/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ── Variables ────────────────────────────────────────────── */
:root {
  --teal:        #8B1A2B;
  --teal-light:  #F7E9EB;
  --teal-dark:   #6E1322;
  --teal-glow:   rgba(139,26,43,.15);
  --slate-50:    #F8FAFC;
  --slate-100:   #F1F5F9;
  --slate-200:   #E2E8F0;
  --slate-400:   #94A3B8;
  --slate-500:   #64748B;
  --slate-700:   #334155;
  --slate-800:   #1E293B;
  --slate-900:   #0F172A;
  --white:       #FFFFFF;
  --red:         #EF4444;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 16px rgba(0,0,0,.07), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.10), 0 4px 12px rgba(0,0,0,.05);
  --radius:      14px;
  --radius-sm:   8px;
  --transition:  .2s cubic-bezier(.4,0,.2,1);
}


body.dark #darkToggle {
  border-color: #475569;
  color: #94a3b8;
}

body.dark #darkToggle:hover {
  border-color: #8B1A2B;
  color: #8B1A2B;
}

/* ── Dark Mode ────────────────────────────────────────────── */
body.dark {
  --slate-50:  #0f172a;
  --slate-100: #1e293b;
  --slate-200: #334155;
  --slate-300: #475569;
  --slate-400: #94a3b8;
  --slate-500: #cbd5e1;
  --slate-600: #e2e8f0;
  --slate-700: #f1f5f9;
  --slate-800: #f8fafc;
  --white:     #1e293b;
  --red:       #f87171;
  background:  #0f172a;
  color:       #e2e8f0;
}

/* Cards */
body.dark .chart-card,
body.dark .kpi-card,
body.dark .login-card {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* Formulários */
body.dark .form-input,
body.dark .form-input:focus,
body.dark select.form-input,
body.dark textarea.form-input {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark .form-input::placeholder {
  color: #475569;
}

/* Header */
body.dark .header {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* Nav */
body.dark .nav-tabs {
  border-color: #334155;
}

body.dark .nav-tab {
  color: #94a3b8;
}

body.dark .nav-tab:hover {
  color: #e2e8f0;
}

body.dark .nav-tab.active {
  color: #8B1A2B;
  border-color: #8B1A2B;
}

/* KPI */
body.dark .kpi-value {
  color: #f1f5f9;
}

body.dark .kpi-label {
  color: #94a3b8;
}

/* Seletores */
body.dark .estab-select,
body.dark .periodo-select,
body.dark select {
  background: #1e293b;
  border-color: #475569;
  color: #e2e8f0;
}

/* Tabelas */
body.dark table thead tr {
  background: #1e293b;
}

body.dark table th {
  color: #94a3b8;
  border-color: #334155;
}

body.dark table td {
  border-color: #1e293b;
  color: #cbd5e1;
}

body.dark table tbody tr:hover {
  background: rgba(139,26,43,0.06);
}

/* Botão primário */
body.dark .btn-primary {
  background: #8B1A2B;
  color: white;
}

/* Logout */
body.dark .btn-logout {
  border-color: #334155;
  color: #94a3b8;
}

body.dark .btn-logout:hover {
  background: #334155;
  color: #e2e8f0;
}

/* Badges status */
body.dark .badge-green,
body.dark .badge-status.badge-green  { background: #064e3b; color: #6ee7b7; }
body.dark .badge-yellow,
body.dark .badge-status.badge-yellow { background: #78350f; color: #fcd34d; }
body.dark .badge-red,
body.dark .badge-status.badge-red    { background: #7f1d1d; color: #fca5a5; }
body.dark .badge-gray,
body.dark .badge-status.badge-gray   { background: #1e293b; color: #94a3b8; }

/* Preview prompt */
body.dark #previewBox {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

/* Empty state */
body.dark .empty-state {
  color: #475569;
}

/* Error banner */
body.dark .error-banner {
  background: #7f1d1d;
  color: #fca5a5;
  border-color: #991b1b;
}

/* Chart area */
body.dark .chart-wrap {
  background: transparent;
}

/* Clinic selector label */
body.dark .estab-selector-label {
  color: #64748b;
}

/* Period badge */
body.dark .period-badge,
body.dark .periodo-badge {
  background: rgba(139,26,43,0.15);
  color: #8B1A2B;
}

/* Section titles */
body.dark .chart-title,
body.dark .section-title {
  color: #f1f5f9;
}

body.dark .chart-subtitle {
  color: #64748b;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: 'DM Sans', sans-serif;
  color: var(--slate-800);
  background: var(--slate-50);
  line-height: 1.6;
  overflow-x: hidden;
  max-width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%,  rgba(139,26,43,.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%,  rgba(139,26,43,.06) 0%, transparent 60%),
    var(--slate-50);
  position: relative;
  overflow: hidden;
}

/* Subtle grid overlay */
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--slate-200) 1px, transparent 1px),
    linear-gradient(90deg, var(--slate-200) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: .35;
  pointer-events: none;
}

.login-card {
  background: var(--white);
  border-radius: 20px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,.04);
  padding: 48px 44px 44px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: cardReveal .5s cubic-bezier(.22,1,.36,1) both;
}

@keyframes cardReveal {
  from { opacity:0; transform: translateY(20px) scale(.98); }
  to   { opacity:1; transform: translateY(0)    scale(1); }
}

/* Teal accent bar */
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 44px; right: 44px;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), #D4A760);
  border-radius: 0 0 4px 4px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-logo-mark {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--teal), #D4A760);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(139,26,43,.3);
}

.login-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.login-logo-text .brand {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--slate-800);
  letter-spacing: -.3px;
}

.login-logo-text .tagline {
  font-size: 11px;
  font-weight: 500;
  color: var(--slate-400);
  letter-spacing: .5px;
  text-transform: uppercase;
}

.login-heading {
  font-family: 'Outfit', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -.4px;
  margin-bottom: 6px;
}

.login-sub {
  font-size: 14px;
  color: var(--slate-500);
  margin-bottom: 32px;
}

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
  letter-spacing: .1px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--slate-50);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14.5px;
  color: var(--slate-800);
  transition: var(--transition);
  outline: none;
}

