/* =====================================================
   Plantão Familiar — estilos gerais
   Paleta: verde-sálvia (turno atual), ardósia (próximos),
   índigo suave (informação), coral (alertas).
   Mobile-first: os familiares usam isso no corredor do hospital.
   ===================================================== */

:root {
  --bg: #F6F7F5;
  --bg-card: #FFFFFF;
  --ink: #2B2E33;
  --ink-soft: #6B7280;
  --line: #E4E7E4;

  --sage: #3F7D6E;
  --sage-bg: #E7F1EC;
  --slate: #8A97A0;
  --slate-bg: #EEF1F2;
  --indigo: #4A5FBF;
  --indigo-bg: #ECEEFA;
  --amber: #D79A34;
  --amber-bg: #FBF1DE;
  --coral: #D6553F;
  --coral-bg: #FBEAE6;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(43,46,51,0.04), 0 6px 20px rgba(43,46,51,0.06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 { margin: 0 0 4px 0; font-weight: 700; letter-spacing: -0.01em; }

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

/* ---------- Layout com menu lateral (páginas logadas) ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--line);
}
.brand-icon { font-size: 22px; }
.brand-name { font-weight: 800; font-size: 15px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sidebar-nav a {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 14.5px;
  font-weight: 600;
}
.sidebar-nav a:hover { background: var(--bg); color: var(--ink); }
.sidebar-nav a.active { background: var(--sage-bg); color: var(--sage); }

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--line);
}
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--sage); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-name { font-size: 13.5px; font-weight: 700; }
.user-role { font-size: 12px; color: var(--ink-soft); }
.btn-logout {
  display: block; text-align: center;
  padding: 8px; border-radius: var(--radius-sm);
  background: var(--bg); font-size: 13px; font-weight: 700;
  color: var(--coral);
}
.btn-logout:hover { background: var(--coral-bg); }

.mobile-menu-btn {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 50;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--bg-card); border: 1px solid var(--line);
  font-size: 18px; box-shadow: var(--shadow);
}

.main-content {
  flex: 1;
  padding: 24px 28px 60px;
  min-width: 0;
}

/* ---------- Cards genéricos ---------- */

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; }
.page-header .subtitle { color: var(--ink-soft); font-size: 14px; margin-top: 2px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- Estatísticas do dashboard ---------- */

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.stat-label { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.stat-value.sage { color: var(--sage); }
.stat-value.coral { color: var(--coral); }
.stat-value.indigo { color: var(--indigo); }

/* ---------- Botões ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700; font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary { background: var(--sage); color: #fff; }
.btn-primary:hover { background: #356a5e; }
.btn-secondary { background: var(--bg); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: #ececea; }
.btn-danger { background: var(--coral-bg); color: var(--coral); }
.btn-danger:hover { background: #f5d9d3; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Formulários ---------- */

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 6px; color: var(--ink);
}
.form-control {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--ink);
}
.form-control:focus { outline: 2px solid var(--indigo); outline-offset: 1px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }
.radio-group { display: flex; gap: 16px; align-items: center; }
.radio-group label { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }

/* ---------- Tabelas ---------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--bg-card); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 12px 16px; font-size: 12.5px; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--ink-soft); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFAF9; }

/* ---------- Badges/tags ---------- */

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 100px;
  font-size: 12.5px; font-weight: 700;
}
.tag-sage { background: var(--sage-bg); color: var(--sage); }
.tag-coral { background: var(--coral-bg); color: var(--coral); }
.tag-amber { background: var(--amber-bg); color: var(--amber); }
.tag-slate { background: var(--slate-bg); color: var(--slate); }
.tag-indigo { background: var(--indigo-bg); color: var(--indigo); }

/* ---------- Alertas ---------- */

.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; margin-bottom: 16px; }
.alert-error { background: var(--coral-bg); color: var(--coral); }
.alert-success { background: var(--sage-bg); color: var(--sage); }

/* ---------- Responsivo do menu ---------- */

@media (max-width: 860px) {
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh; z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding: 70px 16px 40px; }
}

/* =====================================================
   PÁGINA PÚBLICA (o "placar" do plantão — sem login)
   ===================================================== */

.public-page {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  min-height: 100vh;
}

.public-header {
  text-align: center;
  padding: 12px 0 20px;
}
.public-header .eyebrow {
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-soft);
}
.public-header h1 { font-size: 22px; margin-top: 4px; }
.public-header .hospital { color: var(--ink-soft); font-size: 14px; margin-top: 2px; }

