/* ════════════════════════════════════════════════
   COMPONENTS — modal, toast, navbar, botões, inputs
   ════════════════════════════════════════════════ */

/* ─── Botões ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--c-card);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { background: var(--c-mint); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary-dk); color: white; }
.btn-primary:hover { background: var(--c-primary-dk); }
.btn-danger { background: var(--c-err); border-color: #B91C1C; color: white; }
.btn-danger:hover { background: #B91C1C; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,.05); }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* ─── Inputs ─── */
.input {
  width: 100%;
  padding: 10px 12px;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--c-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(41,171,226,.15);
}

/* ─── Cards ─── */
.card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  font-weight: 700;
  font-size: 16px;
  color: var(--c-primary-dk);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--c-border);
}

/* ─── Toast ─── */
#toast-root {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--c-card);
  color: var(--c-text);
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--c-primary);
  font-weight: 500;
  font-size: 14px;
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.25s;
  pointer-events: auto;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { border-left-color: var(--c-ok); }
.toast-error   { border-left-color: var(--c-err); }
.toast-warn    { border-left-color: var(--c-warn); }
.toast-info    { border-left-color: var(--c-primary); }

/* ─── Modal ─── */
.rs-modal-bd {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.2s;
}
.rs-modal-bd.show { opacity: 1; }
.rs-modal-box {
  background: var(--c-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s;
}
.rs-modal-bd.show .rs-modal-box { transform: scale(1); }
.rs-modal-hdr {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  background: var(--c-mint);
  color: var(--c-primary-dk);
}
.rs-modal-hdr.danger { background: #FEE2E2; color: #991B1B; }
.rs-modal-icon { display: flex; }
.rs-modal-title { margin: 0; font-size: 16px; font-weight: 700; }
.rs-modal-body { padding: 20px 22px; }
.rs-modal-msg { margin: 0; color: var(--c-text-sub); line-height: 1.5; }
.rs-modal-input {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 14px;
}
.rs-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 22px;
  background: #F9FAFB;
  border-top: 1px solid var(--c-border);
}
.rs-modal-btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  background: var(--c-card);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.rs-modal-btn:hover { background: var(--c-mint); }
.rs-modal-btn.primary { background: var(--c-primary); border-color: var(--c-primary-dk); color: white; }
.rs-modal-btn.primary:hover { background: var(--c-primary-dk); }
.rs-modal-btn.danger { background: var(--c-err); border-color: #B91C1C; color: white; }
.rs-modal-btn.danger:hover { background: #B91C1C; }

/* ─── Navbar (v200.7.6 — ícone em cima + label embaixo) ─── */
#navbar {
  display: flex;
  align-items: stretch;
  gap: 4px;
  background: var(--c-primary-dk);
  color: white;
  padding: 0 12px;
  min-height: 64px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 14px;
  border-right: 1px solid rgba(255,255,255,.15);
  margin-right: 6px;
  /* Ocupa 1/3 (mesmo peso que .nav-right) — assim as abas ficam no centro real da tela */
  flex: 1 1 0;
  min-width: 0;
}
/* Grupo direito (user + clock) — espelho do brand pra centralizar as abas */
.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 0;
  min-width: 0;
  justify-content: flex-end;
  padding-left: 14px;
  border-left: 1px solid rgba(255,255,255,.15);
  margin-left: 6px;
}
.nav-logo { display: flex; }
.nav-brand-txt {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.04em;
  line-height: 1;
}
.nav-tabs-wrap {
  display: flex;
  gap: 2px;
  flex: 0 1 auto;             /* não cresce — usa só o que precisa, brand+right balanceiam ao redor */
  flex-wrap: nowrap;          /* sempre 1 linha */
  justify-content: center;
  align-items: stretch;
  min-width: 0;
  overflow-x: auto;           /* fallback se a tela for muito estreita */
}
.nav-tab {
  display: inline-flex;
  flex-direction: column;     /* ÍCONE EM CIMA, LABEL EMBAIXO */
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 10px;
  background: transparent;
  color: rgba(255,255,255,.78);
  border: 0;
  border-radius: 0;
  border-bottom: 3px solid transparent;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
  white-space: nowrap;
  min-width: 60px;
  flex-shrink: 0;
}
.nav-tab svg { width: 20px; height: 20px; }
.nav-tab:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-tab.active {
  background: rgba(255,255,255,.10);
  color: #fff;
  border-bottom-color: var(--c-primary-lt, #29ABE2);
}

.nav-user { position: relative; align-self: center; flex-shrink: 0; }
.nav-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255,255,255,.1);
  color: white;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.nav-user-trigger:hover { background: rgba(255,255,255,.18); }
.nav-user-avatar {
  background: rgba(255,255,255,.2);
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-user-info { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.nav-user-name { font-size: 13px; font-weight: 600; }
.nav-user-role { font-size: 11px; opacity: 0.7; }
.nav-user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: all 0.15s;
}
.nav-user-menu.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.nav-user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  color: var(--c-text);
  border: 0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}
.nav-user-item:hover { background: var(--c-mint); }
.nav-user-item.danger { color: var(--c-err); }
.nav-user-item.danger:hover { background: #FEE2E2; }

.nav-clock {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-size: 18px;
  font-weight: 700;
  color: white;
  text-shadow: 0 0 10px rgba(255,255,255,.4);
  min-width: 8.5ch;
  text-align: right;
  white-space: nowrap;
  align-self: center;
  flex-shrink: 0;
}

/* Tela média (laptop ≤1280px) — esconde texto "Bonito Flow" pra dar respiro pras abas */
@media (max-width: 1280px) {
  .nav-brand-txt { display: none; }
  .nav-brand {
    /* Sem texto, o brand fica fininho — não precisa do flex:1 espelhando o lado direito */
    flex: 0 0 auto;
    padding-right: 10px;
    margin-right: 4px;
  }
  .nav-right {
    flex: 0 0 auto;
    padding-left: 10px;
    margin-left: 4px;
  }
  .nav-tabs-wrap {
    flex: 1 1 auto;            /* volta a expandir e centralizar dentro do espaço sobrante */
  }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   TABLET/MOBILE (≤900px) — Bottom nav padrão Instagram/WhatsApp/MercadoLivre
   - Topbar reduzida: só brand + user + clock
   - Abas vão pro RODAPÉ, fixadas, distribuídas igualmente
   - Active state passa pra BORDA SUPERIOR (em vez de inferior)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@media (max-width: 900px) {
  .nav-user-info { display: none; }
  #navbar { min-height: 52px; padding: 0 10px; }

  .nav-tabs-wrap {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--c-primary-dk);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));  /* safe area iOS */
    gap: 0;
    justify-content: space-around;     /* distribui igualmente na largura */
    box-shadow: 0 -4px 12px rgba(0,0,0,.25);
    border-top: 1px solid rgba(255,255,255,.10);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-tab {
    flex: 1 0 auto;
    min-width: 56px;
    padding: 6px 4px;
    font-size: 10px;
    border-bottom: 0;
    border-top: 3px solid transparent;   /* active indicator vira em cima */
  }
  .nav-tab svg { width: 22px; height: 22px; }   /* ícones um pouco maiores pra toque */
  .nav-tab.active {
    background: rgba(255,255,255,.08);
    border-top-color: var(--c-primary-lt, #29ABE2);
  }

  /* Espaço pro conteúdo não ficar atrás da barra inferior */
  #page-app, #page-content, .page {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }
}

/* Mobile estreito — só ícone (sem label) na bottom nav */
@media (max-width: 480px) {
  .nav-tab span { display: none; }
  .nav-tab { min-width: 44px; padding: 8px 4px; }
  .nav-tab svg { width: 24px; height: 24px; }
}

/* User trigger ajustado pro novo navbar de 64px */
.nav-user-trigger {
  align-self: center;
}