.form-input::placeholder { color: var(--slate-400); }

.form-input:focus {
  border-color: var(--teal);
  background: var(--white);
  box-shadow: 0 0 0 3px var(--teal-glow);
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(139,26,43,.3);
  letter-spacing: .1px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(139,26,43,.4);
}
.btn-primary:active { transform: translateY(0); }

.btn-primary:disabled {
  opacity: .65;
  cursor: not-allowed;
  transform: none;
}

.error-msg {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--red);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
  display: none;
}
.error-msg.show { display: block; animation: fadeIn .2s ease; }

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

.login-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 12px;
  color: var(--slate-400);
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 20px;
  background: var(--white);
  border: 1.5px solid var(--slate-200);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--slate-700);
  text-decoration: none;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, background .2s;
  margin-bottom: 6px;
}
.btn-google:hover {
  border-color: #4285F4;
  box-shadow: 0 2px 8px rgba(66,133,244,0.15);
  background: #F8FBFF;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--slate-400);
  font-size: 12px;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--slate-200);
}
.login-divider span { white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════
   DASHBOARD PAGE
═══════════════════════════════════════════════════════════ */
.dashboard-page {
  min-height: 100vh;
  background: var(--slate-100);
}

/* ── Header ─────────────────────────────────────────────── */
.header {
  height: 64px;
  background: var(--white);
  border-bottom: 1px solid var(--slate-100);
  position: sticky;
  top: 0;
  z-index: 100;
  overflow-x: hidden;
  max-width: 100vw;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

.header-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 64px;
}

.header-row-sub {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
  width: 100%;
}

.header-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.header-logo svg {
  display: block;
  height: 36px;
  width: auto;
}

.header-logo-mark {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--teal), #D4A760);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(139,26,43,.25);
}

