/* ============================================================
   NEFROVIDA — style-dashboard.css (Dashboard Clínico)
   Padronizado + responsivo para celular
   ============================================================ */

/* ── Variáveis ── */
:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --surface2: #f1f5f9;
  --border: rgba(0, 0, 0, 0.08);

  --primary: #2b9fd8;
  --primary-dim: rgba(43,159,216,0.12);
  --primary-hover: #1d88be;
  --secondary: #249689;
  --roxo: #4B39EF;
  --hidratacao: #C4E8F7;

  --success: #249689;
  --warning: #d97706;
  --error: #e53e3e;
  --error-strong: #c53030;

  --blue: var(--primary);
  --blue-dim: var(--primary-dim);
  --cyan: var(--secondary);
  --green: var(--success);
  --orange: var(--warning);
  --red: var(--error);

  --text: #1e293b;
  --muted: #64748b;
  --muted2: #475569;
  --accent: var(--roxo);

  /* sidebar escura (valores fixos, não usam as vars acima) */
  --sb-bg: #0f172a;
  --sb-surface: #1e293b;
  --sb-border: rgba(255,255,255,0.07);
  --sb-text: #f1f5f9;
  --sb-muted: #94a3b8;

  /* ── Botões padronizados ── */
  --btn-h:       48px;
  --btn-h-sm:    40px;
  --btn-px:      1.5rem;
  --btn-px-sm:   1rem;
  --btn-radius:  8px;
  --btn-font:    0.88rem;
  --btn-font-sm: 0.8rem;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  display: flex;
  overflow: hidden;
  height: 100vh;
}
/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: 240px;
  height: 100vh;
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  z-index: 200;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--sb-border);
}

.logo-text {
  font-family: 'Pacifico', cursive;
  font-size: 1.6rem;
  color: var(--sb-text);
  letter-spacing: -0.5px;
  line-height: 1;
}
.logo-text span { color: var(--primary); }

.logo-sub {
  font-size: 0.7rem;
  color: var(--sb-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-section {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--sb-muted);
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--sb-muted);
  transition: all 0.15s;
  border: 1px solid transparent;
  min-height: 44px;
}

.nav-item:hover { background: var(--sb-surface); color: var(--sb-text); }
.nav-item.active {
  background: var(--blue-dim);
  color: var(--primary);
  border-color: rgba(43,159,216,0.2);
}

.nav-icon { font-size: 1rem; width: 18px; text-align: center; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--sb-border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--sb-surface);
  border-radius: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 600;
  flex-shrink: 0;
}

.user-name { font-size: 0.8rem; font-weight: 500; color: var(--sb-text); }
.user-role { font-size: 0.7rem; color: var(--sb-muted); }

/* ============================================================
   BOTÕES PADRONIZADOS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--btn-h-sm);
  padding: 0 var(--btn-px-sm);
  border-radius: var(--btn-radius);
  border: none;
  font-size: var(--btn-font);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'DM Sans', sans-serif;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--blue);
  color: white;
  height: var(--btn-h-sm);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--muted2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

/* Ghost dentro da sidebar fica escuro */
.sidebar .btn-ghost {
  color: var(--sb-muted);
  border-color: var(--sb-border);
}
.sidebar .btn-ghost:hover { background: var(--sb-surface); color: var(--sb-text); }

.btn-full {
  width: 100%;
  height: var(--btn-h);
  font-size: var(--btn-font);
}

/* Botão voltar ao site — no footer da sidebar */
.btn-back-site {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 40px;
  margin-top: 8px;
  border-radius: var(--btn-radius);
  font-size: 0.8rem;
  color: var(--sb-muted);
  border: 1px solid var(--sb-border);
  background: transparent;
  text-decoration: none;
  transition: all 0.15s;
  font-family: 'DM Sans', sans-serif;
}
.btn-back-site:hover {
  background: var(--sb-surface);
  color: var(--sb-text);
}

/* ============================================================
   MENU HAMBURGUER (mobile)
   ============================================================ */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px; height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 10px;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 100%; height: 2px;
  background: var(--muted2);
  border-radius: 2px;
  transition: all 0.2s;
}

/* Overlay escuro quando sidebar abre em mobile */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ============================================================
   MAIN
   ============================================================ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0; /* evita overflow em flex */
}

/* ── TOPBAR ── */
.topbar {
  height: 60px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--surface);
  flex-shrink: 0;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.topbar-title {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  font-weight: 300;
  color: var(--text);
  white-space: nowrap;
}

.topbar-actions { display: flex; gap: 10px; align-items: center; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 0.82rem;
  color: var(--muted2);
  cursor: pointer;
  min-width: 200px;
}

/* ── CONTENT ── */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  height: calc(100vh - 60px);
  scroll-behavior: smooth;
}
/* VIEWS */
.view { display: none; }
.view.active { display: block; min-height: 100%; }

/* ============================================================
   STATS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-color, var(--blue));
}

.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 10px;
}

.stat-value {
  font-family: 'Fraunces', serif;
  font-size: 2rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--muted2);
  margin-top: 6px;
}

.stat-icon {
  position: absolute;
  top: 16px; right: 16px;
  font-size: 1.4rem;
  opacity: 0.4;
}

/* ── GRID 2 / 3 COLUNAS ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* ── CARD ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 8px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted2);
}

.card-action {
  font-size: 0.75rem;
  color: var(--blue);
  cursor: pointer;
  white-space: nowrap;
}

/* ── PATIENT LIST ── */
.patient-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  min-height: 56px;
}

.patient-item:hover {
  background: var(--surface2);
  border-color: var(--border);
}

