/* ==========================================================================
   Kronos Fit - camada visual "premium"
   Carrega DEPOIS do style.css e so refina a aparencia (tipografia, campos, cartoes, tabelas, botoes,
   menu). Nao muda estrutura nem comportamento. A cor da marca (azul-ciano) e as cores de apoio
   continuam exatamente as de sempre - tudo aqui le as mesmas variaveis (--primary, --surface...).
   Pra desfazer o visual novo: e so remover o <link> deste arquivo (e do fonts.css) do index.html.
   ========================================================================== */

:root {
  --font: 'Geist Variable', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Bricolage Grotesque Variable', 'Geist Variable', system-ui, sans-serif;
  --font-mono: 'Geist Mono Variable', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  --radius-sm: 9px;
  --radius: 12px;
  --radius-lg: 18px;

  /* Sombras em camadas: um fio de luz no topo + uma sombra longa e suave embaixo (profundidade sem pesar). */
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.035) inset, 0 14px 34px -22px rgba(0, 0, 0, 0.85);
  --shadow-pop: 0 28px 64px -24px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--border);
  --ring: 0 0 0 4px var(--primary-subtle);
  --field-bg: var(--input-bg);
  --field-bg-hover: var(--input-bg);
}
:root[data-theme="light"] {
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 1px 2px rgba(15, 23, 42, 0.05), 0 14px 30px -22px rgba(15, 23, 42, 0.22);
  --shadow-pop: 0 28px 60px -24px rgba(15, 23, 42, 0.28), 0 0 0 1px var(--border);
}

/* ---------- Tipografia ---------- */
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body { font-family: var(--font); font-feature-settings: 'ss01', 'cv11'; letter-spacing: -0.003em; }
button, input, select, textarea { font-family: inherit; }

h1, h2, h3,
.topbar h1,
.page-title-row h2,
.modal-title,
.card-title,
.auth-card h2 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}
.page-title-row h2 { font-size: 1.45rem; font-weight: 700; margin-bottom: 4px; }
.page-title-row p { font-size: 0.86rem; }
.topbar h1 { font-size: 1.05rem; font-weight: 700; }
.card-title { font-size: 1rem; font-weight: 700; }
.modal-title { font-size: 1.18rem; font-weight: 700; }

/* Rotulos pequenos em caixa alta ("eyebrow") e numeros tecnicos usam a fonte mono: da a cara de painel. */
thead th,
.kpi-card .kpi-label,
.dash-mini-stat-label,
.dash-kpi-sub {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.kpi-card .kpi-value,
.dash-mini-stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.kpi-card .kpi-value { font-size: 1.85rem; line-height: 1.1; }
.dash-mini-stat-value { font-size: 1.45rem; }
td, .badge, .days-chip, .lista-contador strong { font-variant-numeric: tabular-nums; }

/* ---------- Campos de texto ---------- */
.form-group { gap: 7px; }
.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  color: var(--text-secondary);
}
.form-control,
.modal .form-control,
.auth-card .form-control {
  min-height: 44px;
  padding: 11px 14px;
  background-color: var(--field-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.025) inset;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
.form-control:hover { border-color: color-mix(in srgb, var(--primary) 38%, var(--input-border)); }
.form-control:focus,
.modal .form-control:focus,
.auth-card .form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring), 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.85; }
.form-control:disabled, .form-control[readonly] { opacity: 0.62; cursor: not-allowed; }
textarea.form-control { min-height: 96px; padding-top: 12px; resize: vertical; line-height: 1.5; }
.form-control:user-invalid { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-subtle); }
input[type="number"].form-control { -moz-appearance: textfield; appearance: textfield; font-variant-numeric: tabular-nums; }
input[type="number"].form-control::-webkit-outer-spin-button,
input[type="number"].form-control::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.form-hint { font-size: 0.74rem; color: var(--text-muted); line-height: 1.45; }

/* Caixa de selecao (a lista que abre e a do proprio sistema - ver premium-select.js) */
select.form-control { cursor: pointer; padding-right: 38px; background-position: right 13px center; background-size: 16px; }

