/* ── Google Fonts ──────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Variáveis — tema claro corporativo (inspirado CGE Portal) ─────────────── */
:root {
  /* Paleta principal */
  --navy:       #1a3a52;
  --navy-dk:    #122840;
  --accent:     #0097d4;
  --accent-dk:  #0078a8;
  --accent-lt:  #e8f5fb;

  /* Superfícies */
  --bg:         #eef2f7;
  --surface:    #ffffff;
  --surface2:   #f5f8fb;

  /* Texto */
  --text:       #1e2d3d;
  --muted:      #5e7a8f;

  /* Bordas e sombras */
  --border:     #cddbe8;
  --shadow-sm:  0 1px 3px rgba(26,58,82,.07);
  --shadow-md:  0 3px 10px rgba(26,58,82,.10);
  --shadow-lg:  0 6px 20px rgba(26,58,82,.13);

  /* Semânticas */
  --green:      #1a9e56;
  --red:        #d93025;
  --yellow:     #e09000;

  /* Geometria */
  --radius:     8px;
  --radius-lg:  12px;
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-dk); }

/* ── NAVBAR ────────────────────────────────────────────────────────────────── */
nav {
  background: var(--navy);
  border-bottom: 3px solid var(--accent);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

nav .brand {
  font-weight: 800;
  font-size: 1.05rem;
  color: #ffffff;
  margin-right: 20px;
  white-space: nowrap;
  letter-spacing: .01em;
}

nav a {
  color: rgba(255,255,255,.72);
  text-decoration: none;
  padding: 6px 13px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all .15s;
}
nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
nav a.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ── PAGE LAYOUT ───────────────────────────────────────────────────────────── */
.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 28px 48px;
}

h1 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}

h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--navy);
}

/* ── CARDS ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

/* ── FORMS ─────────────────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

input[type=text],
input[type=number],
input[type=date],
input[type=password],
input[type=email],
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,151,212,.12);
}
input::placeholder { color: var(--muted); opacity: .7; }
input[type=number] { width: 80px; text-align: right; }

/* ── BUTTONS ───────────────────────────────────────────────────────────────── */
button, .btn {
  padding: 8px 18px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  transition: all .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover {
  background: var(--navy-dk);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover {
  background: var(--accent-dk);
  box-shadow: var(--shadow-sm);
}

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b71c1c; }

.btn-ghost {
  background: var(--surface);
  color: var(--navy);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-lt);
}

.btn-sm { padding: 5px 11px; font-size: 0.8rem; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }

/* ── TABLES ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; background: var(--surface); }

th {
  background: var(--navy);
  color: rgba(255,255,255,.88);
  padding: 9px 11px;
  text-align: center;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  border: 1px solid rgba(255,255,255,.08);
  white-space: nowrap;
}

td {
  padding: 7px 9px;
  border: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
  color: var(--text);
}

tbody tr:hover td { background: var(--accent-lt); }
td.nome { text-align: left; font-weight: 600; white-space: nowrap; padding-left: 14px; color: var(--navy); }

td.calc {
  background: rgba(0,151,212,.07);
  color: var(--accent-dk);
  font-weight: 700;
  pointer-events: none;
}
td.total-row { background: var(--surface2); font-weight: 700; color: var(--navy); }
td.total-row.calc { color: var(--accent); }
td.saldo-pos { color: var(--green); font-weight: 700; }
td.saldo-neg { color: var(--red);   font-weight: 700; }

/* Input dentro de célula */
input.cell-input {
  width: 70px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  padding: 3px 6px;
  text-align: right;
  font-family: inherit;
}
input.cell-input:hover { border-color: var(--border); background: var(--surface); }
input.cell-input:focus { border-color: var(--accent); background: var(--surface); outline: none; box-shadow: none; }

/* ── CHECKBOXES ────────────────────────────────────────────────────────────── */
.dia-check { text-align: center; vertical-align: middle; }
.dia-check input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

/* ── SEMANA BAR ────────────────────────────────────────────────────────────── */
.semana-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.semana-bar select { min-width: 260px; }

/* ── BADGES ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-green { background: rgba(26,158,86,.12); color: var(--green); }
.badge-red   { background: rgba(217,48,37,.10); color: var(--red); }
.badge-blue  { background: var(--accent-lt); color: var(--accent-dk); }

/* ── TOASTS ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--green);
  color: #fff;
  padding: 13px 22px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
  transform: translateY(8px);
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

/* ── HOME GRID ─────────────────────────────────────────────────────────────── */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px,1fr));
  gap: 20px;
  margin-top: 28px;
}
.home-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-decoration: none;
  color: var(--text);
  transition: all .2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}
