/* ============================================================
   CircuitForge – styles.css
   Made by Or Brami
   Dark-mode, professional electronics lab aesthetic
   ============================================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Assistant:wght@300;400;500;600;700&family=Space+Mono:ital,wght@0,400;0,700;1,400&family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* ---------- CSS Variables ---------- */
:root {
  /* Core palette */
  --bg-primary:    #0a0c14;
  --bg-secondary:  #0f1221;
  --bg-card:       #141828;
  --bg-card-hover: #1a2035;
  --bg-elevated:   #1e2540;
  --bg-input:      #111627;

  /* Accent colors */
  --accent-blue:   #4f8ef7;
  --accent-purple: #9b5de5;
  --accent-cyan:   #00d4ff;
  --accent-green:  #22c55e;
  --accent-yellow: #f59e0b;
  --accent-red:    #ef4444;
  --accent-orange: #f97316;

  /* Gradients */
  --grad-primary:  linear-gradient(135deg, #4f8ef7 0%, #9b5de5 100%);
  --grad-card:     linear-gradient(145deg, #141828 0%, #1a2035 100%);
  --grad-glow:     radial-gradient(ellipse at center, rgba(79,142,247,0.15) 0%, transparent 70%);

  /* Text */
  --text-primary:   #e8ecf5;
  --text-secondary: #8b95b0;
  --text-muted:     #4a5270;
  --text-accent:    #4f8ef7;

  /* Borders */
  --border:         rgba(79,142,247,0.15);
  --border-hover:   rgba(79,142,247,0.4);
  --border-active:  #4f8ef7;

  /* Shadows */
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:      0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg:      0 8px 40px rgba(0,0,0,0.6);
  --shadow-blue:    0 4px 20px rgba(79,142,247,0.3);
  --shadow-purple:  0 4px 20px rgba(155,93,229,0.3);
  --glow-blue:      0 0 20px rgba(79,142,247,0.4), 0 0 40px rgba(79,142,247,0.2);

  /* Layout */
  --sidebar-w:     280px;
  --results-w:     320px;
  --header-h:      64px;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --radius-xl:     24px;

  /* Fonts */
  --font-ui:       'Outfit', 'Assistant', system-ui, sans-serif;
  --font-mono:     'Space Mono', 'Courier New', monospace;

  /* Transitions */
  --transition:    0.25s cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 0.4s cubic-bezier(0.4,0,0.2,1);
}

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

html {
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  position: relative;
}

/* RTL support */
body[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

body[dir="rtl"] .sidebar { order: 3; border-left: none; border-right: 1px solid var(--border); }
body[dir="rtl"] .results-panel { order: 1; border-right: none; border-left: 1px solid var(--border); }
body[dir="rtl"] .main-content { order: 2; }

/* Animated background mesh */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 800px 600px at 20% 20%, rgba(79,142,247,0.05) 0%, transparent 60%),
    radial-gradient(ellipse 600px 800px at 80% 80%, rgba(155,93,229,0.05) 0%, transparent 60%),
    radial-gradient(ellipse 400px 400px at 50% 50%, rgba(0,212,255,0.03) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-blue); }

/* ---------- Selection ---------- */
::selection { background: rgba(79,142,247,0.3); color: #fff; }

/* ============================================================
   HEADER
   ============================================================ */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(10,12,20,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--grad-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-blue);
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-name {
  font-size: 1.25rem;
  font-weight: 800;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.logo-tagline {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 400;
}

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

.header-made-by {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-right: 12px;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  text-decoration: none;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--transition);
}

.btn:hover::after { background: rgba(255,255,255,0.06); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: var(--shadow-blue);
}
.btn-primary:hover { box-shadow: var(--glow-blue); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border); }

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--accent-red);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); border-color: var(--accent-red); }

.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-xs { padding: 3px 8px; font-size: 0.7rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn-lang {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  padding: 6px 12px;
}
.btn-lang:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
  display: flex;
  height: 100vh;
  padding-top: var(--header-h);
  position: relative;
  z-index: 1;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-slow);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.search-box {
  position: relative;
}

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px 7px 32px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  transition: border-color var(--transition);
}