.patient-item.selected {
  background: var(--blue-dim);
  border-color: rgba(59,130,246,0.25);
}

.patient-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 600;
  flex-shrink: 0;
  color: white;
}

.patient-name { font-size: 0.88rem; font-weight: 500; }

.patient-info {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 500;
}

.badge-green { background: rgba(36,150,137,0.15); color: var(--success); }
.badge-orange { background: rgba(249,207,88,0.18); color: var(--warning); border: 1px solid rgba(249,207,88,0.25); }
.badge-red {
  background: rgba(255,89,99,0.15);
  color: var(--error);
  border: 1px solid rgba(255,89,99,0.35);
  font-weight: 600;
}
.badge-blue { background: rgba(96,191,238,0.15); color: var(--primary); }

/* ── TABELA ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 500px; /* evita quebra estranha em mobile */
}

th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted2);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #e8f0f8; color: var(--text); cursor: pointer; }

/* ── MED LIST ── */
.med-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.med-item:last-child { border-bottom: none; }

.med-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.med-name { font-size: 0.85rem; font-weight: 500; flex: 1; }
.med-dose { font-size: 0.75rem; color: var(--muted); }

/* ── DIALISE RECORD ── */
.dial-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.dial-row:last-child { border-bottom: none; }
.dial-key { color: var(--muted); }
.dial-val { font-weight: 500; font-family: 'DM Mono', monospace; font-size: 0.8rem; }

/* ── LOADING ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--muted);
  font-size: 0.85rem;
  gap: 10px;
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── LOGIN ── */
#login-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-text { font-size: 1.8rem; color: #1e293b; }
.login-logo .logo-sub { color: #475569; }

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.88rem;
  color: var(--text);
  outline: none;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.15s;
  /* Área de toque confortável */
  min-height: 44px;
}

.form-input:focus { border-color: var(--blue); }

.login-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--red);
  margin-bottom: 16px;
  display: none;
}

/* ── PATIENT DETAIL ── */
.detail-hero {
  background: var(--sb-bg);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid rgba(255,255,255,0.06);
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-wrap: wrap;
}

.detail-hero .detail-name { color: var(--sb-text); }
.detail-hero .detail-meta { color: var(--sb-muted); }
.detail-hero .detail-avatar {
  background: linear-gradient(135deg, var(--accent), var(--primary));
}

.hero-metric {
  background: rgba(255,255,255,0.04) !important;
  border: 1px solid rgba(255,255,255,0.07) !important;
}
.hero-metric .metric-val { color: var(--sb-text); }
.hero-metric .metric-label { color: var(--sb-muted); }

.detail-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 600; color: white;
  flex-shrink: 0;
}

.detail-name {
  font-family: 'Fraunces', serif;
  font-size: 1.4rem;
  font-weight: 300;
}

.detail-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.82rem; color: var(--muted2);
  cursor: pointer; background: none; border: none;
  font-family: 'DM Sans', sans-serif;
  padding: 8px 0;
  min-height: 40px;
}
.back-btn:hover { color: var(--text); }

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface2);
  border-radius: 10px;
  padding: 4px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.tab {
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted2);
  transition: all 0.15s;
  border: none;
  background: none;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
  min-height: 36px;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── METRICS ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--surface2);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.metric-val {
  font-family: 'DM Mono', monospace;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
}

.metric-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 0.85rem;
}

.pulse { animation: pulse 2s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── CHART BOX ── */
.chart-box {
  background: var(--surface2);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}
.chart-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.chart-legend {
  display: flex;
  gap: 14px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.chart-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--muted2);
}
.chart-legend i {
  width: 12px; height: 3px;
  border-radius: 2px;
  display: inline-block;
}

/* ============================================================
   RESPONSIVO — MOBILE
   ============================================================ */

/* Tablet: ≤ 900px */
@media (max-width: 900px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Celular: ≤ 640px */
@media (max-width: 640px) {
  /* Body deixa de ser flex fixo para scroll natural */
  body {
    flex-direction: column;
    overflow: auto;
    height: auto;
  }

  /* Sidebar some da tela — desliza da esquerda */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
    height: 100vh;
    height: 100dvh; /* dynamic viewport height */
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* Hamburger aparece */
  .hamburger { display: flex; }

  /* Main ocupa tela toda e permite scroll */
  .main {
    overflow: visible;
    height: auto;
    min-height: 100dvh;
  }

  /* Topbar */
  .topbar {
    padding: 0 16px;
    position: sticky; top: 0; z-index: 100;
  }
  .topbar-title { font-size: 0.95rem; }

  /* Search box some em telas muito pequenas */
  .topbar-actions .search-box { display: none; }

  /* Content */
  .content {
    padding: 16px;
    height: auto;
    overflow: visible;
  }

  /* Stats — 1 coluna em tela pequena */
  .stats-grid { grid-template-columns: 1fr; }

  /* Metric grid — 2 colunas em vez de 3 */
  .metric-grid { grid-template-columns: 1fr 1fr; }

  /* Login box */
  .login-box { padding: 28px 20px; }

  /* Stat card */
  .stat-value { font-size: 1.6rem; }

  /* Tabs — scroll horizontal */
  .tabs { width: 100%; overflow-x: auto; }

  /* Botão voltar ao site — texto menor */
  .btn-back-site { font-size: 0.75rem; }
}

/* Muito pequeno: ≤ 380px */
@media (max-width: 380px) {
  .metric-grid { grid-template-columns: 1fr; }
  .login-box { padding: 24px 16px; }
  .topbar { padding: 0 12px; }
  .content { padding: 12px; }
}