.header-brand {
  font-family: 'Outfit', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--slate-800);
  letter-spacing: -.3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Desktop: linha 1 e linha 2 ficam na mesma row */
@media (min-width: 641px) {
  .header-inner {
    flex-direction: row;
    align-items: stretch;
    min-height: 64px;
  }
  .header-row-main {
    flex: 1;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
  }
  .header-row-sub {
    flex: 0 0 auto;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 0;
    border-top: none;
    height: 64px;
    gap: 16px;
  }
  .btn-logout span { display: inline; }
  .header-estab { display: block; }
  .header-right { display: flex; align-items: center; gap: 16px; }
}

.header-estab {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-estab-name {
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--slate-800);
  line-height: 1.2;
}

#headerEstabLogo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
  background: white;
  padding: 2px;
  border: 1px solid var(--slate-200);
  display: none;
}

.header-estab-label {
  font-size: 11px;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ── Clinic selector (admin) ─────────────────────────────── */
.estab-selector {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.estab-selector-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.estab-select {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  background: var(--slate-50);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 6px 28px 6px 10px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: var(--transition);
  min-width: 180px;
  max-width: 100%;
  box-sizing: border-box;
}

.estab-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-glow);
}

/* Admin badge */
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, var(--teal), #D4A760);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .4px;
  text-transform: uppercase;
  margin-left: 6px;
  vertical-align: middle;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-500);
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover {
  border-color: var(--red);
  color: var(--red);
  background: #FEF2F2;
}

/* ── Main Content ────────────────────────────────────────── */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 28px 48px;
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  margin-bottom: 28px;
  animation: slideUp .4s cubic-bezier(.22,1,.36,1) both;
}

.page-title {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -.5px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--slate-400);
  margin-top: 3px;
}

.period-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--teal-light);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  margin-top: 10px;
  letter-spacing: .2px;
}

/* ── Período selector ────────────────────────────────────── */
.periodo-selector {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
  margin-left: 8px;
}

.periodo-select {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #8B1A2B;
  background: #F7E9EB;
  border: none;
  border-radius: 20px;
  padding: 4px 28px 4px 12px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238B1A2B' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-color: #F7E9EB;
}

.charts-grid--full {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

/* ── KPI Cards ───────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--slate-200);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  animation: slideUp .4s cubic-bezier(.22,1,.36,1) both;
}

.kpi-card:nth-child(1) { animation-delay: .05s; }
.kpi-card:nth-child(2) { animation-delay: .10s; }
.kpi-card:nth-child(3) { animation-delay: .15s; }
.kpi-card:nth-child(4) { animation-delay: .20s; }

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Teal accent corner */
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), #D4A760);
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0;
  transition: var(--transition);
}
.kpi-card:hover::after { opacity: 1; }

.kpi-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.kpi-icon {
  width: 36px;
  height: 36px;
  background: var(--teal-light);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  flex-shrink: 0;
}

.kpi-value {
  font-family: 'Outfit', sans-serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--slate-900);
  line-height: 1;
  letter-spacing: -1px;
  margin-bottom: 6px;
}

.kpi-value.currency::before {
  content: 'R$ ';
  font-size: 16px;
  font-weight: 500;
  color: var(--slate-500);
  vertical-align: top;
  line-height: 2;
  letter-spacing: 0;
}

.kpi-value.hours::after {
  content: 'h';
  font-size: 16px;
  font-weight: 500;
  color: var(--slate-500);
  vertical-align: bottom;
  line-height: 1.8;
}

.kpi-meta {
  font-size: 12px;
  color: var(--slate-400);
}

