/* ============================================================
   DigaWeb — Tema moderno  (carregar DEPOIS de css/style.css)
   - Cores continuam vindo de --primary / --primary-dark, então o
     DW_CONFIG (js/config.js) segue mandando na identidade do cliente.
   - Modo escuro continua funcionando: tudo usa as variáveis.
   ============================================================ */

:root {
  --bg:        #f4f6fb;
  --surface:   #ffffff;
  --surface2:  #f6f8fc;
  --surface3:  #eceff6;
  --border:    #e5e9f2;
  --border-med:#d3d9e6;
  --text:      #111827;
  --text-muted:#667085;
  --text-light:#98a2b3;

  --radius-sm: 12px;
  --radius:    18px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.04), 0 4px 14px rgba(16,24,40,.05);
  --shadow:    0 8px 24px rgba(16,24,40,.08);
  /* tons derivados da cor da marca (DW_CONFIG.COR_PRIMARIA) */
  --primary-muted: color-mix(in srgb, var(--primary) 12%, transparent);
  --ring:      0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent);
  --nav-h:     68px;
}
body.dark {
  --border:    #1e2a41;
  --surface3:  #1b2438;
  --primary-muted: color-mix(in srgb, var(--primary) 16%, transparent);
  --ring:      0 0 0 4px color-mix(in srgb, var(--primary) 26%, transparent);
}

/* ── Fundo ─────────────────────────────────────────────── */
body { background-color: var(--bg); }
body::before { background: rgba(244,246,251,.965); }
body.dark::before { background: rgba(10,14,26,.96); }

/* Banner de instalação rola junto com a página (não cobre o cabeçalho) */
#pwa-banner { position: relative; top: auto; }

/* ── Cabeçalho: claro, limpo, com o menu à direita ─────── */
#app-header {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(16,24,40,.02), 0 8px 24px rgba(16,24,40,.04) !important;
}
.header-inner { padding: 10px 16px 10px; }
.logo-area { color: var(--text); margin-bottom: 10px; gap: 12px; }
.logo-area img {
  height: 40px !important; width: 40px !important;
  border-radius: 12px !important;
  box-shadow: 0 2px 8px rgba(16,24,40,.12);
}
.logo-area h1 { font-size: 17px; font-weight: 800; letter-spacing: -.2px; color: var(--text); }
.logo-area span#header-user-nome {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; opacity: 1;
  text-transform: none; letter-spacing: 0;
  color: var(--text-muted); max-width: 190px;
}
.logo-area span#header-user-nome::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--secondary); box-shadow: 0 0 0 3px rgba(16,185,129,.18);
  flex-shrink: 0;
}
.hdr-menu-btn {
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
}
.hdr-menu-btn:hover { background: var(--surface3); }

/* ── Abas (desktop: segmentado · celular: barra inferior) ─ */
.tab-nav {
  background: var(--surface3);
  padding: 4px; gap: 4px; border-radius: 14px;
}
.tab-btn {
  flex-direction: row; justify-content: center; gap: 8px;
  background: transparent; border: none; border-radius: 10px;
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  padding: 10px 6px;
}
.tab-btn:hover { background: rgba(255,255,255,.55); color: var(--text); }
body.dark .tab-btn:hover { background: rgba(255,255,255,.06); }
.tab-btn.active {
  background: var(--surface); color: var(--primary);
  box-shadow: 0 1px 3px rgba(16,24,40,.12), 0 4px 12px rgba(16,24,40,.06);
  border: none;
}
.tab-btn i { font-size: 14px; }

@media (max-width: 720px) {
  #app-main { padding-bottom: calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px)); }
  .tab-nav {
    position: fixed; left: 12px; right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 150; margin: 0; padding: 6px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border: 1px solid var(--border); border-radius: 22px;
    box-shadow: 0 12px 32px rgba(16,24,40,.18);
  }
  .tab-btn {
    flex-direction: column; gap: 3px; font-size: 10.5px;
    padding: 8px 2px; border-radius: 16px; min-width: 0;
  }
  .tab-btn i { font-size: 17px; }
  .tab-btn.active { background: var(--primary-muted); color: var(--primary); box-shadow: none; }
  .toast { bottom: calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px)) !important; }
}

