/* ============================================================
   App Saúde - Tema Saúde (Soft Colors)
   Controle de Peso, Glicose e Tirzepatida
   ============================================================ */

:root {
  /* Paleta Saúde - Soft */
  --primary: #4CAF50;
  --primary-light: #E8F5E9;
  --primary-dark: #388E3C;
  --accent: #C8E6C9;
  --secondary: #26A69A;
  --bg: #F5F9F6;
  --surface: #FFFFFF;
  --text: #2E3B2E;
  --text-muted: #6B7A6B;
  --border: #DCE8DC;
  --danger: #E53935;
  --warning: #FB8C00;
  --ok: #43A047;
  --shadow: 0 4px 16px rgba(76, 175, 80, 0.12);
  --shadow-lg: 0 8px 30px rgba(76, 175, 80, 0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 250px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-dark); text-decoration: none; }
img { max-width: 100%; }

/* ============================================================
   Botões
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: center;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(76, 175, 80, 0.4); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-outline {
  background: transparent;
  color: var(--primary-dark);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-block { width: 100%; }
.btn-small { padding: 8px 14px; font-size: 0.875rem; }
.btn-large { padding: 16px 32px; font-size: 1.1rem; }
.btn-icon { padding: 10px; background: transparent; font-size: 1.25rem; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  border: 1px solid var(--border);
}
.card h3 { margin-bottom: 16px; color: var(--primary-dark); font-size: 1.1rem; }
.card-desc { color: var(--text-muted); margin-bottom: 16px; }

/* ============================================================
   Formulários
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
}
.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--accent);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
textarea.form-input { resize: vertical; }
.form-hint { margin-top: 12px; font-size: 0.85rem; color: var(--text-muted); text-align: center; }
.form-hint a { font-weight: 600; }
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-weight: 500;
}
.checkbox-label input { width: 18px; height: 18px; accent-color: var(--primary); }
.hidden { display: none !important; }

/* ============================================================
   Landing Page
   ============================================================ */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.header { padding: 24px 0; }
.logo { font-size: 1.5rem; font-weight: 700; color: var(--primary-dark); }
.subtitle { color: var(--text-muted); }

.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: center;
  padding: 60px 0;
}
.hero-text h2 { font-size: 2.5rem; font-weight: 700; margin-bottom: 16px; color: var(--text); }
.hero-text p { font-size: 1.15rem; color: var(--text-muted); margin-bottom: 28px; }
.hero-buttons { display: flex; gap: 12px; flex-wrap: wrap; }

.hero-card {
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  gap: 16px;
  box-shadow: var(--shadow-lg);
}
.card-item {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "icon label" "icon value";
  align-items: center;
  gap: 4px 16px;
}
.card-icon { grid-area: icon; font-size: 1.8rem; }
.card-label { grid-area: label; color: var(--text-muted); font-size: 0.85rem; }
.card-value { grid-area: value; font-weight: 700; font-size: 1.5rem; color: var(--primary-dark); }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  padding: 40px 0;
}
.feature-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform 0.25s;
}
.feature-card:hover { transform: translateY(-4px); }
.feature-icon { font-size: 2rem; margin-bottom: 12px; }
.feature-card h3 { color: var(--primary-dark); margin-bottom: 8px; }
.feature-card p { color: var(--text-muted); font-size: 0.95rem; }

.cta {
  text-align: center;
  padding: 60px 0;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  border-radius: var(--radius);
  margin: 40px 0;
}
.cta h2 { font-size: 1.8rem; margin-bottom: 8px; color: var(--text); }
.cta p { color: var(--text-muted); margin-bottom: 24px; }

.footer { text-align: center; padding: 24px 0; color: var(--text-muted); font-size: 0.875rem; }