.home-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.home-card .icon { font-size: 2.2rem; }
.home-card h2 { font-size: 1.1rem; color: var(--navy); }
.home-card p { color: var(--muted); font-size: 0.875rem; line-height: 1.55; }
.home-card .badge-tv {
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  font-size: 0.65rem;
  padding: 2px 6px;
  font-weight: 700;
  vertical-align: middle;
}

/* ── SEMANA ITENS (index.html) ─────────────────────────────────────────────── */
.semana-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1px solid var(--border);
  gap: 12px;
  transition: all .15s;
}
.semana-item:hover { border-color: var(--accent); background: var(--accent-lt); }
.semana-item .info { display: flex; flex-direction: column; gap: 3px; }
.semana-item .nome { font-weight: 700; font-size: 0.95rem; color: var(--navy); }
.semana-item .datas { font-size: 0.8rem; color: var(--muted); }
.semana-item .acoes { display: flex; gap: 8px; }
#listaSemanas { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
#semanaVazia { color: var(--muted); font-size: 0.9rem; }

/* ── CLIENTES ──────────────────────────────────────────────────────────────── */
.cliente-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.cliente-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: all .2s;
}
.cliente-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.cliente-nome { font-size: 1rem; font-weight: 700; color: var(--navy); }
.cliente-info { font-size: 0.85rem; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.cliente-info span { display: flex; align-items: center; gap: 7px; }
.cliente-acoes { display: flex; gap: 8px; margin-top: 4px; }
.inativo { opacity: 0.45; }

.dia-tag {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  transition: .15s;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.dia-tag:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-lt); }

/* ── PRODUÇÃO: SALDO BADGE ─────────────────────────────────────────────────── */
.saldo-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
}

/* ── MODAIS ─────────────────────────────────────────────────────────────────── */
[id^="modal"] > div,
#modalCliente > div,
#modalUsuario > div {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-lg) !important;
}

/* ── PAINEL OCULTAS (estoque) ───────────────────────────────────────────────── */
.ocultas-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-top: 12px;
}

/* ── RESPONSIVO ─────────────────────────────────────────────────────────────── */
/* ── Hambúrguer ─────────────────────────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
  flex-direction: column;
  gap: 5px;
}
.nav-hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: .25s;
}
.nav-hamburger.aberto span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.aberto span:nth-child(2) { opacity: 0; }
.nav-hamburger.aberto span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-links { display: contents; }

@media (max-width: 768px) {
  nav {
    padding: 0 16px;
    height: 54px;
    flex-wrap: wrap;
    align-items: center;
    position: relative;
  }
  nav .brand { font-size: 0.9rem; flex: 1; }
  .nav-hamburger { display: flex; margin-left: 0; }

  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    background: var(--navy-dk);
    border-top: 1px solid rgba(255,255,255,.1);
    padding: 8px 0 12px;
    position: absolute;
    top: 54px;
    left: 0;
    right: 0;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
  }
  .nav-links.aberto { display: flex; }
  .nav-links a {
    padding: 12px 20px;
    font-size: 0.95rem;
    border-radius: 0;
    border-bottom: 1px solid rgba(255,255,255,.06);
    color: rgba(255,255,255,.85);
  }
  .nav-links a:last-child { border-bottom: none; }
  .nav-links a.active { background: var(--accent); color: #fff; }
  .nav-links a:hover { background: rgba(255,255,255,.1); }

  /* Esconde botões de usuário/logout do nav no mobile — ficam no menu */
  nav > div[style*="margin-left:auto"] { display: none; }

  .page { padding: 16px 14px 40px; }
  h1 { font-size: 1.2rem; }
  .home-grid { grid-template-columns: 1fr; }
  .semana-item { flex-direction: column; align-items: flex-start; }
  .semana-item .acoes { flex-wrap: wrap; }
  .card { padding: 16px; }
  .card-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .semana-bar { flex-direction: column; align-items: stretch; }
  .semana-bar select { min-width: unset; width: 100%; }

  /* Tabelas com sticky na primeira coluna */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table td:first-child,
  .table-wrap table th:first-child {
    position: sticky;
    left: 0;
    background: var(--surface);
    z-index: 2;
    box-shadow: 2px 0 6px rgba(0,0,0,.08);
  }
  .table-wrap table thead th:first-child {
    background: var(--navy);
    z-index: 3;
  }

  /* Clientes — botões maiores */
  .cliente-acoes .btn { flex: 1; justify-content: center; padding: 10px; font-size: 0.9rem; }
  .cliente-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   DASHBOARD TV — mantém tema escuro (tela de televisão)
   ══════════════════════════════════════════════════════════════════════════════ */
