/* ============================================================
   Cup of Sugar — base.css
   Tokens + componentes compartilhados (admin e usuário)
   ============================================================ */

/* ── Tokens ── */
:root {
  --md-primary:        #6750A4;
  --md-primary-dark:   #4F378B;
  --md-on-primary:     #FFFFFF;
  --md-secondary:      #625B71;
  --md-surface:        #FFFBFE;
  --md-surface-var:    #E7E0EC;
  --md-surface-2:      #F5EFF7;
  --md-on-surface:     #1C1B1F;
  --md-on-surface-var: #49454F;
  --md-outline:        #79747E;
  --md-outline-var:    #CAC4D0;
  --md-error:          #B3261E;
  --md-success:        #386A20;
  --md-warning:        #7D5700;
  --md-info:           #185FA5;
  --md-scrim:          rgba(0,0,0,.4);
  --sidebar-w:         240px;
  --radius-sm:         4px;
  --radius-md:         12px;
  --radius-lg:         16px;
  --radius-xl:         28px;
  --elev1: 0 1px 2px rgba(0,0,0,.1),0 1px 3px 1px rgba(0,0,0,.08);
  --elev2: 0 1px 2px rgba(0,0,0,.1),0 2px 6px 2px rgba(0,0,0,.1);
  --elev3: 0 4px 8px 3px rgba(0,0,0,.1),0 1px 3px rgba(0,0,0,.2);
}

*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { font-size:14px; }
body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--md-surface); color: var(--md-on-surface);
  -webkit-font-smoothing: antialiased;
}
a { text-decoration:none; color:var(--md-primary); }

/* ── Offline bar ── */
.offline-bar {
  background: var(--md-error); color:#fff;
  text-align:center; font-size:12px; padding:6px;
  display:none; position:fixed; top:0; left:0; right:0; z-index:9999;
}
.offline-bar.show { display:block; }

/* ── LOGIN ── */
.login-wrap {
  min-height:100vh; display:flex; align-items:center;
  justify-content:center; background:var(--md-surface-2);
  padding:20px;
}
.login-card {
  background:var(--md-surface); border-radius:var(--radius-xl);
  padding:40px 36px; width:100%; max-width:400px;
  box-shadow:var(--elev3);
}
.login-logo {
  font-size:28px; font-weight:700; letter-spacing:-.02em;
  color:var(--md-primary); margin-bottom:4px;
}
.login-sub {
  font-size:13px; color:var(--md-on-surface-var);
  margin-bottom:28px;
}
.change-pw-banner {
  background:var(--md-surface-var); border-radius:var(--radius-md);
  padding:10px 14px; font-size:12px; color:var(--md-on-surface-var);
  margin-bottom:16px; border-left:3px solid var(--md-primary);
}

/* ── Inputs (Material Outlined) ── */
.form-group { margin-bottom:16px; }
.form-label {
  display:block; font-size:12px; font-weight:500;
  color:var(--md-on-surface-var); margin-bottom:6px; letter-spacing:.03em;
}
input[type=text],input[type=email],input[type=password],
input[type=date],input[type=time],select,textarea {
  width:100%; padding:10px 14px;
  border:1.5px solid var(--md-outline-var);
  border-radius:var(--radius-sm);
  background:var(--md-surface); color:var(--md-on-surface);
  font-size:14px; font-family:inherit;
  transition:border-color .15s,box-shadow .15s;
  outline:none;
}
input:focus,select:focus,textarea:focus {
  border-color:var(--md-primary);
  box-shadow:0 0 0 2px rgba(103,80,164,.15);
}
textarea { resize:vertical; min-height:70px; }
.row-2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.row-3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:12px; }