/* ── Cabeçalhos de página ──────────────────────────────── */
.form-header { text-align: left; padding: 22px 2px 12px; }
.form-header h2 {
  justify-content: flex-start; font-size: 22px; font-weight: 800;
  letter-spacing: -.4px; color: var(--text);
}
.form-header h2 i {
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-muted); color: var(--primary); border-radius: 12px; font-size: 16px;
}
.form-header p { margin-top: 6px; font-size: 13.5px; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border) !important;
  border-left: 1px solid var(--border) !important;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card:hover { transform: none; box-shadow: var(--shadow-sm); }
.actions-card { border: none !important; box-shadow: none; padding: 0; }
.card-title {
  font-size: 13px; letter-spacing: 0; text-transform: none; font-weight: 700;
  color: var(--text); border-bottom: 1px solid var(--border);
  padding-bottom: 14px; margin-bottom: 16px;
}
.card-title i {
  width: 30px; height: 30px; border-radius: 10px; font-size: 13px;
  background: var(--primary-muted); color: var(--primary);
}

/* ── Campos ────────────────────────────────────────────── */
label { font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-muted); }
input[type="text"], input[type="number"], input[type="date"], input[type="time"],
input[type="month"], input[type="search"], select, textarea {
  border: 1px solid var(--border-med);
  border-radius: 12px; background: var(--surface);
  padding: 12px 14px; min-height: 46px; font-size: 14.5px;
}
input[type="month"] { width: 100%; font-family: var(--font); color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: var(--ring); background: var(--surface);
}
body.dark input[type="month"] { background: var(--surface2); border-color: var(--border); color: var(--text); color-scheme: dark; }
input:read-only:not([type="date"]):not([type="month"]) { background: var(--surface2); }

