/* ── 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(64px + var(--safe-bottom));
  background: var(--cream);
}

.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: 700;
  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: 0;
  left: 0;
  right: 0;
  height: calc(60px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(250, 247, 242, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  padding-top: 6px;
  z-index: 50;
}

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

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  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); }

.tab-item svg { transition: transform 0.15s; }
.tab-item.active svg { transform: scale(1.08); }

/* ── 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 ── */
/* Telas de autenticação: fundo "ondas" Alveo (sempre tema neutro) */
.auth-screen {
  background: #F2F6FC url("../assets/loginbg.jpg") no-repeat center center;
  background-size: cover;
}

.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-xl);
}

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

.login-logo img {
  max-width: 300px;
  height: auto;
}

/* Telas que usam só o símbolo (cadastro/análise) */
.login-logo-mark img {
  max-width: 96px;
}

.login-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

.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;
  background: rgba(255, 255, 255, 0.85);
}

.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;
}

/* ── 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(--border) 25%, var(--cream) 50%, var(--border) 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; }
}

/* ── 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;
}