/* ── Buttons (Material) ── */
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  padding:9px 20px; border:none; border-radius:var(--radius-xl);
  font-size:13px; font-weight:500; letter-spacing:.03em;
  cursor:pointer; transition:all .2s; font-family:inherit;
  white-space:nowrap; user-select:none;
  background:var(--md-surface-var); color:var(--md-on-surface);
}
.btn:hover   { filter:brightness(.94); box-shadow:var(--elev1); }
.btn:active  { filter:brightness(.88); }
.btn-primary { background:var(--md-primary); color:var(--md-on-primary); }
.btn-primary:hover { box-shadow:var(--elev2); }
.btn-success { background:#386A20; color:#fff; }
.btn-danger  { background:var(--md-error); color:#fff; }
.btn-sm      { padding:6px 14px; font-size:12px; }
.btn-block   { width:100%; margin-top:8px; }
.btn-icon    { padding:8px; border-radius:50%; }

/* ── App layout ── */
.app { display:flex; height:100vh; overflow:hidden; }

/* ── Navigation Rail (sidebar) ── */
.sidebar {
  width:var(--sidebar-w); background:var(--md-surface-var);
  display:flex; flex-direction:column;
  border-right:1px solid var(--md-outline-var);
  overflow-y:auto; flex-shrink:0;
}
.sidebar-header {
  padding:20px 16px 12px;
  border-bottom:1px solid var(--md-outline-var);
}
.sidebar-logo {
  font-size:18px; font-weight:700; color:var(--md-primary);
  letter-spacing:-.01em; line-height:1.2;
}
.sidebar-logo small {
  display:block; font-size:11px; font-weight:400;
  color:var(--md-on-surface-var); margin-top:1px;
}
.nav-section { padding:8px 0; flex:1; }
.nav-label {
  font-size:10px; font-weight:700; letter-spacing:.1em;
  text-transform:uppercase; color:var(--md-on-surface-var);
  padding:12px 16px 4px;
}
.nav-item {
  display:flex; align-items:center; gap:12px;
  padding:12px 16px; cursor:pointer; font-size:13px; font-weight:500;
  color:var(--md-on-surface-var); border-radius:0;
  transition:background .15s,color .15s;
  border-left:3px solid transparent;
}
.nav-item:hover { background:rgba(103,80,164,.08); color:var(--md-on-surface); }
.nav-item.active {
  background:rgba(103,80,164,.12); color:var(--md-primary);
  border-left-color:var(--md-primary); font-weight:600;
}
.nav-icon { width:18px; height:18px; flex-shrink:0; }
.sidebar-footer {
  padding:12px 16px 16px;
  border-top:1px solid var(--md-outline-var);
}
.sidebar-user-name { font-size:13px; font-weight:600; color:var(--md-on-surface); }
.sidebar-user-role { font-size:11px; color:var(--md-on-surface-var); margin-bottom:10px; }

/* ── Main content ── */
.main {
  flex:1; overflow-y:auto; padding:28px 32px;
  background:var(--md-surface);
}
.page   { display:none; }
.page.active { display:block; }
.page-header { margin-bottom:24px; }
.page-header h1 {
  font-size:22px; font-weight:700; color:var(--md-on-surface);
  letter-spacing:-.02em;
}
.page-header p { font-size:13px; color:var(--md-on-surface-var); margin-top:2px; }
.page-header-row { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }

/* ── Cards (Material Surface) ── */
.card {
  background:var(--md-surface); border-radius:var(--radius-lg);
  border:1px solid var(--md-outline-var); padding:20px;
  box-shadow:var(--elev1); margin-bottom:16px;
}
.card-title {
  font-size:14px; font-weight:600; color:var(--md-on-surface);
  margin-bottom:14px; letter-spacing:-.01em;
}
.cards-grid {
  display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:20px;
}
.metric-card {
  background:var(--md-surface-var); border-radius:var(--radius-lg);
  padding:18px 20px; border:1px solid var(--md-outline-var);
}
.metric-label { font-size:11px; font-weight:600; color:var(--md-on-surface-var); letter-spacing:.04em; text-transform:uppercase; margin-bottom:8px; }
.metric-value { font-size:30px; font-weight:700; color:var(--md-on-surface); }
.metric-value.green { color:var(--md-success); }
.metric-value.amber { color:var(--md-warning); }
.metric-value.red   { color:var(--md-error); }

/* ── Row layouts ── */
.row-cols-2 { display:grid; grid-template-columns:1fr 1fr; gap:16px; }

/* ── Tables ── */
table { width:100%; border-collapse:collapse; font-size:13px; }
thead th {
  text-align:left; padding:10px 12px;
  font-size:11px; font-weight:700; letter-spacing:.05em; text-transform:uppercase;
  color:var(--md-on-surface-var); border-bottom:1px solid var(--md-outline-var);
}
tbody td { padding:12px 12px; border-bottom:1px solid var(--md-outline-var); vertical-align:middle; }
tbody tr:last-child td { border-bottom:none; }
tbody tr:hover { background:rgba(103,80,164,.04); }
.action-row { display:flex; gap:6px; flex-wrap:wrap; }

/* ── Badges ── */
.badge {
  display:inline-flex; align-items:center;
  padding:3px 10px; border-radius:var(--radius-xl);
  font-size:11px; font-weight:600; letter-spacing:.03em;
}
.badge-green  { background:#E8F5E9; color:#2E7D32; }
.badge-red    { background:#FFEBEE; color:#C62828; }
.badge-amber  { background:#FFF8E1; color:#F57F17; }
.badge-blue   { background:#E3F2FD; color:#1565C0; }
.badge-purple { background:#F3E5F5; color:#6A1B9A; }
.badge-gray   { background:#F5F5F5; color:#616161; }

/* ── Tabs ── */
.tabs { display:flex; border-bottom:2px solid var(--md-outline-var); margin-bottom:18px; gap:0; }
.tab {
  padding:10px 18px; font-size:13px; font-weight:500; cursor:pointer;
  color:var(--md-on-surface-var); border-bottom:2px solid transparent;
  margin-bottom:-2px; transition:color .15s,border-color .15s;
}
.tab:hover { color:var(--md-primary); }
.tab.active { color:var(--md-primary); border-bottom-color:var(--md-primary); font-weight:600; }
.tab-content { display:none; }
.tab-content.active { display:block; }

/* ── Modais ── */
.modal-overlay {
  display:none; position:fixed; inset:0;
  background:var(--md-scrim); z-index:200;
  align-items:center; justify-content:center;
  padding:16px;
}
.modal-overlay.open { display:flex; }
.modal {
  background:var(--md-surface); border-radius:var(--radius-xl);
  padding:24px; width:480px; max-width:96vw;
  max-height:90vh; overflow-y:auto;
  box-shadow:var(--elev3);
  animation:modalIn .2s ease;
}
.modal-wide { width:560px; }
@keyframes modalIn {
  from { transform:translateY(12px) scale(.97); opacity:0; }
  to   { transform:none; opacity:1; }
}
.modal-title {
  font-size:17px; font-weight:700; color:var(--md-on-surface);
  margin-bottom:18px; letter-spacing:-.01em;
}
.modal-actions {
  display:flex; justify-content:flex-end; gap:8px; margin-top:20px;
}

/* ── Toast ── */
.toast {
  position:fixed; bottom:24px; left:50%; transform:translateX(-50%);
  background:var(--md-on-surface); color:#fff; padding:12px 20px;
  border-radius:var(--radius-xl); font-size:13px; font-weight:500;
  pointer-events:none; opacity:0; transition:opacity .25s;
  z-index:9999; white-space:nowrap; box-shadow:var(--elev3);
}
.toast.show { opacity:1; }
.toast.toast-erro { background:var(--md-error); }

/* ── Checkboxes ── */
.checkbox-row { display:flex; flex-wrap:wrap; gap:8px; }
.cb-label {
  display:flex; align-items:center; gap:5px;
  font-size:13px; cursor:pointer; padding:4px 8px;
  border:1px solid var(--md-outline-var); border-radius:var(--radius-xl);
  transition:all .15s;
}
.cb-label:hover { border-color:var(--md-primary); background:rgba(103,80,164,.06); }
.cb-label input[type=checkbox] { accent-color:var(--md-primary); }

/* ── Info box ── */
.info-box {
  background:rgba(103,80,164,.08); border-radius:var(--radius-md);
  padding:10px 14px; font-size:12px; color:var(--md-on-surface-var);
  margin-bottom:16px;
}

/* ── Alt cards ── */
.alt-card {
  border:1.5px solid var(--md-outline-var); border-radius:var(--radius-lg);
  padding:14px 16px; margin-bottom:8px; cursor:pointer;
  transition:all .15s;
}
.alt-card:hover { border-color:var(--md-primary); background:rgba(103,80,164,.06); }
.alt-vaga { font-size:14px; font-weight:600; color:var(--md-on-surface); }
.alt-loc  { font-size:12px; color:var(--md-on-surface-var); }

/* ── Sidebar: novos itens nav ─────────────────────────────────── */
.nav-item-badge {
  margin-left: auto;
  background: #e53935;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}



/* ══════════════════════════════════════════════════════════════
   RESPONSIVO MOBILE — topbar, hamburger, drawer, bottom-nav
   ══════════════════════════════════════════════════════════════ */

/* Topbar — visível só no mobile */
.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--md-surface-var);
  border-bottom: 1px solid var(--md-outline-var);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}
.topbar-logo {
  font-size: 16px;
  font-weight: 700;
  color: var(--md-primary);
  letter-spacing: -.01em;
}

/* Botão hamburger */
.hamburger {
  width: 40px; height: 40px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 5px; cursor: pointer;
  border-radius: 50%; border: none;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}
.hamburger span {
  display: block; width: 18px; height: 2px;
  background: var(--md-on-surface); border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Overlay do drawer */
.drawer-overlay {
  display: none;
  position: fixed; inset: 0;
  background: var(--md-scrim);
  z-index: 90;
}
.drawer-overlay.open { display: block; }

/* Notif wrapper (header) */
.notif-btn-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Bottom navigation — visível só no mobile */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--md-surface-var);
  border-top: 1px solid var(--md-outline-var);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  justify-content: space-around;
}
.bottom-nav-item {
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  padding: 6px 10px; cursor: pointer;
  color: var(--md-on-surface-var);
  font-size: 10px;
  border-radius: var(--radius-md);
  transition: color .15s;
  min-width: 48px;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--md-primary); }
.bottom-nav-item span { font-weight: 500; }

/* ── Media queries ──────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Ocultar sidebar no mobile — vira drawer */
  .sidebar {
    display: flex !important;
    position: fixed;
    top: 0; left: -100%; bottom: 0;
    width: 280px; z-index: 100;
    transition: left .25s ease;
    overflow-y: auto;
    background: var(--md-surface-var);
    border-right: 1px solid var(--md-outline-var);
  }
  .sidebar.drawer-open { left: 0; }

  /* Mostrar topbar e bottom-nav */
  .topbar     { display: flex; }
  .bottom-nav { display: flex; }

  /* Reflow do app */
  /* #appView é controlado exclusivamente pelo JS — não forçar display aqui */
  .app {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .main {
    padding: 16px 12px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    overflow-y: visible;
    background: var(--md-surface);
  }

  /* Grids simplificados */
  .cards-grid  { grid-template-columns: 1fr 1fr; gap: 10px; }
  .row-cols-2  { grid-template-columns: 1fr; }
  .row-2       { grid-template-columns: 1fr; }
  .row-3       { grid-template-columns: 1fr; }

  /* Cards com scroll horizontal para tabelas */
  .card { overflow-x: auto; }
  table { min-width: 480px; }

  /* Modal como bottom sheet */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 92vh;
    width: 100%;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    animation: sheetUp .25s ease;
  }
  @keyframes sheetUp {
    from { transform: translateY(100%); }
    to   { transform: none; }
  }
  .modal-wide { width: 100%; }

  /* Page header empilhado */
  .page-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page-header-row > div:last-child { width: 100%; }
  .page-header-row > button,
  .page-header-row > div > button { width: 100%; }

  /* Ações */
  .action-row { flex-wrap: wrap; }
  .modal-actions { flex-direction: column-reverse; gap: 8px; }
  .modal-actions .btn { width: 100%; min-height: 46px; font-size: 15px; }

  /* Banner */
  .reserva-ativa-banner { flex-direction: column; align-items: flex-start; }

  /* Tabs — scroll horizontal */
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    gap: 0;
    -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex-shrink: 0; }

  /* Inputs maiores (evita zoom no iOS) */
  input[type=text], input[type=email], input[type=password],
  input[type=date], input[type=time], select, textarea {
    font-size: 16px;
  }

  /* Botões de ação maiores */
  .btn-block { min-height: 48px; font-size: 15px; }
}

@media (max-width: 400px) {
  .cards-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .bottom-nav-item { min-width: 40px; padding: 6px 6px; }
  .metric-value { font-size: 22px; }
}