/* ============================================================
   App Shell (sidebar + main)
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  padding: 24px 16px;
  z-index: 50;
}
.sidebar-header { margin-bottom: 28px; padding: 0 8px; }
.sidebar-menu { list-style: none; flex: 1; }
.sidebar-menu li { margin-bottom: 4px; }
.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.sidebar-menu a:hover { background: var(--primary-light); color: var(--primary-dark); }
.sidebar-menu a.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.nav-icon { font-size: 1.2rem; }
.sidebar-footer { padding-top: 16px; border-top: 1px solid var(--border); }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 0 32px 32px;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 40;
}
.topbar h1 { font-size: 1.5rem; flex: 1; color: var(--text); }
.user-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.875rem;
}
.menu-toggle { display: none; }

.content { max-width: 1100px; }

/* ============================================================
   Dashboard
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.metric-card { padding: 24px; }
.metric-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.metric-header h3 { margin: 0; font-size: 0.95rem; }
.metric-icon { font-size: 1.4rem; }
.metric-value { font-size: 2rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 4px; }
.metric-sub { color: var(--text-muted); font-size: 0.875rem; }

.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-card canvas { width: 100% !important; }

/* ============================================================
   Tabelas
   ============================================================ */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.data-table th { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.data-table tr:hover td { background: #FBFDFB; }

/* ============================================================
   Auth Page
   ============================================================ */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-container { width: 100%; max-width: 440px; }
.auth-card { padding: 36px; }
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-logo { font-size: 3rem; display: block; margin-bottom: 8px; }
.auth-header h1 { font-size: 1.6rem; color: var(--primary-dark); }
.auth-header p { color: var(--text-muted); }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 24px; }
.tab-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}
.tab-btn.active { background: var(--primary-light); color: var(--primary-dark); box-shadow: inset 0 0 0 2px var(--primary); }
.auth-footer { margin-top: 20px; font-size: 0.8rem; color: var(--text-muted); text-align: center; }

/* ============================================================
   Info / Badges / Doses
   ============================================================ */
.info-card { margin-top: 20px; }
.ref-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.ref-item { padding: 12px; border-radius: var(--radius-sm); border-left: 4px solid var(--border); }
.ref-item.normal { border-left-color: var(--ok); background: #E8F5E9; }
.ref-item.pre { border-left-color: var(--warning); background: #FFF3E0; }
.ref-item.alto { border-left-color: var(--danger); background: #FFEBEE; }
.ref-item strong { display: block; margin: 4px 0; }

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-ok { background: #C8E6C9; color: #1B5E20; }
.badge-warn { background: #FFE0B2; color: #E65100; }
.badge-danger { background: #FFCDD2; color: #B71C1C; }
.badge-free { background: var(--primary-light); color: var(--primary-dark); }

.dose-grid { display: grid; gap: 8px; }
.dose-item {
  padding: 12px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  color: var(--primary-dark);
}

.profile-row { display: flex; align-items: center; gap: 16px; }
.profile-avatar {
  width: 56px; height: 56px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
}
.profile-nome { font-weight: 600; }
.profile-username { color: var(--text-muted); }

.plan-box { padding: 16px; background: var(--bg); border-radius: var(--radius-sm); }
.plan-box p { margin: 12px 0; color: var(--text-muted); }

.code-block {
  background: #f6f8f6;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
  overflow-x: auto;
}
.code-block code { font-size: 0.85rem; color: var(--primary-dark); }

.form-card, .table-card, .chart-card { margin-bottom: 24px; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: #fff;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { background: var(--ok); }
.toast.error { background: var(--danger); }

/* ============================================================
   Responsivo
   ============================================================ */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 0 20px 24px; }
  .menu-toggle { display: inline-flex; }
  .charts-grid { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; text-align: center; }
  .hero-buttons { justify-content: center; }
  .hero-card { max-width: 320px; margin: 0 auto; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .card { padding: 20px; }
  .hero-text h2 { font-size: 1.8rem; }
  .metric-value { font-size: 1.6rem; }
  .topbar h1 { font-size: 1.2rem; }
}