/* Interruptor */
.toggle-switch .toggle-slider { transition: background-color .18s ease; }

/* ---------- Cartoes ---------- */
.card {
  border-radius: var(--radius-lg);
  border-color: var(--card-border);
  padding: 22px 24px;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.022), transparent 120px);
  box-shadow: var(--shadow-card);
}
:root[data-theme="light"] .card { background-image: none; }
.kpi-card {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, 0.03), transparent 55%);
  transition: transform .18s ease, border-color .18s ease;
}
.kpi-card:hover { border-color: color-mix(in srgb, var(--primary) 30%, var(--card-border)); }
:root[data-theme="light"] .kpi-card { background-image: none; }
.kpi-card .kpi-icon { border-radius: 10px; width: 32px; height: 32px; }

/* ---------- Botoes ---------- */
.btn {
  min-height: 40px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  letter-spacing: -0.005em;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .12s ease, filter .16s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { min-height: 32px; padding: 6px 13px; font-size: 0.78rem; border-radius: 8px; }
.btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 92%, white), var(--primary));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28) inset, 0 8px 22px -10px var(--primary);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 92%, white), var(--primary)); }
.btn-success { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 8px 20px -12px var(--success); }
.btn-danger { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 8px 20px -12px var(--danger); }
.btn-outline { background: color-mix(in srgb, var(--surface) 60%, transparent); border-color: var(--input-border); }
.btn-outline:hover:not(:disabled) { background: var(--primary-subtle); border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); color: var(--text); }
.btn-icon { border-radius: 9px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.form-control:focus-visible { outline: none; }

/* ---------- Tabelas ---------- */
table { font-size: 0.875rem; }
thead th { padding: 12px 14px; background: transparent; color: var(--text-muted); border-bottom: 1px solid var(--border); }
thead th:first-child, thead th:last-child { border-radius: 0; }
tbody td { padding: 14px; border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
tbody tr { transition: background-color .12s ease; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--table-row-hover); }
.aluno-nome-link { font-weight: 600; letter-spacing: -0.01em; }

/* ---------- Selos / abas ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 99px;
  font-family: var(--font-mono); font-size: 0.64rem; font-weight: 600; letter-spacing: 0.07em;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.tab-btn {
  border-radius: 11px; padding: 10px 20px; font-weight: 600;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  transition: background-color .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.tab-btn:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.tab-btn.active { box-shadow: 0 10px 24px -12px var(--primary); }

/* ---------- Menu lateral e barra superior ---------- */
.sidebar { padding: 20px 14px; }
.sidebar-nav { gap: 3px; }
.nav-item {
  position: relative;
  padding: 10px 13px;
  border-radius: 11px;
  border-left: none;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background-color .15s ease, color .15s ease;
}
.nav-item svg { width: 18px; height: 18px; opacity: 0.85; stroke-width: 1.9; }
.nav-item:hover { background: color-mix(in srgb, var(--sidebar-active-text) 7%, transparent); }
.nav-item.active {
  font-weight: 600;
  background: linear-gradient(90deg, var(--sidebar-active-bg), transparent 92%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sidebar-active-border) 22%, transparent);
}
.nav-item.active::before {
  content: ''; position: absolute; left: -14px; top: 22%; bottom: 22%; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--sidebar-active-border); box-shadow: 0 0 14px var(--sidebar-active-border);
}
.nav-item.active svg { opacity: 1; }
.sidebar-footer { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.05em; }
.topbar { backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); background: color-mix(in srgb, var(--topbar-bg) 82%, transparent); }
.page-content { padding: 28px 32px 40px; }

/* ---------- Janelas (modais) ---------- */
.modal-overlay { backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.modal {
  border-radius: 22px;
  box-shadow: var(--shadow-pop);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 140px);
}
:root[data-theme="light"] .modal { background-image: none; }
.modal-footer { margin-top: 24px; padding-top: 18px; }
.modal-close { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; }

