/* ─── Variáveis ─────────────────────────────────────────── */
:root {
  --primary: #4f8ef7;
  --primary-dark: #3a72d0;
  --danger: #f87171;
  --warning-color: #fbbf24;
  --success: #34d399;
  --info: #60a5fa;
  --bg: #111;
  --bg2: #1a1a1a;
  --bg3: #232323;
  --bg-card: #1e1e1e;
  --border: #2a2a2a;
  --border2: #333;
  --text: #f0f0f0;
  --text2: #aaa;
  --text-muted: #666;
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 240px;
  --top-h: 56px;
  --bottom-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.5;
  min-height: 100%; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: 16px; }

/* ─── Layout ─────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ─── Overlay (mobile drawer) ───────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.65); z-index: 199;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 200;
  border-right: 1px solid var(--border);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.sidebar-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex; align-items: center;
  gap: 10px; font-size: 16px; font-weight: 700; color: #fff;
}
.sidebar-logo i { font-size: 22px; color: var(--primary); }

.btn-close-sidebar { display: none; }

.sidebar-nav {
  flex: 1; padding: 10px 8px;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--text2); font-size: 14px; font-weight: 400;
  transition: background .15s, color .15s;
  border: none; background: none; width: 100%; text-align: left;
  min-height: 44px;
}
.nav-item i { font-size: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(79,142,247,.15); color: var(--primary); font-weight: 500; }

.sidebar-notify { padding: 8px; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 8px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}

.user-info {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0; text-decoration: none; color: inherit;
}
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); display: flex;
  align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0;
}

/* ─── Ícone botão genérico ──────────────────────────────── */
.btn-icon {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 8px;
  background: none; border: none; color: var(--text2);
  font-size: 20px; transition: background .15s, color .15s;
  flex-shrink: 0;
}
.btn-icon:hover { background: rgba(255,255,255,.07); color: #fff; }
.btn-logout { border: 1px solid var(--border); }
.btn-logout:hover { background: rgba(248,113,113,.1); color: var(--danger); border-color: var(--danger); }

/* ─── Top Bar (mobile) ──────────────────────────────────── */
.top-bar {
  display: none;
  align-items: center; height: var(--top-h);
  padding: 0 8px 0 4px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100; gap: 4px;
}
.top-bar-title { flex: 1; font-size: 16px; font-weight: 600; color: #fff; padding: 0 4px; }
.top-bar-right { min-width: 38px; }
.btn-hamburger { font-size: 22px; }

/* ─── Conteúdo principal ────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; }
.content-inner { padding: 20px 16px; flex: 1; }

/* ─── Bottom Nav (mobile) ───────────────────────────────── */
.bottom-nav {
  display: none; position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg2); border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: var(--safe-bottom);
}

.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; height: var(--bottom-h);
  background: none; border: none;
  color: var(--text-muted); font-size: 10px;
  text-decoration: none; transition: color .15s;
  min-width: 0; padding: 6px 2px;
}
.bottom-nav-item i { font-size: 22px; line-height: 1; }
.bottom-nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item:hover { color: var(--text2); }

/* ─── Mobile media query ────────────────────────────────── */
@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 6px 0 24px rgba(0,0,0,.5); }
  .btn-close-sidebar { display: flex; }
  .top-bar { display: flex; }
  .bottom-nav { display: flex; }
  .main-content { margin-left: 0; }
  .content-inner {
    padding: 12px;
    padding-bottom: calc(var(--bottom-h) + var(--safe-bottom) + 12px);
  }
}

@media (min-width: 768px) {
  .main-content { margin-left: var(--sidebar-w); }
  .content-inner { padding: 24px; max-width: 960px; }
}

/* ─── Autenticação ──────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 24px;
  width: 100%; max-width: 380px;
}
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-logo i { font-size: 32px; color: var(--primary); }
.auth-logo-text { font-size: 20px; font-weight: 700; }
.auth-logo-sub { font-size: 11px; color: var(--text-muted); }

/* ─── Cabeçalho de página ───────────────────────────────── */
.page-header { margin-bottom: 16px; }
.page-header h2 { font-size: 18px; font-weight: 600; }
.page-header p { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* ─── Card ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 14px; font-weight: 600; }

