/* ════════════════════════════════════════════
   VSX Digital – Instagram Dashboard Styles
   ════════════════════════════════════════════ */

@font-face {
  font-family: 'Ranade';
  src: url('fonts/Ranade-Variable.woff2') format('woff2'),
       url('fonts/Ranade-Variable.woff') format('woff');
  font-weight: 100 700;
  font-display: swap;
  font-style: normal;
}
@font-face {
  font-family: 'Ranade';
  src: url('fonts/Ranade-Regular.woff2') format('woff2'),
       url('fonts/Ranade-Regular.woff') format('woff');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Ranade';
  src: url('fonts/Ranade-Medium.woff2') format('woff2'),
       url('fonts/Ranade-Medium.woff') format('woff');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Ranade';
  src: url('fonts/Ranade-Bold.woff2') format('woff2'),
       url('fonts/Ranade-Bold.woff') format('woff');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg:          #06081A;
  --bg-card:     #0B0E24;
  --bg-card2:    #0F1330;
  --bg-hover:    #141838;
  --border:      #1C2248;
  --accent:      #1432F5;
  --accent-dim:  rgba(20, 50, 245, 0.12);
  --accent2:     #0F26CC;
  --green:       #10B981;
  --green-dim:   rgba(16, 185, 129, 0.12);
  --red:         #EF4444;
  --red-dim:     rgba(239, 68, 68, 0.12);
  --yellow:      #F59E0B;
  --yellow-dim:  rgba(245, 158, 11, 0.12);
  --blue:        #1432F5;
  --pink:        #EC4899;
  --text-1:      #F0F4FF;
  --text-2:      #8899CC;
  --text-3:      #4A5580;
  --radius:      14px;
  --radius-sm:   8px;
  --sidebar-w:   220px;
  --transition:  0.2s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Ranade', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
select { font-family: inherit; }

/* ── Demo Banner ── */
.demo-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: linear-gradient(90deg, #92400e, #78350f);
  color: #FEF3C7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  font-size: 13px;
  gap: 12px;
}
.demo-banner code { background: rgba(0,0,0,0.3); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.demo-banner button { color: #FEF3C7; font-size: 16px; opacity: 0.7; }
.demo-banner button:hover { opacity: 1; }
.hidden { display: none !important; }

/* ── App Layout ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition), width var(--transition);
  overflow: hidden;
}
.sidebar.collapsed {
  width: 60px;
}
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-footer {
  display: none;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 16px;
}
.logo-img {
  height: 28px;
  width: auto;
  object-fit: contain;
}
.sidebar.collapsed .logo-img {
  display: none;
}
.sidebar-toggle {
  color: var(--text-2);
  font-size: 18px;
  padding: 4px;
  border-radius: 6px;
  transition: background var(--transition);
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text-1); }
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  font-size: 13px;
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-1); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-icon { font-size: 16px; flex-shrink: 0; }
.sidebar-footer {
  padding: 16px;
  font-size: 11px;
  color: var(--text-3);
  border-top: 1px solid var(--border);
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.main-content.collapsed { margin-left: 60px; }

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(6, 8, 26, 0.90);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  gap: 16px;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.mobile-menu-btn {
  display: none;
  color: var(--text-2);
  font-size: 20px;
}
.selector-label { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.selector {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  min-width: 160px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239899BA' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.selector:focus { outline: none; border-color: var(--accent); }
.period-btns { display: flex; gap: 4px; }
.period-btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--bg-card2);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.period-btn:hover { border-color: var(--accent); color: var(--accent); }
.period-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.export-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  transition: opacity var(--transition);
}
.export-btn:hover { opacity: 0.85; }

/* ── Page Content ── */
.page-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* ── Loading ── */
.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px;
  color: var(--text-2);
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Section ── */
.section { display: flex; flex-direction: column; gap: 20px; }
.section-header { display: flex; align-items: baseline; gap: 12px; }
.section-title { font-size: 20px; font-weight: 700; }
.section-subtitle { font-size: 13px; color: var(--text-3); }

/* ── Health Score ── */
.health-score-bar {
  height: 6px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
  margin: 6px 0 4px;
}
.health-score-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 1s ease;
}
.health-score-status { font-size: 11px; font-weight: 600; color: var(--text-3); }
/* Score colors */
.health-red .health-score-value { color: var(--red); }
.health-red .health-score-fill { background: var(--red); }
.health-red .health-score-status { color: var(--red); }
.health-yellow .health-score-value { color: var(--yellow); }
.health-yellow .health-score-fill { background: var(--yellow); }
.health-yellow .health-score-status { color: var(--yellow); }
.health-green .health-score-value { color: var(--green); }
.health-green .health-score-fill { background: var(--green); }
.health-green .health-score-status { color: var(--green); }

/* ── KPI Grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.kpi-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: transform var(--transition), border-color var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); }
.kpi-card.highlight { background: var(--bg-card); }
.kpi-card.highlight-green { background: var(--bg-card); }
.kpi-card.roi { background: var(--bg-card); }
.kpi-card.sm { padding: 14px 16px; }
.kpi-icon { font-size: 22px; flex-shrink: 0; margin-top: 2px; }
.kpi-content { flex: 1; min-width: 0; }
.kpi-label { font-size: 12px; color: var(--text-2); margin-bottom: 4px; display: flex; align-items: center; gap: 4px; }
.kpi-value { font-size: 24px; font-weight: 700; }
.kpi-value.big { font-size: 32px; }
.kpi-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.kpi-trend { font-size: 13px; font-weight: 600; margin-top: 4px; }
.trend-up { color: var(--green); }
.trend-down { color: var(--red); }
.trend-neutral { color: var(--text-3); }

/* ── KPI Mini Grid ── */
.kpi-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.kpi-mini-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi-mini-label { font-size: 12px; color: var(--text-2); }
.kpi-mini-value { font-size: 22px; font-weight: 700; color: var(--accent); }

/* ── Charts Grid ── */
.charts-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.charts-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.chart-card.full-width { width: 100%; }
.chart-card.span-2 { grid-column: span 2; }
.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.chart-card-header h3 { font-size: 14px; font-weight: 600; }
.chart-wrap { position: relative; height: 220px; }
.chart-wrap-sm { height: 200px; }

/* ── Format Cards ── */
.format-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.format-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.format-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.format-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-reels { background: rgba(236, 72, 153, 0.2); color: var(--pink); }
.badge-carousel { background: rgba(59, 130, 246, 0.2); color: var(--blue); }
.badge-image { background: rgba(16, 185, 129, 0.2); color: var(--green); }
.format-stat { display: flex; justify-content: space-between; font-size: 13px; }
.format-stat-label { color: var(--text-2); }
.format-stat-value { font-weight: 600; }

/* ── Data Table ── */
.table-responsive { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.row-top5 td { background: rgba(20, 50, 245, 0.06); border-left: 3px solid var(--accent); }
.row-top5:hover td { background: rgba(20, 50, 245, 0.12); }
.post-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.post-thumb-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: var(--bg-card2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-3);
}
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}
.rank-1 { background: #D97706; color: #fff; }
.rank-2 { background: #6B7280; color: #fff; }
.rank-3 { background: #92400E; color: #fff; }
.rank-other { background: var(--bg-hover); color: var(--text-2); }

/* ── Best Times Cards ── */
.best-times-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.best-time-card {
  background: linear-gradient(135deg, var(--accent-dim), transparent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  position: relative;
}
.best-time-rank {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}
.best-time-icon { font-size: 32px; margin-bottom: 8px; }
.best-time-day { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.best-time-hour { font-size: 28px; font-weight: 800; color: var(--accent); margin-bottom: 4px; }
.best-time-score { font-size: 12px; color: var(--text-2); }

/* ── Heatmap ── */
.heatmap-wrap { display: flex; flex-direction: column; gap: 8px; }
.heatmap-container { display: flex; flex-direction: column; }
.heatmap-x-labels {
  display: flex;
  padding-left: 0;
  gap: 3px;
  margin-bottom: 4px;
}
.heatmap-x-label {
  flex: 1;
  text-align: center;
  font-size: 9px;
  color: var(--text-3);
  min-width: 0;
}
.heatmap-y-labels {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 18px;
  padding-right: 8px;
  width: 36px;
  flex-shrink: 0;
}
.heatmap-y-label {
  flex: 1;
  font-size: 11px;
  color: var(--text-2);
  text-align: right;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 28px;
}
.heatmap-outer { display: flex; gap: 4px; }
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
}
.heatmap-cell {
  width: 100%;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform var(--transition), opacity var(--transition);
  position: relative;
}
.heatmap-cell:hover { transform: scale(1.3); z-index: 10; }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 8px;
  justify-content: flex-end;
}
.heatmap-legend-bar {
  width: 120px;
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg, rgba(20,50,245,0.1), #1432F5);
}

/* ── Tooltip ── */
.tooltip-icon {
  font-size: 12px;
  color: var(--text-3);
  cursor: help;
}
.tooltip-popup {
  position: fixed;
  z-index: 9999;
  background: #0F1330;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-1);
  max-width: 260px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  line-height: 1.5;
}
.tooltip-popup.visible { opacity: 1; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Responsive ── */
@media (max-width: 1200px) {
  .charts-grid-3 { grid-template-columns: 1fr 1fr; }
  .chart-card.span-2 { grid-column: span 1; }
  .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-220px); width: 220px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-menu-btn { display: block; }
  .charts-grid-2 { grid-template-columns: 1fr; }
  .format-cards { grid-template-columns: 1fr; }
  .best-times-cards { grid-template-columns: 1fr; }
  .heatmap-cell { height: 20px; }
  .topbar { flex-wrap: wrap; }
}
@media (max-width: 600px) {
  .page-content { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-grid-4 { grid-template-columns: 1fr 1fr; }
  .section-title { font-size: 16px; }
  .kpi-value { font-size: 18px; }
  .kpi-value.big { font-size: 24px; }
  .topbar-right { flex-wrap: wrap; gap: 8px; }
  .export-btn span { display: none; }
}

/* ── Print / PDF ── */
@media print {
  .sidebar, .topbar, .demo-banner { display: none !important; }
  .main-content { margin-left: 0; }
  .section { page-break-inside: avoid; }
  body { background: #fff; color: #000; }
}