/* ── Charts ──────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 16px;
  animation: slideUp .4s cubic-bezier(.22,1,.36,1) .3s both;
}

.chart-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--slate-200);
}

.chart-title {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--slate-800);
  margin-bottom: 4px;
  letter-spacing: -.2px;
}

.chart-subtitle {
  font-size: 12px;
  color: var(--slate-400);
  margin-bottom: 20px;
}

.chart-wrap {
  position: relative;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--slate-400);
  font-size: 13px;
  gap: 8px;
}

/* ── Loading skeleton ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-200) 50%, var(--slate-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}

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

/* ── Error banner ────────────────────────────────────────── */
.error-banner {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--red);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 24px;
  display: none;
}
.error-banner.show { display: block; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes slideUp {
  from { opacity:0; transform: translateY(16px); }
  to   { opacity:1; transform: translateY(0); }
}

/* ── Section label ───────────────────────────────────────── */
.section-label {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin: 28px 0 12px;
}

/* ── Follow-up status cards ──────────────────────────────── */
.followup-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}

.fu-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 16px 16px;
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  border-top: 3px solid transparent;
  text-align: center;
}
.fu-aguardando  { border-top-color: #94A3B8; }
.fu-t1          { border-top-color: #F59E0B; }
.fu-t2          { border-top-color: #F97316; }
.fu-responderam { border-top-color: #10B981; }
.fu-esgotados   { border-top-color: #EF4444; }

.fu-value {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--slate-800);
  line-height: 1;
  margin-bottom: 6px;
}
.fu-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ── Agents table ─────────────────────────────────────────── */
.agents-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.agents-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--slate-200);
}
.agents-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--slate-100);
  color: var(--slate-700);
  vertical-align: middle;
}
.agents-table tr:last-child td { border-bottom: none; }
.agents-table tr:hover td { background: var(--slate-50); }

.agent-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--teal-light);
  color: var(--teal);
  font-size: 10px;
  font-weight: 700;
  margin-right: 8px;
  vertical-align: middle;
  flex-shrink: 0;
}

.badge-resolved {
  background: #D1FAE5;
  color: #065F46;
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 4px;
}
.badge-pct {
  font-size: 11px;
  color: var(--slate-400);
}

/* Procedimentos chart wrap height */
.procedimentos-wrap { height: 220px; }

/* Agents table: sem height fixo — cresce com o conteúdo */
.agents-wrap { height: auto !important; }

/* Heatmap card: overflow visível para o scroll horizontal funcionar */
.heatmap-card { overflow: visible; }

/* ── Heatmap mobile/desktop visibility ───────────────────── */
#heatmapMobile { display: none; }   /* hidden on desktop */

