/*
 * 360 Haircare Reporting — Shared Design System
 *
 * Extracted from reports/templates/report.html patterns.
 * All pages in frontend/ import this file.
 * The ads report (reports/templates/report.html) keeps its own inline styles
 * for backwards compatibility but follows the same variables and conventions.
 */

/* ── CSS Variables ── */
:root {
  --brand-dark: #0a1628;
  --up:         #198754;
  --down:       #dc3545;
  --neu:        #6c757d;
  --bg:         #f0f2f5;
  --card-bg:    #ffffff;
  --border:     #e9ecef;
  --muted:      #6c757d;
}

/* ── Base ── */
body {
  background: var(--bg);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  overflow-x: hidden;
  margin: 0;
}
.page-shell {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}
.page-shell.narrow {
  max-width: 900px;
  padding-top: 48px;
  padding-bottom: 48px;
}
.page-header { margin-bottom: 24px; }
.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--brand-dark);
  margin: 0;
}
.page-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 0;
}
.page-subtitle.centered {
  max-width: 420px;
  margin: 12px auto 0;
  font-size: 14px;
}

/* ── Navigation bar ── */
.site-nav {
  background: var(--brand-dark);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 0;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
}
.site-nav .nav-brand {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  margin-right: 24px;
  white-space: nowrap;
  letter-spacing: .3px;
}
.site-nav .nav-links {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 100%;
}
.site-nav .nav-link {
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.site-nav .nav-link:hover {
  color: #fff;
}
.site-nav .nav-link.active {
  color: #fff;
  border-bottom-color: #4da6ff;
}

/* ── Date picker bar ── */
.picker-bar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  position: sticky;
  top: 48px; /* offset below nav */
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.picker-brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.picker-bar .brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--brand-dark);
  margin-right: 4px;
}
.picker-controls { display: contents; }
.mobile-filter-toggle {
  display: none;
  margin-left: auto;
  border: 1px solid #dee2e6;
  background: var(--card-bg);
  color: var(--brand-dark);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
}

