/* ─── Florio Analytics Dashboard — Styles ─────────────────────────────────── */

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

:root {
  --bg: #E7EDDF;
  --bg-dark: #D8E0CF;
  --text: #375926;
  --text-muted: rgba(78, 93, 66, 0.8);
  --card: #FAF9F5;
  --card-border: #EEEEEE;
  --accent: #EE9E4F;
  --accent-light: #FBAE62;
  --green-light: #8AAC6B;
  --green-dark: #4E5D42;
  --white: #FFFFFF;
  --shadow: rgba(0, 0, 0, 0.15);
  --radius: 12px;
  --radius-lg: 16px;
  --font: 'Nunito', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ─── Password Gate ──────────────────────────────────────────────────────── */

.password-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
}

.password-gate h1 {
  font-size: 28px;
  font-weight: 700;
}

.password-gate p {
  color: var(--text-muted);
  font-size: 14px;
}

.password-gate input {
  font-family: var(--font);
  font-size: 16px;
  padding: 12px 20px;
  border: 1px solid var(--card-border);
  border-radius: 100px;
  background: var(--card);
  color: var(--text);
  width: 300px;
  outline: none;
  text-align: center;
}

.password-gate input:focus {
  border-color: var(--green-light);
}

.password-gate .error {
  color: #D44;
  font-size: 13px;
  font-weight: 500;
}

.btn-primary {
  font-family: var(--font);
  font-weight: 700;
  font-size: 16px;
  color: var(--white);
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border: none;
  border-radius: 100px;
  padding: 12px 40px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.97); }

/* ─── Layout ─────────────────────────────────────────────────────────────── */

.app { display: none; }
.app.visible { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  background: var(--card);
  border-right: 1px solid var(--card-border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 2px 0 8px rgba(0,0,0,0.05);
}

.sidebar-logo {
  font-size: 22px;
  font-weight: 700;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text);
}

.sidebar-logo span {
  color: var(--accent);
}

.sidebar nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover {
  background: var(--bg);
  color: var(--text);
}

.sidebar nav a.active {
  color: var(--text);
  font-weight: 700;
  background: var(--bg);
  border-left-color: var(--accent);
}

.sidebar nav a .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.main {
  margin-left: 220px;
  flex: 1;
  padding: 32px;
  min-height: 100vh;
}

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

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
}

.page-header .subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Date Picker ────────────────────────────────────────────────────────── */

.date-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.date-btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.date-btn:hover { border-color: var(--green-light); color: var(--text); }
.date-btn.active { background: var(--text); color: var(--white); border-color: var(--text); }

/* ─── Toggle: Numbers / Percentages ──────────────────────────────────────── */

.toggle-group {
  display: inline-flex;
  border: 1px solid var(--card-border);
  border-radius: 100px;
  overflow: hidden;
  background: var(--card);
}

.toggle-btn {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.toggle-btn.active {
  background: var(--text);
  color: var(--white);
}

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

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 3px 6px var(--shadow);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Grid ───────────────────────────────────────────────────────────────── */

.grid {
  display: grid;
  gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

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

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
}

.stat-value.accent { color: var(--accent); }
.stat-value.green { color: var(--green-light); }

.stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.stat-change {
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

.stat-change.positive { color: var(--green-light); }
.stat-change.negative { color: #D44; }

/* ─── TV Mode (Home/Live) ───────────────────────────────────────────────── */

.tv-mode .sidebar { display: none; }
.tv-mode .main { margin-left: 0; }

.tv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 24px;
}

.tv-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 12px var(--shadow);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s;
}

.tv-card:hover { transform: translateY(-2px); }

.tv-value {
  font-size: 56px;
  font-weight: 700;
  line-height: 1.1;
}

.tv-label {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-muted);
}

.tv-icon {
  font-size: 32px;
  margin-bottom: 4px;
}

.tv-header {
  text-align: center;
  margin-bottom: 32px;
}

.tv-header h1 {
  font-size: 32px;
  font-weight: 700;
}

.tv-header p {
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 4px;
}

.tv-footer {
  text-align: center;
  margin-top: 40px;
  font-size: 14px;
  color: var(--text-muted);
}

.pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--green-light);
  border-radius: 50%;
  margin-right: 6px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

/* ─── Funnel Chart ───────────────────────────────────────────────────────── */

.funnel-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 300px;
  padding: 16px 0;
}

.funnel-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 6px;
}

.funnel-bar {
  width: 100%;
  max-width: 60px;
  background: linear-gradient(180deg, var(--accent), var(--accent-light));
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height 0.5s ease;
  position: relative;
}

.funnel-bar-value {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.funnel-bar-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  max-width: 80px;
  line-height: 1.2;
}

.funnel-drop {
  font-size: 11px;
  font-weight: 600;
  color: #D44;
  text-align: center;
}

/* ─── Chart Containers ───────────────────────────────────────────────────── */

.chart-wrap {
  position: relative;
  height: 280px;
}

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

/* ─── Cross Reference ────────────────────────────────────────────────────── */

.cross-ref-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.cross-ref-controls select {
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 10px 16px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--card-border);
}

.data-table th {
  font-weight: 700;
  color: var(--text);
  background: var(--bg);
  position: sticky;
  top: 0;
}

.data-table td {
  color: var(--text-muted);
  font-weight: 500;
}

.data-table tr:hover td {
  background: rgba(138, 172, 107, 0.08);
}

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

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
  gap: 8px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--card-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ─── Empty State ────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.empty-state p { font-size: 14px; }