/* ── Botões ────────────────────────────────────────────── */
button { border-radius: 12px; }
#btn-salvar, #btn-whatsapp {
  padding: 16px 24px !important; border-radius: 14px !important;
  font-size: 15px !important; font-weight: 700 !important;
}
#btn-salvar {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 32%, transparent) !important;
}
#btn-limpar { border-radius: 14px; }
.btn-refresh, .btn-copy, .btn-wpp, .btn-export {
  border-radius: 12px; font-weight: 600; padding: 11px 16px; font-size: 13.5px;
}
.btn-refresh { background: var(--primary); color: #fff; }
.btn-copy { background: var(--primary-muted); color: var(--primary); border: none; }
.btn-copy:hover { background: var(--primary); color: #fff; }
.btn-wpp { background: linear-gradient(135deg, #25D366, #128C7E); color: #fff; border: none; }
.btn-refresh:hover { background: var(--primary-dark); }
body.dark .btn-refresh { background: var(--primary-dark); color: #fff; }

.filter-bar {
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow-sm); gap: 10px;
}
.filter-bar label { font-size: 12.5px; color: var(--text-muted); }

/* ── Sub-abas e listas ─────────────────────────────────── */
.at-tabs { background: var(--surface3); border-radius: 14px; padding: 4px; }
.at-tab-btn { border-radius: 10px; }
.at-tab-btn.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(16,24,40,.12); }
body.dark .at-tab-btn.active { background: var(--surface); color: var(--primary); }

.atendimento-card {
  border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.atendimento-header { background: var(--surface2) !important; }
.atendimento-title { color: var(--text); font-weight: 700; }

/* ── Menu lateral ──────────────────────────────────────── */
#app-drawer { border-radius: 24px 0 0 24px; box-shadow: -12px 0 40px rgba(16,24,40,.22) !important; }
#app-drawer > div:first-child {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
  border-radius: 24px 0 0 0;
}
.app-drawer-item { margin: 2px 10px; width: calc(100% - 20px); border-radius: 12px; padding: 12px 14px; }
.app-drawer-item:hover { background: var(--primary-muted); }

/* ── Seletor de técnico adicional ──────────────────────── */
.tec-add-wrap { margin-top: 8px; }
.tec-add-wrap select { background-color: var(--surface2); border-style: dashed; color: var(--primary); font-weight: 600; }
.tec-hint { font-size: 11.5px; color: var(--text-light); margin-top: 6px; line-height: 1.4; }

/* ============================================================
   Relatório mensal
   ============================================================ */
.mensal-filtros {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end;
}
.mensal-filtros .btn-refresh { grid-column: 1 / -1; min-height: 48px; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 2px; overflow: hidden;
}
.kpi i {
  position: absolute; right: 14px; top: 14px; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 11px; background: var(--primary-muted); color: var(--primary); font-size: 14px;
}
.kpi b { font-size: 30px; font-weight: 800; letter-spacing: -1px; color: var(--text); line-height: 1.1; }
.kpi span { font-size: 12px; font-weight: 600; color: var(--text-muted); }

.tipo-lista { display: flex; flex-direction: column; gap: 12px; }
.tipo-linha { display: grid; grid-template-columns: minmax(90px, 34%) 1fr 36px; gap: 10px; align-items: center; font-size: 13px; }
.tipo-nome { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tipo-barra { height: 9px; background: var(--surface3); border-radius: 99px; overflow: hidden; }
.tipo-barra i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); }
.tipo-qtd { text-align: right; font-weight: 800; color: var(--text); }

.tabela-wrap { overflow-x: auto; margin: 0 -4px; }
.tabela-mensal { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabela-mensal th {
  text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text-muted);
  padding: 10px 12px; background: var(--surface2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tabela-mensal th:first-child { border-radius: 10px 0 0 10px; }
.tabela-mensal th:last-child  { border-radius: 0 10px 10px 0; }
.tabela-mensal td { padding: 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; }
.tabela-mensal tbody tr:last-child td { border-bottom: none; }
.tabela-mensal tbody tr:hover td { background: var(--surface2); }
.pill-tipo {
  display: inline-block; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--primary-muted); color: var(--primary); white-space: nowrap;
}

.mensal-acoes { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.mensal-acoes button { flex: 1 1 140px; min-height: 46px; }
.btn-export { background: var(--primary-muted); color: var(--primary); }
.btn-export:hover { background: var(--primary); color: #fff; }

.mensal-print-head { display: none; }

/* Tabela vira "cartões" no celular */
@media (max-width: 640px) {
  .tabela-mensal thead { display: none; }
  .tabela-mensal, .tabela-mensal tbody, .tabela-mensal tr, .tabela-mensal td { display: block; width: 100%; }
  .tabela-mensal tr {
    border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px; background: var(--surface2);
  }
  .tabela-mensal td { border: none !important; padding: 4px 0; display: flex; gap: 10px; justify-content: space-between; text-align: right; background: transparent !important; }
  .tabela-mensal td[data-l="#"] { display: none; }
  .tabela-mensal td::before { content: attr(data-l); font-weight: 600; color: var(--text-muted); text-align: left; flex-shrink: 0; }
}
@media (min-width: 721px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .mensal-filtros { grid-template-columns: 1fr 1fr auto; }
  .mensal-filtros .btn-refresh { grid-column: auto; }
}

/* ── Impressão / PDF do relatório mensal ───────────────── */
@media print {
  body::before { display: none; }
  body { background: #fff !important; }
  #app-header, .tab-nav, #app-drawer, #app-drawer-overlay, #offline-barra, #pwa-banner,
  .mensal-filtros, .mensal-acoes, .toast { display: none !important; }
  .tab-content:not(#tab-mensal) { display: none !important; }
  #tab-mensal .form-header { display: none; }
  .mensal-print-head { display: block; margin-bottom: 14px; }
  .mensal-print-head h2 { font-size: 20px; }
  .mensal-print-head p { color: #444; font-size: 13px; margin-top: 2px; }
  .card, .kpi { box-shadow: none !important; break-inside: avoid; }
  .tabela-mensal { font-size: 11.5px; }
  .tabela-mensal tr { break-inside: avoid; }
}
