/* ── Utilitário global ── */
.hidden { display: none !important; }

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--cream);
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Tela de login (cobre tudo) ── */
.screen {
  position: fixed;
  inset: 0;
  background: var(--cream);
  z-index: 100;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: var(--safe-top);
}

.screen.hidden { display: none; }

/* ── Shell do app ── */
.app-shell {
  position: fixed;
  inset: 0;
}

.app-shell.hidden { display: none; }

/* ── Páginas individuais ── */
.page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: calc(90px + var(--safe-bottom));   /* respiro p/ a tab bar flutuante */
  background: var(--app-bg);
}

.page.hidden { display: none; }

/* ── Cabeçalho da página ── */
.page-header {
  display: flex;
  align-items: center;
  padding: var(--sp-md) var(--sp-md) var(--sp-sm);
  gap: var(--sp-sm);
  min-height: 60px;
  flex-shrink: 0;
}

.page-header-left { flex: 1; }

.page-title {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--text-dark);
  flex: 1;
  letter-spacing: -0.4px;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

/* ── Barra de data / navegação (abaixo do header) ── */
.page-date-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--sp-md) var(--sp-sm);
  flex-shrink: 0;
  min-height: 32px;
}

.page-date-bar .page-subtitle {
  width: 100%;
}

/* ── Conteúdo rolável ── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--sp-md) var(--sp-lg);
  -webkit-overflow-scrolling: touch;
}

/* ── Tab bar ── */
.tab-bar {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 10px);
  left: 14px;
  right: 14px;
  max-width: 460px;
  margin: 0 auto;
  height: 64px;
  padding: 0 6px;
  background: rgba(220, 237, 224, 0.62);   /* vidro fosco c/ leve tom verde botânico */
  backdrop-filter: blur(26px) saturate(185%);
  -webkit-backdrop-filter: blur(26px) saturate(185%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 22px;
  box-shadow: 0 8px 26px rgba(27, 42, 74, 0.14), 0 2px 6px rgba(27, 42, 74, 0.06);
  display: flex;
  align-items: center;
  z-index: 50;
}

/* Tema Silvia preserva o tint creme morno */
[data-theme="silvia"] .tab-bar { background: rgba(245, 241, 234, 0.62); }

.tab-bar.hidden { display: none; }

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font);
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.tab-item.active { color: var(--gold); font-weight: 700; }

/* Ícone com pílula de fundo no item ativo (mesma linguagem dos chips) */
.tab-item svg {
  padding: 5px 12px;
  border-radius: 12px;
  box-sizing: content-box;
  transition: background 0.18s, color 0.18s;
}
.tab-item.active svg {
  background: var(--gold-pale);
  color: var(--gold-dark);
}

/* ── Barra de pesquisa ── */
.search-bar {
  padding: 0 var(--sp-md) var(--sp-sm);
  flex-shrink: 0;
}

/* ── Pílulas de abas (dentro de páginas) ── */
.tab-pills {
  display: flex;
  padding: 0 var(--sp-md) var(--sp-sm);
  gap: var(--sp-sm);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.tab-pills::-webkit-scrollbar { display: none; }

.tab-pill {
  padding: 6px 18px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: none;
  font-size: var(--text-sm);
  font-family: var(--font);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.tab-pill.active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--white);
  font-weight: 600;
}

/* ── Login ── */
.auth-screen {
  background:
    radial-gradient(ellipse 90% 60% at 12% 88%, rgba(144, 191, 153, 0.35) 0%, transparent 55%),
    radial-gradient(ellipse 70% 45% at 88% 12%, rgba(196, 168, 130, 0.28) 0%, transparent 52%),
    linear-gradient(155deg, #E8F2EA 0%, #F5F2EE 55%, #EDF5EF 100%);
}

.login-container {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-xl) var(--sp-lg);
  gap: var(--sp-lg);
}

.login-logo {
  text-align: center;
}

.login-logo img {
  max-width: 200px;
  height: auto;
  border-radius: 20px;
  box-shadow: 0 6px 24px rgba(79, 116, 85, 0.14);
}

/* Telas que usam só o símbolo (cadastro/análise) */
.login-logo-mark img {
  max-width: 96px;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(79, 116, 85, 0.14);
}

.login-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  background: var(--cream);
  border-radius: 24px;
  padding: var(--sp-xl) var(--sp-lg);
  box-shadow: 0 4px 24px rgba(79, 116, 85, 0.13);
  border: 1px solid rgba(144, 191, 153, 0.25);
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
}

/* Input com ícone interno + botão mostrar senha */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  width: 20px;
  height: 20px;
  color: var(--gold);
  pointer-events: none;
}

.input.input-iconed {
  padding-left: 46px;
}

.input.input-toggleable {
  padding-right: 46px;
}

.input-toggle {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}
.input-toggle svg { width: 20px; height: 20px; }
.input-toggle:active { opacity: 0.6; }

.login-forgot {
  text-align: center;
  color: var(--gold);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  margin-top: -4px;
}