.search-input:focus { outline: none; border-color: var(--accent-blue); }
.search-input::placeholder { color: var(--text-muted); }

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.8rem;
  pointer-events: none;
}

body[dir="rtl"] .search-input { padding: 7px 32px 7px 12px; }
body[dir="rtl"] .search-icon { left: auto; right: 10px; }

.btn-random {
  width: 100%;
  margin-top: 10px;
  background: linear-gradient(135deg, rgba(79,142,247,0.2) 0%, rgba(155,93,229,0.2) 100%);
  border: 1px solid rgba(79,142,247,0.35);
  color: var(--accent-cyan);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  animation: pulse-border 3s ease-in-out infinite;
}
.btn-random:hover {
  background: linear-gradient(135deg, rgba(79,142,247,0.35) 0%, rgba(155,93,229,0.35) 100%);
  border-color: var(--accent-blue);
  box-shadow: var(--glow-blue);
  transform: translateY(-1px);
}

@keyframes pulse-border {
  0%, 100% { border-color: rgba(79,142,247,0.35); }
  50% { border-color: rgba(79,142,247,0.7); }
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.category-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 12px 8px 6px;
}

.template-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  margin-bottom: 2px;
  position: relative;
}

.template-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border);
}

.template-item.active {
  background: rgba(79,142,247,0.12);
  border-color: rgba(79,142,247,0.4);
}

.template-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--grad-primary);
  border-radius: 3px 0 0 3px;
}

body[dir="rtl"] .template-item.active::before {
  left: auto; right: 0;
  border-radius: 0 3px 3px 0;
}

.template-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.template-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.template-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 20px;
  font-size: 0.62rem;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: 0.5px;
}
.badge-resistive  { background: rgba(245,158,11,0.15); color: var(--accent-yellow); border: 1px solid rgba(245,158,11,0.3); }
.badge-reactive   { background: rgba(79,142,247,0.15); color: var(--accent-blue);   border: 1px solid rgba(79,142,247,0.3); }
.badge-mixed      { background: rgba(155,93,229,0.15); color: var(--accent-purple); border: 1px solid rgba(155,93,229,0.3); }
.badge-random     { background: rgba(0,212,255,0.15);  color: var(--accent-cyan);   border: 1px solid rgba(0,212,255,0.3); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
  gap: 12px;
}

.canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.canvas-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.canvas-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* SVG Canvas */
.circuit-canvas-wrapper {
  flex: 0 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  min-height: 280px;
  max-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.circuit-canvas-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(79,142,247,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79,142,247,0.03) 1px, transparent 1px);
  background-size: 30px 30px;
  pointer-events: none;
}

#circuit-svg {
  width: 100%;
  height: 100%;
  min-height: 260px;
  max-height: 330px;
}

.circuit-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.circuit-placeholder .ph-icon { font-size: 3rem; opacity: 0.3; }
.circuit-placeholder p { font-size: 0.85rem; max-width: 280px; line-height: 1.5; }