/* ── Peak list (mobile heatmap substituto) ───────────────── */
.peak-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.peak-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.peak-rank {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--slate-400);
  width: 16px;
  text-align: right;
  flex-shrink: 0;
}
.peak-icon {
  display: flex;
  align-items: center;
  color: var(--teal);
  flex-shrink: 0;
}
.peak-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-700);
  flex-shrink: 0;
  min-width: 120px;
}
.peak-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--slate-100);
  border-radius: 99px;
  overflow: hidden;
}
.peak-bar {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), #D4A760);
  border-radius: 99px;
  transition: width .4s ease;
}
.peak-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-500);
  flex-shrink: 0;
  min-width: 48px;
  text-align: right;
}
body.dark .peak-label { color: #cbd5e1; }
body.dark .peak-bar-wrap { background: #334155; }

/* ── Heatmap ──────────────────────────────────────────────── */
.heatmap-wrap {
  overflow-x: auto;
  padding-bottom: 4px;
}
.heatmap-hours-row, .hm-day-col {
  display: flex;
  align-items: center;
  gap: 3px;
}
.heatmap-hours-row { margin-bottom: 3px; }
.hm-day-label {
  width: 32px;
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-400);
  text-align: right;
  padding-right: 6px;
  flex-shrink: 0;
}
.hm-hour-label {
  width: 26px;
  font-size: 10px;
  color: var(--slate-400);
  text-align: center;
  flex-shrink: 0;
}
.hm-cell {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  flex-shrink: 0;
  cursor: default;
  transition: transform .1s;
}
.hm-cell:hover { transform: scale(1.15); z-index: 1; position: relative; }

/* Dark mode for new components */
body.dark .fu-card,
body.dark .agents-table th,
body.dark .agents-table td { border-color: #334155; }
body.dark .fu-card { background: #1e293b; }
body.dark .fu-value { color: #f1f5f9; }
body.dark .agents-table tr:hover td { background: #1e293b; }
body.dark .agents-table td { color: #cbd5e1; }
body.dark .badge-resolved { background: rgba(16,185,129,.15); color: #34d399; }

/* ── Responsive ──────────────────────────────────────────── */

/* Tablet (640–1024px): KPIs 2×2, gráficos lado a lado */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile (< 640px) */
@media (max-width: 640px) {
  /* Header: logo + sair na linha 1, dropdown na linha 2 */
  .header { height: auto; }

  .header-inner {
    flex-wrap: wrap;
    height: auto;
    min-height: 56px;
    padding: 0 16px;
    gap: 0;
    align-items: center;
  }

  .header-logo {
    flex: 1;
    padding: 10px 0;
  }

  .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  /* Dropdown vai para linha 2, ocupando 100% */
  .estab-selector {
    flex: 0 0 100% !important;
    width: 100% !important;
    order: 99;
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #f1f5f9;
    padding: 8px 0 10px;
    margin: 0;
    box-sizing: border-box;
  }

  .estab-select {
    flex: 1;
    min-width: 0;
    max-width: 100%;
  }

  .estab-selector-label {
    white-space: nowrap;
    font-size: 11px;
    flex-shrink: 0;
  }

  /* Esconde nome da clínica e texto do sair */
  .header-estab { display: flex !important; }
  .logout-text { display: none; }
  .btn-logout { padding: 8px; }

  /* Conteúdo (valores já definidos no breakpoint 768px acima) */
  .chart-wrap { height: 220px; }
  .login-card { padding: 36px 24px 32px; }
  .login-card::before { left: 24px; right: 24px; }

  /* 1. Follow-up cards: 2 colunas no mobile */
  .followup-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .fu-card { padding: 14px 12px 12px; }
  .fu-value { font-size: 22px; }

  /* 2. Heatmap: ocultar grid, mostrar peak list no mobile */
  #heatmapWrap { display: none; }
  #heatmapMobile { display: block; }

  /* 3. Procedimentos: chart menor no mobile */
  .procedimentos-wrap { height: 180px; }

  /* 4. Tabela atendentes: esconder Tempo Médio, avatar compacto */
  .agents-table th:last-child,
  .agents-table td:last-child { display: none; }
  .agents-table { font-size: 12px; }
  .agents-table td, .agents-table th { padding: 8px 6px; }
  .agent-avatar { width: 22px; height: 22px; font-size: 9px; margin-right: 5px; }

  /* 5. Espaçamentos menores */
  .section-label { margin: 18px 0 10px; }
  .charts-grid { gap: 12px; }
  .charts-grid--full { gap: 12px; margin-top: 12px; }
  .chart-card { padding: 16px; }
  .chart-subtitle { margin-bottom: 14px; }
}

/* ═══════════════════════════════════════════════════════════
   NAV TABS
═══════════════════════════════════════════════════════════ */
.nav-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border-bottom: 2px solid var(--slate-200);
  overflow: hidden;
}

.nav-tab {
  text-decoration: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--slate-500);
  padding: 10px 20px;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-tab:hover { color: var(--teal); }

.nav-tab.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   CLINICA FORM FEEDBACK
═══════════════════════════════════════════════════════════ */
.form-feedback {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
  animation: fadeIn .2s ease;
}

.feedback-ok {
  background: #F0FDF4;
  border: 1px solid #86EFAC;
  color: #166534;
}

.feedback-err {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--red);
}

/* ── KPI icon variants ───────────────────────────────────── */
.kpi-icon--green  { background: #F0FDF4; color: #16A34A; }
.kpi-icon--blue   { background: #EFF6FF; color: #2563EB; }
.kpi-icon--teal   { background: var(--teal-light); color: var(--teal); }
.kpi-icon--amber  { background: #FFFBEB; color: #D97706; }

.kpi-desc { font-size: 12px; color: var(--slate-400); margin-top: 4px; }

.chart-header { margin-bottom: 0; }

/* ═══════════════════════════════════════════════════════════
   APP LAYOUT — SIDEBAR
═══════════════════════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--slate-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 200;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

.sidebar-logo {
  padding: 18px 14px 14px;
  border-bottom: 1px solid var(--slate-100);
  flex-shrink: 0;
}

.sidebar-logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--slate-500);
  text-decoration: none;
  transition: background .12s ease, color .12s ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  line-height: 1;
  white-space: nowrap;
}

.sidebar-item:hover {
  background: var(--slate-50);
  color: var(--slate-700);
}

.sidebar-item.active {
  background: var(--teal-light);
  color: var(--teal);
  font-weight: 600;
}

.sidebar-item svg { flex-shrink: 0; opacity: .7; }
.sidebar-item.active svg { opacity: 1; }

.sidebar-separator {
  height: 1px;
  background: var(--slate-200);
  margin: 6px 8px;
}

.sidebar-footer {
  padding: 8px;
  flex-shrink: 0;
  border-top: 1px solid var(--slate-100);
}

.sidebar-logout-btn:hover {
  color: var(--red) !important;
  background: #fef2f2 !important;
}

.app-content {
  flex: 1;
  margin-left: 220px;
  min-width: 0;
  max-width: calc(100% - 220px);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Header overrides inside sidebar layout */
.app-content .header {
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  overflow: hidden;
}

.app-content .header-inner {
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: none;
  margin: 0;
}

.header-center {
  flex: 1;
  display: flex;
  align-items: center;
}

/* Hamburger / sidebar toggle */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--slate-500);
  transition: var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: var(--slate-100);
  color: var(--slate-700);
}

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 199;
  backdrop-filter: blur(1px);
}
.sidebar-overlay.show { display: block; }

/* ── Dark mode — sidebar ─────────────────────────────────── */
body.dark .sidebar {
  background: #1e293b;
  border-color: #334155;
}
body.dark .sidebar-logo { border-color: #334155; }
body.dark .sidebar-footer { border-color: #334155; }
body.dark .sidebar-item:hover { background: #334155; color: #e2e8f0; }
body.dark .sidebar-item.active { background: rgba(139,26,43,.15); color: #8B1A2B; }
body.dark .sidebar-separator { background: #334155; }
body.dark .sidebar-logout-btn:hover { background: rgba(239,68,68,.12) !important; }
body.dark .app-content .header { background: #1e293b; border-color: #334155; }
body.dark .sidebar-toggle:hover { background: #334155; color: #e2e8f0; }

/* ── Mobile (≤768px) ─────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-220px); }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }
  .app-content {
    margin-left: 0;
    max-width: 100%;
    width: 100%;
    overflow-x: hidden;
  }
  .sidebar-toggle { display: flex; }

  /* Layout principal no mobile */
  .main {
    padding: 16px;
    width: 100%;
    max-width: 100%;
  }

  /* KPI grid: 2 colunas, sem overflow */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 100%;
  }
  .kpi-card { padding: 14px 14px 12px; }
  .kpi-value { font-size: 1.75rem; }

  /* Charts */
  .charts-grid, .charts-grid--full { grid-template-columns: 1fr; }
  .chart-card { padding: 16px; }

  /* Page header no mobile */
  .page-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 20px;
  }
  .periodo-selector { margin-left: 0; margin-top: 0; }
  .page-title { font-size: 22px; }

  /* Header */
  .app-content .header-inner { padding: 0 12px; gap: 8px; }
  #headerEstabLogo { display: block !important; width: 32px; height: 32px; }
  .header-estab-name { font-size: 14px; }
  #userName { display: none; }
}