.now-card {
  background: var(--bg-card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 24px 22px;
  text-align: center;
  border: 2px solid var(--sage-bg);
}
.now-card.state-warn { border-color: var(--amber-bg); }
.now-card.state-alert { border-color: var(--coral-bg); }
.now-card.state-empty { border-color: var(--line); }

.now-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--sage); margin-bottom: 12px;
}
.now-badge .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--sage);
  animation: pulse 1.6s infinite;
}
.state-warn .now-badge, .state-warn .now-badge .dot { color: var(--amber); background: var(--amber); }
.state-alert .now-badge, .state-alert .now-badge .dot { color: var(--coral); background: var(--coral); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(63,125,110,0.4); }
  70% { box-shadow: 0 0 0 8px rgba(63,125,110,0); }
  100% { box-shadow: 0 0 0 0 rgba(63,125,110,0); }
}

.now-name { font-size: 26px; font-weight: 800; margin-bottom: 2px; }
.now-turno { color: var(--ink-soft); font-size: 14px; margin-bottom: 18px; }

.progress-track {
  width: 100%; height: 14px; border-radius: 100px;
  background: var(--sage-bg);
  overflow: hidden;
  margin-bottom: 10px;
}
.progress-fill {
  height: 100%; border-radius: 100px;
  background: var(--sage);
  transition: width 1s linear;
}
.state-warn .progress-track { background: var(--amber-bg); }
.state-warn .progress-fill { background: var(--amber); }
.state-alert .progress-track { background: var(--coral-bg); }
.state-alert .progress-fill { background: var(--coral); }

.progress-labels {
  display: flex; justify-content: space-between;
  font-size: 12.5px; color: var(--ink-soft); font-weight: 600;
  margin-bottom: 4px;
}
.time-remaining { font-size: 15px; font-weight: 700; }
.time-remaining span { color: var(--sage); }
.state-warn .time-remaining span { color: var(--amber); }
.state-alert .time-remaining span { color: var(--coral); }

.upcoming-list { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.upcoming-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-card); border-radius: var(--radius-sm);
  padding: 12px 16px; box-shadow: var(--shadow);
}
.upcoming-item .label { font-size: 11.5px; font-weight: 800; text-transform: uppercase; color: var(--ink-soft); letter-spacing: 0.04em; }
.upcoming-item .who { font-weight: 700; font-size: 15px; margin-top: 2px; }
.upcoming-item .when { color: var(--ink-soft); font-size: 13px; text-align: right; }

.today-timeline { margin-top: 24px; }
.today-timeline h3 { font-size: 14px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 800; margin-bottom: 10px; }
.timeline-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.timeline-row:last-child { border-bottom: none; }
.timeline-row .check { width: 20px; text-align: center; }
.timeline-row.done { color: var(--ink-soft); }
.timeline-row.active { font-weight: 700; color: var(--sage); }

.empty-state {
  text-align: center; padding: 40px 20px; color: var(--ink-soft);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }

.day-nav {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-card); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 8px 6px; margin-bottom: 12px;
}
.day-nav-arrow {
  width: 40px; height: 40px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: var(--ink-soft);
  border-radius: 50%;
}
.day-nav-arrow:hover { background: var(--bg); color: var(--sage); }
.day-nav-label { text-align: center; }
.day-nav-title { font-weight: 800; font-size: 15.5px; }
.day-nav-date { font-size: 12.5px; color: var(--ink-soft); margin-top: 1px; }

/* ---------- Login ---------- */

.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--bg) 0%, var(--sage-bg) 100%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--bg-card); border-radius: 20px; box-shadow: var(--shadow);
  padding: 32px 28px;
}
.login-card .logo { font-size: 34px; text-align: center; margin-bottom: 8px; }
.login-card h1 { text-align: center; font-size: 20px; }
.login-card .subtitle { text-align: center; color: var(--ink-soft); font-size: 13.5px; margin-bottom: 24px; }
.login-footer-link { text-align: center; margin-top: 16px; font-size: 13.5px; color: var(--ink-soft); }

/* ---------- Impressão / Geração de PDF (despesas_publico.php) ---------- */

.print-header { text-align: center; margin-bottom: 20px; }
.print-header h1 { font-size: 20px; margin-bottom: 4px; }
.print-subtitle { font-size: 13px; color: var(--ink-soft); }

@media print {
  .no-print { display: none !important; }
  .print-header { display: block !important; }
  body { background: #fff; }
  .public-page { max-width: 100%; padding: 0; }
  .stat-card, .card, .table-wrap { box-shadow: none; border: 1px solid var(--line); }
  table { font-size: 12.5px; }
  thead th { background: #f4f4f2; }
  @page { margin: 16mm; }
}