/* Components table */
.components-section {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.components-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.components-table-wrapper {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.components-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 3px;
  font-size: 0.8rem;
}

.components-table th {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 4px 12px;
  text-align: left;
}

body[dir="rtl"] .components-table th,
body[dir="rtl"] .components-table td {
  text-align: right;
}

.components-table td {
  padding: 8px 12px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.components-table td:first-child {
  border-left: 1px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.components-table td:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

body[dir="rtl"] .components-table td:first-child {
  border-left: none;
  border-right: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

body[dir="rtl"] .components-table td:last-child {
  border-right: none;
  border-left: 1px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.components-table tr:hover td { background: var(--bg-card-hover); }

.comp-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
}

.comp-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-r  { background: var(--accent-yellow); }
.dot-l  { background: var(--accent-blue); }
.dot-c  { background: var(--accent-cyan); }
.dot-vs { background: var(--accent-green); }

/* Inline value input */
.value-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  width: 90px;
  transition: border-color var(--transition);
}

.value-input:focus { outline: none; border-color: var(--accent-blue); }

.comp-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ============================================================
   RESULTS PANEL
   ============================================================ */
.results-panel {
  width: var(--results-w);
  min-width: var(--results-w);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.results-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.panel-section-header {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

.panel-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

.panel-section-body {
  padding: 10px 14px;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.result-row:last-child { border-bottom: none; }

.result-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.result-value {
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.result-value.highlight  { color: var(--accent-blue); }
.result-value.positive   { color: var(--accent-green); }
.result-value.warning    { color: var(--accent-yellow); }
.result-value.resonant   { color: var(--accent-cyan); }

.no-results {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Component sub-results */
.comp-result-item {
  margin-bottom: 8px;
  padding: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.comp-result-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-accent);
  font-family: var(--font-mono);
  margin-bottom: 4px;
}

.comp-result-data {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.comp-result-data span {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.comp-result-data span strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ============================================================
   PRACTICE QUESTIONS
   ============================================================ */
.questions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.question-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  transition: border-color var(--transition);
}

.question-item:hover { border-color: var(--border-hover); }

.question-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.question-number {
  width: 20px;
  height: 20px;
  background: var(--grad-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  margin-top: 1px;
}

.question-text {
  font-size: 0.78rem;
  color: var(--text-primary);
  line-height: 1.5;
  flex: 1;
}

.question-difficulty {
  font-size: 0.62rem;
  padding: 2px 6px;
  border-radius: 20px;
  font-weight: 700;
  flex-shrink: 0;
}
.diff-basic        { background: rgba(34,197,94,0.15);  color: var(--accent-green); }
.diff-intermediate { background: rgba(245,158,11,0.15); color: var(--accent-yellow); }
.diff-advanced     { background: rgba(239,68,68,0.15);  color: var(--accent-red); }

.question-solution {
  display: none;
  margin-top: 8px;
  padding: 10px;
  background: rgba(79,142,247,0.06);
  border: 1px solid rgba(79,142,247,0.2);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.7;
  font-family: var(--font-mono);
}

.question-solution.visible { display: block; animation: fadeSlide 0.25s ease; }
.question-solution .sol-answer { color: var(--accent-cyan); font-weight: 700; }
.question-solution .sol-step { display: block; margin-bottom: 3px; }

.question-footer {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 360px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.modal-field {
  margin-bottom: 14px;
}

.modal-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 600;
}

.modal-select,
.modal-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  transition: border-color var(--transition);
}

.modal-select:focus,
.modal-input:focus { outline: none; border-color: var(--accent-blue); }

.modal-select option { background: var(--bg-card); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3000;
}

body[dir="rtl"] .toast-container { right: auto; left: 24px; }

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 200px;
  max-width: 320px;
  animation: toastIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

.toast.removing { animation: toastOut 0.3s ease forwards; }

.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-success { border-color: rgba(34,197,94,0.4); }
.toast-success .toast-icon { color: var(--accent-green); }
.toast-warning { border-color: rgba(245,158,11,0.4); }
.toast-warning .toast-icon { color: var(--accent-yellow); }
.toast-error { border-color: rgba(239,68,68,0.4); }
.toast-error .toast-icon { color: var(--accent-red); }
.toast-info { border-color: rgba(79,142,247,0.4); }
.toast-info .toast-icon { color: var(--accent-blue); }

/* ============================================================
   FREQUENCY CONTROL
   ============================================================ */
.freq-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.freq-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  font-family: var(--font-mono);
}

.freq-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: right;
  width: 70px;
}

.freq-input:focus { outline: none; }

.freq-unit {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(30px); }
}

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.loading-shimmer {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
  background-size: 200% auto;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* SVG animations */
.svg-wire { stroke-dasharray: 1000; stroke-dashoffset: 1000; animation: drawWire 1s ease forwards; }
@keyframes drawWire {
  to { stroke-dashoffset: 0; }
}

.svg-component { opacity: 0; transform: scale(0.8); animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards; }
@keyframes popIn {
  to { opacity: 1; transform: scale(1); }
}

/* Glow on active component */
.comp-glow { filter: drop-shadow(0 0 6px rgba(79,142,247,0.6)); }

/* ============================================================
   SVG STYLES (inline circuit diagram)
   ============================================================ */
.circuit-svg-text {
  font-family: var(--font-mono);
  fill: var(--text-primary);
  font-size: 11px;
}

/* ============================================================
   BLUEPRINT WATERMARK
   ============================================================ */
.blueprint-credit {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 0.6rem;
  font-family: var(--font-mono);
  color: rgba(79,142,247,0.25);
  letter-spacing: 1px;
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
}

body[dir="rtl"] .blueprint-credit { right: auto; left: 12px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  :root { --results-w: 280px; --sidebar-w: 240px; }
}

@media (max-width: 860px) {
  .results-panel { display: none; }
  :root { --sidebar-w: 220px; }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .header-made-by { display: none; }
}

/* ============================================================
   DIVIDER / MISC
   ============================================================ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.tag-blue   { background: rgba(79,142,247,0.15); color: var(--accent-blue); border: 1px solid rgba(79,142,247,0.3); }
.tag-purple { background: rgba(155,93,229,0.15); color: var(--accent-purple); border: 1px solid rgba(155,93,229,0.3); }
.tag-green  { background: rgba(34,197,94,0.15);  color: var(--accent-green); border: 1px solid rgba(34,197,94,0.3); }
.tag-cyan   { background: rgba(0,212,255,0.15);  color: var(--accent-cyan);  border: 1px solid rgba(0,212,255,0.3); }

/* Flex utilities */
.flex          { display: flex; }
.flex-col      { display: flex; flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.hidden { display: none !important; }

/* ============================================================
   ADDITIONAL POLISH – appended
   ============================================================ */

/* Hide freq control by default; JS shows it for AC circuits */
#freq-control {
  display: none;
}

/* Results content scrollable */
.results-content {
  overflow-y: auto;
}

/* Active template left-border glow */
.template-item.active .template-name {
  color: var(--accent-blue);
}

/* Question solution monospace blocks */
.question-solution .sol-step {
  display: block;
  line-height: 1.8;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.question-solution .sol-answer {
  color: var(--accent-cyan);
  font-weight: 700;
  font-size: 0.78rem;
  margin-top: 2px;
}

/* Smooth SVG canvas transition */
#circuit-svg {
  transition: opacity 0.2s ease;
}

/* Random badge in sidebar for random circuit */
.template-item.random-item {
  border: 1px solid rgba(0,212,255,0.25);
  background: rgba(0,212,255,0.04);
}

/* Comp-table row animation */
.components-table tbody tr {
  animation: fadeSlide 0.2s ease forwards;
}

/* Freq control layout */
.freq-control {
  align-items: center;
}

/* Value input monospace */
.value-input {
  font-family: var(--font-mono);
  text-align: right;
}

body[dir="rtl"] .value-input {
  text-align: left;
}

/* Make modal label RTL friendly */
body[dir="rtl"] .modal-label {
  display: block;
  text-align: right;
}

/* Sidebar scrollbar */
.sidebar-list::-webkit-scrollbar { width: 3px; }
.sidebar-list::-webkit-scrollbar-thumb { background: var(--bg-elevated); }

/* Blueprint credit RTL */
body[dir="rtl"] .blueprint-credit {
  right: auto;
  left: 12px;
  text-align: left;
}

/* Panel section hover effect */
.panel-section {
  transition: border-color var(--transition);
}
.panel-section:hover {
  border-color: rgba(79,142,247,0.25);
}

/* Subtle circuit canvas grid dots overlay */
.circuit-canvas-wrapper::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(79,142,247,0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  opacity: 0.6;
}

/* results-body inner padding */
#results-body .result-row:first-child {
  padding-top: 0;
}

/* No circuit / no results messages */
.no-results {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

/* Generate questions button hover glow */
#btn-gen-questions:hover {
  box-shadow: 0 0 12px rgba(79,142,247,0.4);
}

/* Tooltip-style title on value input */
.value-input[title]:hover::after {
  content: attr(title);
  position: absolute;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.7rem;
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

/* Canvas wrapper min height on small screens */
@media (max-height: 700px) {
  .circuit-canvas-wrapper {
    min-height: 200px;
    max-height: 240px;
  }
  #circuit-svg {
    min-height: 190px;
    max-height: 230px;
  }
}
