/* =========================================
   Dashboard iFood — Sushi Rio Preto
   Tema: Branco e Azul (#1565C0 / #1976D2)
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  --blue-dark:   #1565C0;
  --blue-mid:    #1976D2;
  --blue-light:  #42A5F5;
  --blue-bg:     #E3F2FD;
  --white:       #FFFFFF;
  --gray-50:     #F8FAFC;
  --gray-100:    #F1F5F9;
  --gray-200:    #E2E8F0;
  --gray-500:    #64748B;
  --gray-700:    #334155;
  --gray-900:    #0F172A;
  --green:       #22C55E;
  --red:         #EF4444;
  --orange:      #F97316;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:   0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);
  --radius:      12px;
  --radius-sm:   8px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
}

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-mid) 100%);
  padding: 1rem;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  width: 72px;
  height: 72px;
  background: var(--blue-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.login-logo svg { color: var(--blue-dark); }

.login-card h1 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: .25rem;
}

.login-card .subtitle {
  font-size: .875rem;
  color: var(--gray-500);
  margin-bottom: 2rem;
}

.form-group { text-align: left; margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: .375rem;
}

.form-group input {
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .9375rem;
  font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}

.form-group input:focus {
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(25,118,210,.15);
}

.btn-primary {
  width: 100%;
  padding: .8125rem;
  background: var(--blue-mid);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.error-msg {
  background: #FEF2F2;
  color: var(--red);
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  padding: .625rem .875rem;
  font-size: .8125rem;
  margin-bottom: 1rem;
  display: none;
}

/* ── LAYOUT: TOPBAR + MAIN ── */
.app-layout { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--blue-dark);
  color: var(--white);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.topbar-left { display: flex; align-items: center; gap: .75rem; }

.topbar-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topbar-title {
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1.2;
}

.topbar-subtitle {
  font-size: .75rem;
  opacity: .75;
}

.btn-logout {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  color: var(--white);
  padding: .4375rem .875rem;
  border-radius: var(--radius-sm);
  font-size: .8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s;
  display: flex;
  align-items: center;
  gap: .375rem;
}

.btn-logout:hover { background: rgba(255,255,255,.25); }

/* ── MAIN CONTENT ── */
.main-content { padding: 1.5rem; flex: 1; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ── PERIOD SELECTOR ── */
.period-bar {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
}

.period-bar label { font-size: .8125rem; font-weight: 600; color: var(--gray-700); white-space: nowrap; }

.period-quick-btns { display: flex; gap: .5rem; flex-wrap: wrap; }

.btn-period {
  padding: .375rem .75rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 20px;
  background: var(--white);
  color: var(--gray-700);
  font-size: .8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all .2s;
}

.btn-period:hover { border-color: var(--blue-mid); color: var(--blue-mid); }
.btn-period.active { background: var(--blue-mid); border-color: var(--blue-mid); color: var(--white); font-weight: 600; }

.period-custom { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.period-custom input[type="date"] {
  padding: .375rem .625rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .8125rem;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
}

.period-custom input[type="date"]:focus { border-color: var(--blue-mid); }

.btn-apply {
  padding: .375rem .875rem;
  background: var(--blue-mid);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: .8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s;
}

.btn-apply:hover { background: var(--blue-dark); }

/* ── SECTION TITLE ── */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.section-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 1.125rem;
  background: var(--blue-mid);
  border-radius: 2px;
}

/* ── KPI CARDS ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--blue-mid);
  display: flex;
  flex-direction: column;
  gap: .25rem;
  position: relative;
  transition: box-shadow .2s;
}

.kpi-card:hover { box-shadow: var(--shadow-md); }

.kpi-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
  margin-top: .25rem;
}

.kpi-sub {
  font-size: .75rem;
  color: var(--gray-500);
  margin-top: .25rem;
}

.kpi-card .tooltip-icon {
  position: absolute;
  top: .875rem;
  right: .875rem;
  width: 18px;
  height: 18px;
  background: var(--blue-bg);
  color: var(--blue-mid);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  position: absolute;
}

/* ── GRID 2-COL ── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* ── SECTION CARD ── */
.section-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.section-card h3 {
  font-size: .875rem;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.section-card h3 .icon { font-size: 1rem; }

/* ── RATING ── */
.stars { color: #F59E0B; font-size: 1.25rem; letter-spacing: .1em; }
.rating-value { font-size: 2rem; font-weight: 700; color: var(--gray-900); }
.rating-count { font-size: .8125rem; color: var(--gray-500); }

/* ── PROGRESS BAR ── */
.progress-wrap { margin-top: .75rem; }
.progress-label { display: flex; justify-content: space-between; font-size: .8125rem; margin-bottom: .375rem; }
.progress-bar { height: 10px; background: var(--gray-100); border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--blue-mid); border-radius: 5px; transition: width .4s ease; }
.progress-fill.good { background: var(--green); }
.progress-fill.warn { background: var(--orange); }
.progress-fill.bad  { background: var(--red); }

/* ── FUNNEL ── */
.funnel-steps { display: flex; flex-direction: column; gap: .75rem; }

.funnel-step {
  position: relative;
}

.funnel-step-label { display: flex; justify-content: space-between; margin-bottom: .375rem; font-size: .8125rem; }
.funnel-step-name { font-weight: 600; color: var(--gray-700); }
.funnel-step-val  { color: var(--gray-500); }

.funnel-bar { height: 32px; background: var(--gray-100); border-radius: 6px; overflow: hidden; position: relative; }
.funnel-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-mid), var(--blue-light));
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding-left: .75rem;
  font-size: .75rem;
  font-weight: 600;
  color: white;
  transition: width .5s ease;
}