.login-message {
  text-align: center;
  font-size: var(--text-sm);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--r-md);
  line-height: 1.5;
}
.login-message.success { background: var(--success-pale); color: var(--success); }
.login-message.error   { background: var(--danger-pale);  color: var(--danger); }

.login-switch {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-top: var(--sp-md);
}
.login-switch a {
  color: var(--gold);
  font-weight: 600;
  text-decoration: none;
}

/* ── Botão voltar ── */
.btn-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  color: var(--gold);
  cursor: pointer;
  border-radius: var(--r-sm);
  margin-left: -6px;
  flex-shrink: 0;
}

/* ── Navegação de mês ── */
.month-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

.month-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  min-width: 88px;
  text-align: center;
}

/* ── Cards de resumo ── */
.summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}

.summary-card {
  padding: var(--sp-md);
  border-radius: var(--r-lg);
}

.summary-card--gold {
  background: var(--gold-pale);
  border: 1.5px solid var(--gold-light);
}

.summary-card--lavender {
  background: var(--lavender-light);
  border: 1.5px solid var(--lavender);
}

.summary-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 4px;
}

.summary-value {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-dark);
}

/* ── Seções de formulário ── */
.form-section {
  background: var(--white);
  border-radius: var(--r-lg);
  padding: var(--sp-md);
  margin-bottom: var(--sp-md);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

.form-section-title {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.form-section-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: -8px;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  padding-bottom: var(--sp-xl);
}

/* ── Estado vazio ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-xl);
  gap: var(--sp-md);
  color: var(--text-muted);
  text-align: center;
  font-size: var(--text-sm);
  min-height: 200px;
}

/* ── Estado vazio com marca (símbolo esmaecido + frase acolhedora) ── */
.empty-state--brand { gap: 10px; }

.empty-mark {
  width: 64px;
  height: 64px;
  object-fit: contain;
  opacity: 0.16;            /* marca-d'água suave (gradiente do símbolo) */
  margin-bottom: 2px;
}

.empty-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--navy);
}

.empty-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 268px;
  line-height: 1.5;
}

.empty-state--brand .btn { margin-top: 6px; }

/* ── Info row (detalhe do paciente) ── */
.info-card {
  background: var(--white);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  padding: var(--sp-md);
  margin-bottom: var(--sp-md);
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: var(--sp-md);
}

.info-row:last-child { border-bottom: none; }

.info-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  flex-shrink: 0;
  padding-top: 1px;
}

.info-value {
  font-size: var(--text-sm);
  color: var(--text-dark);
  font-weight: 500;
  text-align: right;
  line-height: 1.4;
}

/* ── Indicador de salvamento ── */
.save-indicator {
  font-size: var(--text-xs);
  color: var(--text-muted);
  min-width: 55px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Skeleton loading ── */
.skeleton-card {
  height: 76px;
  background: linear-gradient(90deg, var(--gold-pale) 25%, var(--cream) 50%, var(--gold-pale) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Loader de marca: 3 pontos pulsando ── */
.brand-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 38px 0;
}
.brand-loader-dots {
  display: flex;
  flex-direction: row;
  gap: 9px;
  align-items: center;
}
.brand-loader-dots i {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: dotpulse 1.2s ease-in-out infinite;
}
.brand-loader-dots i:nth-child(1) { background: var(--gold-light); animation-delay: 0s;    }
.brand-loader-dots i:nth-child(2) { background: var(--gold);       animation-delay: 0.2s;  }
.brand-loader-dots i:nth-child(3) { background: var(--gold-dark);  animation-delay: 0.4s;  }

@keyframes dotpulse {
  0%, 100% { opacity: 0.25; transform: scale(0.65); }
  50%      { opacity: 1;    transform: scale(1); }
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(72px + var(--safe-bottom));
  left: var(--sp-md);
  right: var(--sp-md);
  background: var(--lavender-dark);
  color: #fff;
  padding: 12px var(--sp-md);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  text-align: center;
  z-index: 300;
  animation: fadeInUp 0.25s ease;
}

.toast.hidden { display: none; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Bottom sheet (pagamentos, etc.) ── */
.bottom-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
}

.bottom-sheet.hidden { display: none; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(44, 31, 14, 0.45);
  animation: fadeIn 0.2s ease;
}

.sheet-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--sp-md) var(--sp-md) calc(var(--sp-xl) + var(--safe-bottom));
  max-height: 88vh;
  overflow-y: auto;
  animation: slideUp 0.28s ease;
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto var(--sp-md);
}

.sheet-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: var(--sp-md);
  text-align: center;
  letter-spacing: -0.2px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0.6; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── WhatsApp card ── */
.whatsapp-preview {
  background: #e7fdb9;
  border-radius: var(--r-md);
  padding: var(--sp-md);
  font-size: var(--text-sm);
  line-height: 1.6;
  color: #1a1a1a;
  white-space: pre-wrap;
  border: 1px solid #c8e89a;
  margin-bottom: var(--sp-md);
  font-family: -apple-system, sans-serif;
}