/* ─── Métricas ──────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px; margin-bottom: 14px;
}
@media (min-width: 480px) { .metrics-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 768px) { .metrics-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); } }

.metric-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 12px;
}
.metric-card.metric-danger { border-color: var(--danger); background: rgba(248,113,113,.06); }
.metric-card.metric-warning { border-color: var(--warning-color); background: rgba(251,191,36,.06); }
.metric-label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .4px; }
.metric-value { font-size: 26px; font-weight: 700; display: block; }

/* ─── Tabelas ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; min-width: 360px; }
th {
  text-align: left; padding: 9px 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 14px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ─── Formulários ───────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
.form-control {
  display: block; width: 100%;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 11px 13px; font-size: 16px;
  transition: border-color .15s;
  -webkit-appearance: none; appearance: none;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }

/* ─── Botões ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; border: none;
  cursor: pointer; transition: all .15s; min-height: 44px; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover  { background: #e05555; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--border2); }
.btn-ghost { background: none; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-sm { padding: 7px 12px; font-size: 13px; min-height: 36px; }
.btn-block { width: 100%; }

/* ─── Badges / Status ───────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-ok      { background: rgba(52,211,153,.15); color: var(--success); }
.badge-danger  { background: rgba(248,113,113,.15); color: var(--danger);  }
.badge-warning { background: rgba(251,191,36,.15);  color: var(--warning-color); }
.badge-info    { background: rgba(96,165,250,.15);  color: var(--info); }

/* ─── Role badge ────────────────────────────────────────── */
.role-badge { font-size: 10px; padding: 2px 7px; border-radius: 20px; font-weight: 600; }
.role-dev     { background: rgba(167,139,250,.2); color: #c4b5fd; }
.role-geral   { background: rgba(52,211,153,.2);  color: #6ee7b7; }
.role-estoque { background: rgba(251,191,36,.2);  color: #fde68a; }
.role-pedidos { background: rgba(251,146,60,.2);  color: #fdba74; }
.role-admin   { background: rgba(96,165,250,.2);  color: #bfdbfe; }
.role-pendente{ background: rgba(156,163,175,.2); color: #d1d5db; }

/* ─── Alertas ───────────────────────────────────────────── */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 14px; }
.alert i { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: rgba(52,211,153,.12); color: var(--success); border: 1px solid rgba(52,211,153,.25); }
.alert-danger  { background: rgba(248,113,113,.12); color: var(--danger);  border: 1px solid rgba(248,113,113,.25); }
.alert-warning { background: rgba(251,191,36,.12);  color: var(--warning-color); border: 1px solid rgba(251,191,36,.25); }
.alert-info    { background: rgba(96,165,250,.12);  color: var(--info);   border: 1px solid rgba(96,165,250,.25); }

/* ─── Info box ──────────────────────────────────────────── */
.info-box { background: rgba(96,165,250,.1); color: var(--info); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 12px; display: flex; gap: 8px; border: 1px solid rgba(96,165,250,.2); }

/* ─── Pedidos ───────────────────────────────────────────── */
.pedido-card { padding: 14px 0; border-bottom: 1px solid var(--border); }
.pedido-card:last-child { border-bottom: none; }
.pedido-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; flex-wrap: wrap; }
.pedido-itens { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.pedido-item-tag { background: var(--bg3); border: 1px solid var(--border2); border-radius: 6px; padding: 4px 8px; font-size: 12px; }
.pedido-obs { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.pedido-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ─── Produtos (pedidos) ────────────────────────────────── */
.prod-grid { display: flex; flex-direction: column; gap: 2px; }
.prod-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: var(--radius-sm);
  background: var(--bg3); cursor: pointer;
  transition: background .15s; min-height: 60px;
}
.prod-card:hover { background: var(--border2); }
.prod-card.selected { background: rgba(79,142,247,.15); border: 1px solid rgba(79,142,247,.3); }
.prod-icon {
  width: 38px; height: 38px; border-radius: 9px;
  background: rgba(79,142,247,.15); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; flex-shrink: 0;
}
.prod-info { flex: 1; min-width: 0; }
.prod-nome { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prod-saldo { font-size: 12px; color: var(--text-muted); }
.stock-neg  { color: var(--danger); }
.stock-zero { color: var(--danger); }
.stock-low  { color: var(--warning-color); }
.stock-ok   { color: var(--text-muted); }
.prod-qty-wrap { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.qty-btn { width: 32px; height: 32px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--border2); color: var(--text); font-size: 18px; display: flex; align-items: center; justify-content: center; }
.qty-input { width: 52px; height: 32px; text-align: center; background: var(--bg2); border: 1px solid var(--border2); border-radius: 7px; color: var(--text); font-size: 14px; padding: 0 4px; }

/* ─── Usuários ──────────────────────────────────────────── */
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.user-row:last-child { border-bottom: none; }
.user-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ─── Filtros ───────────────────────────────────────────── */
.filter-form { margin-bottom: 16px; }

/* ─── BottomSheet (modal mobile) ───────────────────────── */
.sheet-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 300;
  backdrop-filter: blur(2px);
}
.sheet-overlay.show { display: block; }

.sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg2); border-radius: var(--radius) var(--radius) 0 0;
  border-top: 1px solid var(--border);
  z-index: 301; max-height: 90vh; overflow-y: auto;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  padding-bottom: var(--safe-bottom);
}
.sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--border2); margin: 12px auto 0;
}
.sheet-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.sheet-title { font-size: 16px; font-weight: 600; }
.sheet-body { padding: 16px; }
.sheet-actions { padding: 12px 16px 16px; display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; }

/* ─── Cardápio ──────────────────────────────────────────── */
.cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 8px;
}
.cal-nav-title { font-size: 15px; font-weight: 600; flex: 1; text-align: center; }
.cal-view-toggle {
  display: flex; gap: 4px; background: var(--bg3);
  border-radius: var(--radius-sm); padding: 3px;
}
.cal-toggle-btn {
  padding: 5px 12px; border-radius: 6px; border: none;
  background: none; color: var(--text-muted); font-size: 13px; font-weight: 500;
  transition: all .15s;
}
.cal-toggle-btn.active { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.3); }