/* ── Date range trigger (Agoda-style) ── */
.date-range-trigger {
  display: flex;
  align-items: stretch;
  border: 1.5px solid #dee2e6;
  border-radius: 10px;
  cursor: pointer;
  overflow: visible;
  position: relative;
  transition: border-color .15s, box-shadow .15s;
  background: var(--card-bg);
  min-width: 280px;
}
#pickerAnchor {
  position: absolute;
  bottom: 0; left: 0;
  width: 0; height: 0;
  opacity: 0; pointer-events: none;
  border: none; padding: 0;
}
.date-range-trigger:hover { border-color: #adb5bd; }
.date-range-trigger.is-open { border-color: #0d6efd; box-shadow: 0 0 0 3px rgba(13,110,253,.12); }
.date-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  flex: 1;
}
.date-field + .date-field { border-left: 1.5px solid #dee2e6; }
.date-range-trigger.is-open .date-field.active-field { background: #f0f5ff; }
.cal-icon { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.date-field-texts { display: flex; flex-direction: column; line-height: 1.2; }
.date-field-label { font-size: 10px; color: #9ca3af; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.date-field-value { font-size: 13px; font-weight: 600; color: var(--brand-dark); margin-top: 1px; white-space: nowrap; }

.preset-btn {
  font-size: 12px; padding: 5px 12px; border-radius: 20px;
  border: 1px solid #dee2e6; background: var(--card-bg); color: #495057;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.preset-btn:hover, .preset-btn.active {
  background: var(--brand-dark); color: #fff; border-color: var(--brand-dark);
}
.preset-group { display: contents; }
.period-label { font-size: 11px; color: #9ca3af; margin-left: auto; order: 999; }

/* ── Litepicker theme overrides ── */
.litepicker {
  --litepicker-container-months-color-bg: #fff;
  --litepicker-month-header-color: var(--brand-dark);
  --litepicker-button-prev-month-color: #6c757d;
  --litepicker-button-next-month-color: #6c757d;
  --litepicker-button-prev-month-color-hover: var(--brand-dark);
  --litepicker-button-next-month-color-hover: var(--brand-dark);
  --litepicker-day-color: #212529;
  --litepicker-day-color-hover: var(--brand-dark);
  --litepicker-is-today-color: #0d6efd;
  --litepicker-is-in-range-color: #e8f0fe;
  --litepicker-is-start-color: #fff;
  --litepicker-is-start-color-bg: var(--brand-dark);
  --litepicker-is-end-color: #fff;
  --litepicker-is-end-color-bg: var(--brand-dark);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.14);
  border: 1px solid var(--border);
}
.litepicker .container__months { border-radius: 14px; }
.litepicker .month-item-header { font-weight: 700; font-size: 14px; }
.litepicker .day-item { border-radius: 50%; font-size: 13px; }
.litepicker .day-item.is-start-date,
.litepicker .day-item.is-end-date { font-weight: 700; }
.litepicker .day-item.is-in-range { border-radius: 0; }

/* ── KPI cards ── */
.kpi-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 18px 18px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  height: 100%;
  border-top: 3px solid #0d6efd;
}
.kpi-card.accent-green  { border-top-color: #198754; }
.kpi-card.accent-orange { border-top-color: #f97316; }
.kpi-card.accent-purple { border-top-color: #7c3aed; }
.kpi-card.accent-gray   { border-top-color: #6c757d; }

.kpi-label { font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--brand-dark); line-height: 1.15; margin-top: 4px; }
.kpi-sub   { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-wow   { font-size: 12px; font-weight: 600; margin-top: 6px; display: flex; align-items: center; gap: 3px; }
.kpi-wow.up      { color: var(--up); }
.kpi-wow.down    { color: var(--down); }
.kpi-wow.neutral { color: var(--neu); }

/* ── Target progress bar ── */
.target-progress-wrap { margin-top: 8px; }
.target-progress-bar {
  height: 6px;
  border-radius: 99px;
  background: #e9ecef;
  overflow: hidden;
}
.target-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .4s ease;
  background: var(--up);
}
.target-progress-fill.amber { background: #f59e0b; }
.target-progress-fill.red   { background: var(--down); }
.target-pace-label { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── Status badges ── */
.badge-achieved { background: #d1fae5; color: #065f46; border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.badge-on-track { background: #dbeafe; color: #1e40af; border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.badge-lagging  { background: #fef3c7; color: #92400e; border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.badge-up       { background: #d1fae5; color: #065f46; border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 600; }
.badge-down     { background: #fee2e2; color: #991b1b; border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 600; }
.badge-neutral  { background: #f1f5f9; color: #475569; border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 600; }

/* ── Module cards (executive dashboard) ── */
.module-card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  border-top: 3px solid #0d6efd;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, transform .15s;
}
.module-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); transform: translateY(-1px); }
.module-card.disabled { border-top-color: #dee2e6; opacity: .6; pointer-events: none; }
.module-card-title { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.module-card-value { font-size: 28px; font-weight: 700; color: var(--brand-dark); line-height: 1.1; }
.module-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 20px; }
.module-card-copy { font-size: 12px; color: var(--muted); }
.module-card-placeholder { font-size: 16px; color: var(--muted); font-weight: 500; padding-top: 4px; }
.module-card-link  { font-size: 12px; font-weight: 600; color: #0d6efd; margin-top: auto; }

/* ── Chart cards ── */
.chart-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chart-title { font-size: 13px; font-weight: 600; color: var(--brand-dark); margin-bottom: 14px; }
.chart-frame {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}
.chart-frame > canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Tables ── */
.report-table { background: var(--card-bg); border-radius: 12px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.07); }
.report-table table { margin-bottom: 0; }
.report-table thead tr { background: var(--brand-dark); color: #fff; }
.report-table thead th { font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; padding: 10px 14px; border: none; }
.report-table tbody td { padding: 9px 14px; vertical-align: middle; border-color: var(--bg); font-size: 13px; }
.report-table tbody tr:nth-child(even) { background: #f8f9fa; }
.report-table tbody tr.total-row { font-weight: 700; background: #eef2ff !important; }

/* ── Tooltips ── */
.wow-tip { position: relative; cursor: default; border-bottom: 1px dotted currentColor; }
.wow-tip::after {
  content: attr(data-tip); position: absolute; top: 125%; left: 50%;
  transform: translateX(-50%); white-space: nowrap;
  background: #2b2d42; color: #fff; font-size: 11px; font-weight: 500;
  padding: 4px 10px; border-radius: 6px; pointer-events: none;
  opacity: 0; transition: opacity .15s; z-index: 10;
}
.wow-tip:hover::after { opacity: 1; }
tr:last-child .wow-tip::after { top: auto; bottom: 125%; }

/* ── Section headings ── */
.section-title {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 12px; padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}

/* ── Skeleton loading state ── */
.skeleton {
  background: linear-gradient(90deg, #e9ecef 25%, #f8f9fa 50%, #e9ecef 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
  display: inline-block;
}
.loading-block { width: 120px; }
.loading-block-lg { height: 32px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Placeholder states ── */
.empty-state-row { font-size: 13px; padding: 16px 0 !important; }
.platform-name { font-weight: 500; }
.placeholder-panel {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  padding: 64px 24px;
  text-align: center;
}
.placeholder-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  height: 32px;
  padding: 0 16px;
  border-radius: 999px;
  background: #eef2ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  margin-bottom: 20px;
}
.button-dark {
  background: var(--brand-dark);
  color: #fff;
  border-radius: 8px;
  border: 0;
}
.button-dark:hover {
  background: #12233d;
  color: #fff;
}

/* ── Footer ── */
.report-footer { font-size: 11px; color: #adb5bd; text-align: center; padding: 20px 0 32px; }

/* ── Responsive ── */
@media (max-width: 991.98px) {
  .page-shell { padding: 20px 16px; }
  .picker-bar { padding: 10px 16px; }
  .date-range-trigger { min-width: 0; width: 100%; }
  .chart-frame { min-height: 220px; }
  .chart-card { padding: 16px; }
}

@media (max-width: 767.98px) {
  .page-shell.narrow { padding-top: 28px; padding-bottom: 28px; }
  .page-title { font-size: 18px; }
  .placeholder-panel { padding: 48px 20px; }
  .picker-bar {
    top: 48px;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px 12px;
  }
  .picker-brand-row { width: 100%; }
  .mobile-filter-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .picker-controls { display: none; width: 100%; gap: 8px; }
  .picker-bar.filters-open .picker-controls { display: flex; flex-wrap: wrap; }
  .site-nav { padding: 0 16px; }
  .site-nav .nav-link { padding: 0 10px; font-size: 12px; }
}
