/* -------------------------------------------------------
   Diginess Meta Reporting — Custom CSS
   Tailwind handles most layout; this file adds:
   - CSS custom properties
   - Chart containers
   - Table utilities
   - Print styles
------------------------------------------------------- */

:root {
  --brand-primary: #0F172A;
  --brand-accent:  #6366F1;
}

/* Chart containers — fixed height for consistent layout */
.chart-container {
  position: relative;
  height: 220px;
  width: 100%;
}

/* Sticky table header — applied to campaigns-table and drilldown-table */
#campaigns-table thead th,
#drilldown-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  box-shadow: 0 1px 0 #e2e8f0;
}

/* Pinned first column (campaign name / adset name / ad name) */
#campaigns-table th:first-child,
#campaigns-table td:first-child,
#drilldown-table th:first-child,
#drilldown-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: white;
}

/* Corner cell: both sticky directions — needs highest z-index */
#campaigns-table thead th:first-child,
#drilldown-table thead th:first-child {
  z-index: 3;
  background: #f8fafc;
}

/* Thin right shadow on pinned column to separate it visually */
#campaigns-table td:first-child,
#campaigns-table th:first-child,
#drilldown-table td:first-child,
#drilldown-table th:first-child {
  box-shadow: 2px 0 4px -2px rgba(0,0,0,0.08);
}

/* Zebra stripe override for bordered tables */
#campaigns-table tbody tr:nth-child(even),
#drilldown-table tbody tr:nth-child(even) {
  background-color: #fafafa;
}

/* Keep pinned cell background in sync with zebra row */
#campaigns-table tbody tr:nth-child(even) td:first-child,
#drilldown-table tbody tr:nth-child(even) td:first-child {
  background: #fafafa;
}

/* Hover state on pinned cell */
#campaigns-table tbody tr:hover td:first-child,
#drilldown-table tbody tr:hover td:first-child {
  background: #f1f5f9;
}

/* Focus ring using accent color */
input:focus, select:focus, textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--brand-accent);
}

/* Sidebar transition */
#sidebar {
  will-change: transform;
}

/* Loading skeleton pulse */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}
.animate-pulse { animation: pulse 1.5s cubic-bezier(.4,0,.6,1) infinite; }

/* Builder canvas helpers */
.min-h-\[640px\] { min-height: 640px; }

/* -------------------------------------------------------
   Print / PDF export styles
------------------------------------------------------- */
@media print {
  /* Hide navigation and interactive elements */
  #sidebar,
  #sidebar-overlay,
  header,
  .print\:hidden,
  button,
  input,
  select {
    display: none !important;
  }

  /* Full-width content area */
  #app { display: block !important; }
  .lg\:ml-64 { margin-left: 0 !important; }
  main { padding: 0 !important; overflow: visible !important; height: auto !important; }
  body  { background: white !important; }
  #app  { height: auto !important; overflow: visible !important; }

  /* Reset flex/overflow on print */
  .flex-1, .flex { display: block !important; }

  /* Print header */
  .print\:block { display: block !important; }

  /* Chart containers — slightly taller for print */
  .chart-container {
    height: 200px;
    break-inside: avoid;
  }

  /* Page breaks */
  .print-page-break {
    break-before: auto;
    break-inside: avoid;
  }

  /* KPI cards in a row for print */
  #kpi-bar, #kpi-bar-2 {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    break-inside: avoid;
  }

  /* Chart grid for print */
  .grid.grid-cols-1.lg\:grid-cols-2 {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  /* Table: don't break rows across pages */
  tr { break-inside: avoid; }

  /* Page setup */
  @page {
    size: A4 landscape;
    margin: 1.5cm;
  }

  /* Typography for print */
  body { font-size: 11px; color: #1e293b !important; }
  h1, h2, h3 { color: #0f172a !important; }

  /* Borders for print */
  .border, .border-slate-200 { border-color: #e2e8f0 !important; }

  /* Remove shadows for print */
  .shadow-sm, .shadow { box-shadow: none !important; }

  /* Show table print hidden column labels */
  .print\:text-slate-400 { color: #94a3b8 !important; }
}