.dia-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 10px; overflow: hidden;
}
.dia-header {
  padding: 12px 14px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border);
}
.dia-label { font-size: 13px; font-weight: 600; }
.dia-data  { font-size: 12px; color: var(--text-muted); }
.dia-hoje  { border-color: var(--primary); }
.dia-hoje .dia-header { background: rgba(79,142,247,.08); }

.refeicao-item {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px;
}
.refeicao-item:last-child { border-bottom: none; }
.refeicao-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.refeicao-body { flex: 1; min-width: 0; }
.refeicao-tipo { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 3px; }
.refeicao-desc { font-size: 14px; line-height: 1.4; }
.refeicao-obs  { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.refeicao-edit { flex-shrink: 0; }

.dia-add {
  padding: 10px 14px; display: flex; gap: 8px; flex-wrap: wrap;
}
.btn-add-ref {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 8px; border: 1px dashed var(--border2);
  background: none; color: var(--text-muted); font-size: 13px;
  transition: all .15s;
}
.btn-add-ref:hover { border-color: var(--primary); color: var(--primary); }

/* ─── Calendário mensal ─────────────────────────────────── */
.month-grid { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.month-weekdays {
  display: grid; grid-template-columns: repeat(7,1fr);
  background: var(--bg3); border-bottom: 1px solid var(--border);
}
.month-weekday { text-align: center; padding: 8px 4px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.month-days { display: grid; grid-template-columns: repeat(7,1fr); }
.month-day {
  aspect-ratio: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s; position: relative; padding: 4px;
  font-size: 13px; font-weight: 500;
}
.month-day:nth-child(7n) { border-right: none; }
.month-day:hover { background: var(--bg3); }
.month-day.outro-mes { color: var(--text-muted); opacity: .4; cursor: default; }
.month-day.hoje { color: var(--primary); font-weight: 700; }
.month-day.tem-refeicao::after {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--primary); display: block;
}
.month-day.tem-refeicao.hoje::after { background: var(--primary); }

/* ─── Misc ──────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* iOS notch support */
@supports (padding-top: env(safe-area-inset-top)) {
  .top-bar { padding-top: env(safe-area-inset-top); height: calc(var(--top-h) + env(safe-area-inset-top)); }
}
