/* AR Dashboard v5 — Athletic Republic */
/* Brand: #C41230 red, #1a1a1a dark, white cards */

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

:root {
  --ar-red:    #C41230;
  --dark:      #1a1a1a;
  --gray-1:    #f5f5f7;
  --gray-2:    #e8e8ec;
  --gray-3:    #c7c7cc;
  --gray-4:    #6e6e73;
  --text:      #1d1d1f;
  --text-muted:#6e6e73;
  --green:     #15803d;
  --blue:      #2563eb;
  --purple:    #7c3aed;
  --green-bg:  #d5f0e0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --radius:    12px;
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--gray-1);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Loading overlay ─────────────────────────────────────────────────────── */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(245,245,247,0.75);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-2);
  border-top-color: var(--ar-red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Header ─────────────────────────────────────────────────────────────── */

header {
  background: var(--dark);
  border-bottom: 3px solid var(--ar-red);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo-mark {
  background: var(--ar-red);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
  padding: 5px 10px;
  border-radius: 6px;
  text-transform: uppercase;
}

.header-title {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

/* ── Period Selector ─────────────────────────────────────────────────────── */

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.period-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  padding: 3px;
}

.period-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.6);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  padding: 4px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1.4;
}

.period-btn:hover:not(:disabled) {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.period-btn.active {
  background: var(--ar-red);
  color: #fff;
}

.period-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.period-days-label {
  color: rgba(255,255,255,.4);
  font-size: 12px;
  padding: 0 6px 0 2px;
}

/* ── Header Right ────────────────────────────────────────────────────────── */

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--gray-3);
  font-size: 13px;
  flex-shrink: 0;
}

.period-badge {
  background: rgba(196,18,48,.18);
  color: #ff6b82;
  border: 1px solid rgba(196,18,48,.3);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.updated-time {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot-live {
  width: 7px;
  height: 7px;
  background: #2ecc71;
  border-radius: 50%;
  display: inline-block;
}

/* ── User chip ───────────────────────────────────────────────────────────── */

.user-chip {
  display: flex;
  align-items: center;
  gap: 7px;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.2);
  object-fit: cover;
}

.user-name {
  font-size: 13px;
  color: rgba(255,255,255,.75);
  font-weight: 500;
}

/* ── Main layout ─────────────────────────────────────────────────────────── */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 32px 60px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Section headers ─────────────────────────────────────────────────────── */

.section-header {
  color: var(--ar-red);
  font-size: 18px;
  font-weight: 700;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ar-red);
  margin-top: 24px;
  margin-bottom: 12px;
}

.section-header:first-child {
  margin-top: 0;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-2);
  padding: 20px 24px;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── Snapshot Grid (4 KPI cards) ─────────────────────────────────────────── */

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}

.snapshot-card {
  background: #f8fafc;
  border: 1px solid var(--gray-2);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
}

.snap-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.snap-value {
  font-size: 28px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1;
}

/* ── New Lead Status Grid (6-cell) ───────────────────────────────────────── */

.leads-status-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  border: 1px solid var(--gray-2);
  border-radius: 8px;
  overflow: hidden;
}

.ls-cell {
  text-align: center;
  padding: 14px 8px;
  border-right: 1px solid var(--gray-2);
}

.ls-cell-last {
  border-right: none;
}

.ls-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.ls-value {
  font-size: 22px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.1;
}

.ls-value.ls-red    { color: #dc2626; }
.ls-value.ls-green  { color: var(--green); }
.ls-value.ls-blue   { color: var(--blue); }
.ls-value.ls-ar-red { color: var(--ar-red); }

.ls-formula {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 2px;
}

.leads-footnote {
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
  text-align: center;
  margin-top: 10px;
}

/* ── Charts row ──────────────────────────────────────────────────────────── */

.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.chart-container {
  position: relative;
}

.chart-container canvas {
  width: 100% !important;
}

/* ── Donut / legend ──────────────────────────────────────────────────────── */

.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.donut-wrap canvas {
  max-width: 200px !important;
  max-height: 200px !important;
}

.legend-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.legend-label  { color: var(--text); }
.legend-count  { font-weight: 600; color: var(--text); }
.legend-pct    { font-size: 11px; color: var(--text-muted); margin-left: 4px; }

/* ── Google Ads KPI rows ─────────────────────────────────────────────────── */

.ads-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: #f8fafc;
  border: 1px solid var(--gray-2);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.ads-kpi-row2 {
  grid-template-columns: 1fr 2fr 1fr;
}

.ads-kpi-cell {
  text-align: center;
  padding: 16px 12px;
  border-right: 1px solid var(--gray-2);
}

.ads-kpi-cell:last-child {
  border-right: none;
}

.ads-kpi-cell-wide {
  border-top: 1px solid var(--gray-2);
}

.ads-kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.ads-kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.1;
}

