/* =======================================================================
   app.css — Global Design Tokens, Typography, Reset, Base Styles
   Advanced Solar Load Calculator — Production CSS Architecture
   ======================================================================= */

/* ── CSS Custom Properties (Design Tokens) ─────────────────────────── */
:root {
  /* Background layers */
  --bg:        #0a0e1a;
  --bg-2:      #0f1424;
  --panel:     #131a2e;
  --panel-2:   #1a2238;
  --surface:   #0f1424;
  --surface-2: #131a2e;

  /* Borders */
  --border:    #1f2a44;
  --border-2:  #2a3656;
  --border-3:  #3a4870;

  /* Text */
  --text:      #e6ecff;
  --text-2:    #a3b1d1;
  --text-3:    #6b7a9c;
  --text-4:    #4a5678;

  /* Accent / Solar brand */
  --accent:    #ff6a00;
  --accent-2:  #ffb547;
  --accent-3:  #ff8c33;
  --solar:     #f59e0b;
  --solar-2:   #fbbf24;

  /* Semantic colors */
  --green:     #10b981;
  --red:       #ef4444;
  --blue:      #3b82f6;
  --purple:    #8b5cf6;
  --cyan:      #06b6d4;
  --pink:      #ec4899;
  --yellow:    #eab308;
  --indigo:    #6366f1;
  --rose:      #f43f5e;
  --sky:       #0ea5e9;
  --fuchsia:   #d946ef;
  --teal:      #14b8a6;
  --emerald:   #10b981;

  /* Spacing scale (4px base) */
  --sp-0:  0;
  --sp-1:  0.25rem;  /* 4px  */
  --sp-2:  0.5rem;   /* 8px  */
  --sp-3:  0.75rem;  /* 12px */
  --sp-4:  1rem;     /* 16px */
  --sp-5:  1.25rem;  /* 20px */
  --sp-6:  1.5rem;   /* 24px */
  --sp-8:  2rem;     /* 32px */
  --sp-10: 2.5rem;   /* 40px */
  --sp-12: 3rem;     /* 48px */
  --sp-16: 4rem;     /* 64px */
  --sp-20: 5rem;     /* 80px */

  /* Typography scale */
  --fs-xs:   0.625rem;  /* 10px */
  --fs-sm:   0.75rem;   /* 12px */
  --fs-base: 0.875rem;  /* 14px */
  --fs-md:   1rem;      /* 16px */
  --fs-lg:   1.125rem;  /* 18px */
  --fs-xl:   1.25rem;   /* 20px */
  --fs-2xl:  1.5rem;    /* 24px */
  --fs-3xl:  1.875rem;  /* 30px */

  /* Line heights */
  --lh-tight:  1.25;
  --lh-normal: 1.5;
  --lh-relaxed: 1.625;

  /* Border radii */
  --radius-sm:  4px;
  --radius-md:  6px;
  --radius-lg:  8px;
  --radius-xl:  12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  /* Shadows & elevation */
  --shadow-sm:    0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:    0 4px 6px rgba(0,0,0,0.4);
  --shadow-lg:    0 10px 15px rgba(0,0,0,0.5);
  --shadow-xl:    0 20px 25px rgba(0,0,0,0.6);
  --shadow-accent: 0 4px 14px rgba(255,106,0,0.3);

  /* Transitions */
  --transition-fast:   0.15s ease;
  --transition-base:   0.2s ease;
  --transition-slow:   0.3s ease;
  --transition-slower: 0.5s ease;

  /* Z-index layers */
  --z-sidebar:    40;
  --z-header:     30;
  --z-modal:      50;
  --z-toast:      60;
  --z-tooltip:    70;

  /* Focus ring */
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

  /* Layout */
  --sidebar-width: 16rem;
  --sidebar-collapsed: 4rem;
  --header-height: 4rem;
  --max-content: 1800px;
}

/* ── Reset & Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #root { height: 100%; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  direction: rtl;
}

.mono {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-3); }

.table-scroll::-webkit-scrollbar { height: 8px; }

/* ── Focus ─────────────────────────────────────────────────────────── */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent) !important;
  background: rgba(15, 20, 36, 0.9);
}

/* ── Number input spinners ─────────────────────────────────────────── */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] { -moz-appearance: textfield; }

/* ── Range input ───────────────────────────────────────────────────── */
input[type=range] {
  -webkit-appearance: none;
  height: 4px;
  background: var(--border-2);
  border-radius: 4px;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(255,106,0,0.6);
}

/* ── Grid background ───────────────────────────────────────────────── */
.bg-grid {
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* ── Solar glow ────────────────────────────────────────────────────── */
.solar-glow {
  box-shadow: 0 0 40px rgba(245, 158, 11, 0.15),
              0 0 80px rgba(255, 106, 0, 0.08);
}

/* ── Glass morphism ────────────────────────────────────────────────── */
.glass {
  background: rgba(19, 26, 46, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ── Animations ────────────────────────────────────────────────────── */
@keyframes pulse-slow {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}
@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes slideInUp {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.animate-pulse-slow { animation: pulse-slow 3s ease-in-out infinite; }
.animate-spin-slow  { animation: spin-slow 12s linear infinite; }
.animate-spin       { animation: spin-slow 1s linear infinite; }
.shimmer {
  background: linear-gradient(90deg, transparent, rgba(255,106,0,0.15), transparent);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}
.animate-fade-in   { animation: fadeIn 0.3s ease; }
.animate-slide-in  { animation: slideInRight 0.3s ease; }
.animate-scale-in  { animation: scaleIn 0.2s ease; }

/* ── Selection ─────────────────────────────────────────────────────── */
::selection {
  background: rgba(255, 106, 0, 0.3);
  color: var(--text);
}

/* ── Headings ──────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-weight: 600;
  line-height: var(--lh-tight);
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }

/* ── Links ─────────────────────────────────────────────────────────── */
a {
  color: var(--accent-2);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--accent); }
