/* ── 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:        #0EA5A0;
  --teal-light:  #E0F7F6;
  --teal-dark:   #0B8A86;
  --teal-glow:   rgba(14,165,160,.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);
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'DM Sans', sans-serif;
  color: var(--slate-800);
  background: var(--slate-50);
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════
   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(14,165,160,.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%,  rgba(14,165,160,.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), #34D399);
  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), #0DD6CF);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(14,165,160,.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(14,165,160,.3);
  letter-spacing: .1px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(14,165,160,.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);
}

/* ═══════════════════════════════════════════════════════════
   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), #0DD6CF);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(14,165,160,.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-clinic { display: block; }
  .header-right { display: flex; align-items: center; gap: 16px; }
}

.header-clinic {
  text-align: right;
}

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

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

/* ── Clinic selector (admin) ─────────────────────────────── */
.clinic-selector {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

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

.clinic-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), #0DD6CF);
  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: #0EA5A0;
  background: #E0F7F6;
  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='%230EA5A0' 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: #E0F7F6;
}

.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), #34D399);
  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); }
}

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

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

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

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

  /* Conteúdo */
  .main { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .kpi-value { font-size: 2rem; }
  .charts-grid, .charts-grid--full { grid-template-columns: 1fr; }
  .chart-wrap { height: 260px; }
  .login-card { padding: 36px 24px 32px; }
  .login-card::before { left: 24px; right: 24px; }
}