/* ---------- Barra de rolagem: discreta (so destaca ao passar o mouse) ---------- */
* { scrollbar-color: color-mix(in srgb, var(--text-muted) 55%, transparent) transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-muted) 45%, transparent); }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ---------- Lista de opcoes do sistema (substitui a lista cinza do navegador) ---------- */
.ps-pop {
  position: fixed; z-index: 1400; display: flex; flex-direction: column;
  min-width: 180px; max-width: min(92vw, 460px);
  background: var(--modal-bg); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-pop); overflow: hidden;
  animation: ps-in .14s ease-out;
}
@keyframes ps-in { from { opacity: 0; transform: translateY(-4px) scale(0.985); } to { opacity: 1; transform: none; } }
.ps-search { margin: 8px 8px 4px; }
.ps-search input {
  width: 100%; min-height: 38px; padding: 8px 12px; border-radius: 9px; font-size: 0.86rem;
  background: var(--input-bg); border: 1px solid var(--input-border); color: var(--text);
}
.ps-search input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.ps-list { overflow-y: auto; padding: 6px; max-height: 300px; overscroll-behavior: contain; }
.ps-group { padding: 10px 10px 4px; font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); }
.ps-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 9px; font-size: 0.875rem; color: var(--text);
  cursor: pointer; user-select: none; line-height: 1.3;
}
.ps-opt.is-active { background: var(--primary-subtle); }
.ps-opt.is-selected { color: var(--primary-light); font-weight: 600; }
:root[data-theme="light"] .ps-opt.is-selected { color: var(--primary); }
.ps-opt.is-disabled { opacity: 0.4; cursor: not-allowed; }
.ps-opt .ps-check { width: 16px; height: 16px; flex: none; opacity: 0; color: var(--primary); }
.ps-opt.is-selected .ps-check { opacity: 1; }
.ps-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: 0.84rem; }
.ps-scrim { display: none; }

/* ---------- Celular ---------- */
@media (max-width: 720px) {
  .page-content { padding: 20px 16px 32px; }
  .page-title-row h2 { font-size: 1.3rem; }
  .card { padding: 18px 16px; border-radius: 16px; }
  /* 16px nos campos: abaixo disso o iPhone aumenta a tela sozinho ao tocar no campo. */
  .form-control, .modal .form-control, .ps-search input { font-size: 16px; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .modal { border-radius: 20px; padding: 22px 18px; }

  /* A lista de opcoes vira uma "gaveta" que sobe de baixo da tela - mais facil de tocar com o polegar. */
  .ps-scrim { display: block; position: fixed; inset: 0; z-index: 1399; background: var(--modal-overlay); animation: ps-fade .16s ease-out; }
  .ps-pop {
    left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important;
    width: 100% !important; max-width: none; border-radius: 22px 22px 0 0; border-bottom: none;
    animation: ps-up .2s ease-out;
  }
  .ps-pop::before { content: ''; align-self: center; width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 10px 0 4px; }
  .ps-list { max-height: 52vh; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .ps-opt { padding: 14px 14px; font-size: 1rem; }
}
@keyframes ps-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ps-fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .ps-pop, .ps-scrim { animation: none; }
  .btn, .form-control, .nav-item, .kpi-card { transition: none; }
}

/* Celular: formularios em UMA coluna (duas colunas deixavam campos espremidos e de larguras diferentes). */
.form-grid > *, .endereco-grid > * { min-width: 0; }
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; gap: 4px; }
  .endereco-grid .eg-cep, .endereco-grid .eg-rua, .endereco-grid .eg-bairro { grid-column: span 12; }
  .endereco-grid .eg-num { grid-column: span 5; }
  .endereco-grid .eg-comp { grid-column: span 7; }
  .endereco-grid .eg-cidade { grid-column: span 8; }
  .endereco-grid .eg-uf { grid-column: span 4; }
}

/* Coluna de acoes das tabelas (PDF / Renovar / Editar / lixeira): ocupa so o que precisa e nao quebra de linha. */
tbody td:has(> .btn-sm), tbody td:has(> div > .btn-sm), tbody td:has(> .btn-icon), tbody td:has(> div > .btn-icon) { width: 1%; white-space: nowrap; }
tbody td > div:has(> .btn-sm) { flex-wrap: nowrap !important; }