.ads-kpi-value.ads-kpi-green  { color: var(--green); }
.ads-kpi-value.ads-kpi-purple { color: var(--purple); }
.ads-kpi-value.ads-kpi-blue   { color: var(--blue); }

.ads-kpi-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 3px;
}

/* ── Data tables (AR red header) ─────────────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead tr th {
  background: var(--ar-red);
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
}

.data-table thead tr th:first-child {
  border-radius: 6px 0 0 0;
}

.data-table thead tr th:last-child {
  border-radius: 0 6px 0 0;
}

.data-table tbody tr td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-2);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: #f8fafc;
}

.data-table tbody tr.row-alt td {
  background: #f8fafc;
}

.data-table tbody tr.row-alt:hover td {
  background: var(--gray-2);
}

.data-table tbody tr.row-overall td {
  background: #f0f9ff;
  font-weight: 600;
  border-top: 2px solid var(--gray-2);
}

/* ── Table cell helpers ───────────────────────────────────────────────────── */

.cell-bold  { font-weight: 600; }
.cell-green { color: var(--green); font-weight: 600; }
.cell-muted { color: var(--text-muted); }

/* ── Table sub-title ─────────────────────────────────────────────────────── */

.table-sub-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* ── Error banner ─────────────────────────────────────────────────────────── */

.error-banner {
  background: #fde8ec;
  border: 1px solid rgba(196,18,48,.3);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--ar-red);
  font-size: 13px;
  display: none;
  margin-bottom: 8px;
}

/* ── Comment / Feedback Form ─────────────────────────────────────────────── */

.comment-intro {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-textarea {
  width: 100%;
  border: 1.5px solid var(--gray-2);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  resize: vertical;
  min-height: 100px;
  transition: border-color 0.15s;
  background: #fafafa;
}

.comment-textarea:focus {
  outline: none;
  border-color: var(--ar-red);
  background: #fff;
}

.comment-footer {
  display: flex;
  align-items: center;
  gap: 16px;
}

.comment-btn {
  background: var(--ar-red);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
}

.comment-btn:hover:not(:disabled) {
  opacity: 0.88;
}

.comment-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.comment-toast {
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
}

.comment-toast-success {
  background: #d5f0e0;
  color: var(--green);
  border: 1px solid rgba(21,128,61,.2);
}

.comment-toast-error {
  background: #fde8ec;
  color: var(--ar-red);
  border: 1px solid rgba(196,18,48,.2);
}

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

@media (max-width: 1100px) {
  .snapshot-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .leads-status-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .ls-cell:nth-child(3),
  .ls-cell:nth-child(6) {
    border-right: none;
  }
  .ls-cell:nth-child(4),
  .ls-cell:nth-child(5),
  .ls-cell:nth-child(6) {
    border-top: 1px solid var(--gray-2);
  }
}

@media (max-width: 860px) {
  main    { padding: 20px 16px 48px; }
  header  { padding: 0 12px; gap: 8px; }
  .header-title { display: none; }
  .updated-time { display: none; }
  .charts-row { grid-template-columns: 1fr; }
  .snapshot-grid { grid-template-columns: repeat(2, 1fr); }
  .ads-kpi-row   { grid-template-columns: repeat(2, 1fr); }
  .ads-kpi-row2  { grid-template-columns: 1fr; }
  .data-table { font-size: 12px; }
  .data-table thead tr th,
  .data-table tbody tr td { padding: 8px 10px; }
}

@media (max-width: 560px) {
  .leads-status-grid { grid-template-columns: repeat(2, 1fr); }
  .ls-cell:nth-child(2),
  .ls-cell:nth-child(4),
  .ls-cell:nth-child(6) { border-right: none; }
  .ls-cell:nth-child(3),
  .ls-cell:nth-child(4),
  .ls-cell:nth-child(5),
  .ls-cell:nth-child(6) { border-top: 1px solid var(--gray-2); }
  .period-days-label { display: none; }
  .user-name { display: none; }
}