body.dashboard-mode {
  background: #000 !important;
  overflow: hidden;
  color: #e2e8f0;

  /* Redefine variáveis para o contexto escuro do dashboard TV */
  --accent:   #4f8ef7;
  --accent-dk:#3b7de8;
  --accent-lt:#1a2a4a;
  --text:     #e2e8f0;
  --muted:    #64748b;
  --surface:  #1a1d27;
  --surface2: #22263a;
  --border:   #2e3350;
  --green:    #22c55e;
  --yellow:   #f59e0b;
  --red:      #ef4444;
  --navy:     #0f1117;
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 40px 8px;
}
.dash-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: #4f8ef7;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.dash-semana { font-size: 1rem; color: #64748b; }
.dash-clock {
  font-size: 1.4rem;
  font-weight: 700;
  color: #e2e8f0;
  font-variant-numeric: tabular-nums;
}

.dash-list {
  padding: 10px 40px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.dash-item {
  display: grid;
  grid-template-columns: 50px 1fr auto auto;
  align-items: center;
  gap: 16px;
  background: #1a1d27;
  border: 1px solid #2e3350;
  border-radius: 12px;
  padding: 14px 20px;
  transition: .3s;
}
.dash-item.top1 { border-color: #f59e0b; background: rgba(245,158,11,.08); }
.dash-item.top2 { border-color: #94a3b8; background: rgba(148,163,184,.05); }
.dash-item.top3 { border-color: #b45309; background: rgba(180,83,9,.05); }

.dash-pos { font-size: 1.6rem; font-weight: 900; color: #64748b; text-align: center; }
.dash-item.top1 .dash-pos { color: #f59e0b; }
.dash-item.top2 .dash-pos { color: #94a3b8; }
.dash-item.top3 .dash-pos { color: #b45309; }

.dash-nome { font-size: 1.4rem; font-weight: 700; letter-spacing: .02em; color: #e2e8f0; }

.dash-bar-wrap { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.dash-bar-bg { height: 12px; background: #22263a; border-radius: 6px; overflow: hidden; }
.dash-bar-fill { height: 100%; border-radius: 6px; transition: width .8s ease; }
.fill-green  { background: #22c55e; }
.fill-yellow { background: #f59e0b; }
.fill-red    { background: #ef4444; }

.dash-value {
  font-size: 2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  text-align: right;
  color: #e2e8f0;
}
.dash-saldo {
  font-size: 1.1rem;
  font-weight: 600;
  min-width: 90px;
  text-align: right;
  color: #e2e8f0;
}

.dash-legend {
  display: flex;
  gap: 20px;
  padding: 8px 40px;
  font-size: 0.8rem;
  color: #64748b;
  border-top: 1px solid #2e3350;
}
.dash-legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; }

/* ── Histórico de semanas ───────────────────────────────────────────────────── */
.semana-hist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  transition: .15s;
  cursor: pointer;
}
.semana-hist-item:hover { border-color: var(--accent); background: var(--accent-lt); }
.semana-hist-item.selecionada {
  border-color: var(--accent);
  background: var(--accent-lt);
  box-shadow: 0 0 0 2px rgba(0,151,212,.15);
}
.semana-hist-info { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.semana-hist-nome { font-weight: 600; font-size: .95rem; color: var(--navy); }
.semana-hist-datas { font-size: .8rem; color: var(--muted); }
.semana-hist-acoes { display: flex; gap: 8px; flex-shrink: 0; }
.badge-atual {
  background: var(--accent); color: #fff;
  font-size: .68rem; font-weight: 700; padding: 2px 7px;
  border-radius: 10px; letter-spacing: .04em;
}
.badge-vis {
  color: var(--accent); font-size: .72rem; font-weight: 700;
}

@media (max-width: 768px) {
  .semana-hist-item { flex-direction: column; align-items: flex-start; }
  .semana-hist-acoes { width: 100%; }
  .semana-hist-acoes .btn { flex: 1; justify-content: center; }
}

/* ── Modal de confirmação ───────────────────────────────────────────────────── */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease;
}
.confirm-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  max-width: 420px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: slideUp .18s ease;
}
.confirm-box .confirm-icon { font-size: 2rem; margin-bottom: 10px; }
.confirm-box h3 { font-size: 1.05rem; color: var(--navy); margin-bottom: 8px; }
.confirm-box p  { font-size: 0.9rem; color: var(--muted); line-height: 1.5; margin-bottom: 24px; }
.confirm-btns   { display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fadeIn  { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0 } to { transform: none; opacity: 1 } }
