/* ============================================================
   SPANINSIGHT REPORT DASHBOARD — Premium Design System
   ============================================================ */

:root {
  --primary: #6C63FF;
  --primary-dark: #5A52D5;
  --primary-light: #8B83FF;
  --accent: #00D9FF;
  --success: #00E676;
  --warning: #FFB74D;
  --error: #FF5252;
  --bg: #F5F6FA;
  --surface: #FFFFFF;
  --surface-alt: #F0F1F8;
  --border: #E0E1EC;
  --text: #1A1B2E;
  --text-secondary: #6B6D82;
  --text-muted: #9EA0B4;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 24px rgba(108, 99, 255, 0.15);
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #0A0B14;
  --surface: #141627;
  --surface-alt: #1C1E33;
  --border: #2A2D4A;
  --text: #EEEEF5;
  --text-secondary: #8E90A6;
  --text-muted: #5A5C72;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 32px rgba(108, 99, 255, 0.2);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* Theme Toggle FAB & Fixed Icon */
.fixed-icon-link {
  position: fixed; top: 16px; left: 16px; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 12px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--surface);
  transition: all var(--transition); box-shadow: var(--shadow-sm);
}
.fixed-icon-link:hover { border-color: var(--primary); box-shadow: var(--shadow-glow); transform: translateY(-1px); }
.fixed-icon { height: 28px; width: auto; opacity: 0.85; transition: opacity var(--transition); }
.fixed-icon-link:hover .fixed-icon { opacity: 1; }

.theme-fab {
  position: fixed; top: 16px; right: 16px; z-index: 100;
  width: 44px; height: 44px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); box-shadow: var(--shadow-sm);
}
.theme-fab:hover { border-color: var(--primary); color: var(--primary); box-shadow: var(--shadow-glow); }
.theme-fab .icon-sun, .theme-fab .icon-moon { width: 20px; height: 20px; position: absolute; transition: all var(--transition); }
[data-theme="light"] .theme-fab .icon-moon { opacity: 0; transform: scale(0.5) rotate(-90deg); }
[data-theme="light"] .theme-fab .icon-sun { opacity: 1; transform: scale(1) rotate(0); }
[data-theme="dark"] .theme-fab .icon-sun { opacity: 0; transform: scale(0.5) rotate(90deg); }
[data-theme="dark"] .theme-fab .icon-moon { opacity: 1; transform: scale(1) rotate(0); }

/* Container */
.report-container { max-width: 800px; width: 100%; margin: 0 auto; padding: 24px 16px 40px; }

/* States */
.state { animation: fadeIn 0.4s ease-out; }
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* Loading */
#loading { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; gap: 24px; }
.loader { position: relative; width: 56px; height: 56px; }
.loader-ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--primary); animation: spin 1s linear infinite; }
.loader-ring-delay { border-top-color: var(--accent); animation-delay: 0.3s; inset: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { color: var(--text-secondary); font-size: 14px; font-weight: 500; }

/* Error */
#error { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; text-align: center; gap: 16px; }
.error-icon { width: 64px; height: 64px; border-radius: 50%; background: rgba(255,82,82,0.1); color: var(--error); font-size: 28px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
#error h2 { font-size: 22px; font-weight: 700; }
#error p { color: var(--text-secondary); font-size: 14px; max-width: 320px; }

/* Report Header */
.report-header {
  text-align: center; margin-bottom: 32px; padding: 32px 24px;
  background: var(--surface); border-radius: var(--radius-xl);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.report-logo-link { display: inline-block; margin-bottom: 20px; }
.report-logo { height: 32px; width: auto; opacity: 0.85; transition: opacity var(--transition); }
.report-logo:hover { opacity: 1; }
#report-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; line-height: 1.3; }
.report-meta { color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; }
.report-expiry { color: var(--text-muted); font-size: 12px; margin-top: 16px; }

/* Action Buttons */
.report-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; font-family: var(--font); font-size: 14px; font-weight: 600;
  border: none; border-radius: var(--radius-md); cursor: pointer;
  transition: all var(--transition); text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 16px rgba(108,99,255,0.3); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 6px 24px rgba(108,99,255,0.4); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Chart Cards */
.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; margin-bottom: 16px;
  box-shadow: var(--shadow-sm); transition: box-shadow var(--transition);
}
.chart-card:hover { box-shadow: var(--shadow-md); }
.chart-number { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 13px; font-weight: 700; margin-bottom: 12px; }
.chart-prompt { font-size: 16px; font-weight: 600; margin-bottom: 16px; line-height: 1.4; }
.chart-image { width: 100%; border-radius: var(--radius-md); margin-bottom: 16px; background: var(--surface-alt); }
.chart-description { font-size: 14px; color: var(--text-secondary); line-height: 1.7; white-space: pre-wrap; }

/* Footer */
.report-footer { text-align: center; padding: 32px 0; }
.powered-by-link { display: flex; flex-direction: column; align-items: center; gap: 8px; text-decoration: none; }
.powered-by-text { font-size: 11px; color: var(--text-muted); font-weight: 500; letter-spacing: 0.5px; text-transform: uppercase; }
.powered-by-logo { height: 36px; width: auto; opacity: 0.7; }

/* Responsive */
@media (max-width: 480px) {
  .report-container { padding: 16px 12px 32px; }
  .report-header { padding: 24px 16px; }
  #report-title { font-size: 20px; }
  .chart-card { padding: 16px; }
  .report-actions { flex-direction: column; }
  .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Print styles for PDF */
@media print {
  .theme-fab, .report-actions, .report-expiry, .report-footer { display: none !important; }
  body { background: #fff; }
  .report-container { max-width: 100%; padding: 0; }
  .chart-card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}