.funnel-conv { font-size: .75rem; color: var(--gray-500); margin-top: .25rem; text-align: right; }

/* ── CANCELLATION ORIGIN LIST ── */
.origin-list { display: flex; flex-direction: column; gap: .625rem; margin-top: .5rem; }
.origin-item { display: flex; align-items: center; gap: .625rem; }
.origin-badge {
  min-width: 90px;
  padding: .25rem .5rem;
  border-radius: 4px;
  font-size: .6875rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: .04em;
}

.badge-merchant  { background: #FEF3C7; color: #92400E; }
.badge-customer  { background: #DBEAFE; color: #1E40AF; }
.badge-logistics { background: #D1FAE5; color: #065F46; }
.badge-system    { background: #F3F4F6; color: #374151; }

.origin-bar-wrap { flex: 1; }
.origin-bar { height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.origin-bar-fill { height: 100%; border-radius: 4px; }
.fill-merchant  { background: #F59E0B; }
.fill-customer  { background: var(--blue-mid); }
.fill-logistics { background: var(--green); }
.fill-system    { background: var(--gray-500); }

.origin-count { font-size: .8125rem; font-weight: 600; color: var(--gray-700); min-width: 30px; text-align: right; }

/* ── TOP REASONS LIST ── */
.reason-list { display: flex; flex-direction: column; gap: .5rem; }
.reason-item { display: flex; justify-content: space-between; align-items: center; font-size: .8125rem; padding: .5rem .75rem; background: var(--gray-50); border-radius: 6px; }
.reason-name { color: var(--gray-700); flex: 1; margin-right: .5rem; }
.reason-count { font-weight: 700; color: var(--blue-mid); }

/* ── NPS DISTRIBUTION ── */
.nps-dist { display: flex; gap: .75rem; margin-top: .75rem; flex-wrap: wrap; }
.nps-bucket { flex: 1; min-width: 80px; text-align: center; padding: .875rem .5rem; border-radius: var(--radius-sm); }
.nps-bucket.promoter  { background: #D1FAE5; }
.nps-bucket.neutral   { background: #FEF3C7; }
.nps-bucket.detractor { background: #FEE2E2; }
.nps-bucket-val  { font-size: 1.5rem; font-weight: 700; }
.nps-bucket-pct  { font-size: .75rem; color: var(--gray-500); }
.nps-bucket-name { font-size: .75rem; font-weight: 600; margin-top: .25rem; }
.promoter  .nps-bucket-val { color: #065F46; }
.neutral   .nps-bucket-val { color: #92400E; }
.detractor .nps-bucket-val { color: #991B1B; }

/* ── MTP / DELTA CT ── */
.metric-pair { display: flex; gap: 1rem; flex-wrap: wrap; }
.metric-box {
  flex: 1;
  min-width: 120px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
}
.metric-box-val { font-size: 1.625rem; font-weight: 700; color: var(--gray-900); }
.metric-box-unit { font-size: .75rem; color: var(--gray-500); }
.metric-box-label { font-size: .8125rem; font-weight: 600; color: var(--gray-700); margin-top: .25rem; }

.classification-tag {
  display: inline-block;
  padding: .25rem .75rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  margin-top: .75rem;
}
.tag-high { background: #FEE2E2; color: #991B1B; }
.tag-ok   { background: #D1FAE5; color: #065F46; }
.tag-low  { background: #FEF3C7; color: #92400E; }

/* ── CHART CONTAINERS ── */
.chart-container { position: relative; height: 280px; }
.chart-container-sm { position: relative; height: 200px; }

/* ── LOADING SKELETON ── */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  background: rgba(255,255,255,.85);
  border-radius: var(--radius);
  z-index: 10;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue-mid);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.unavailable {
  text-align: center;
  color: var(--gray-500);
  padding: 2rem 1rem;
  font-size: .875rem;
}
.unavailable-icon { font-size: 2rem; margin-bottom: .5rem; }

/* ── ERROR BANNER ── */
.error-banner {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  display: none;
}
.error-banner.show { display: flex; }
.btn-retry {
  padding: .5rem 1rem;
  background: var(--red);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 600;
  font-size: .875rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn-retry:hover { background: #DC2626; }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .main-content { padding: 1rem .75rem; }
  .topbar { padding: 0 .875rem; }
  .topbar-title { font-size: .875rem; }
  .kpi-value { font-size: 1.5rem; }
  .period-bar { gap: .5rem; }
}
