/* ==========================================================================
   VeriLearn Design System & Base Styles
   Target: Mobile-first design, modern Dark Theme default, RTL & LTR support
   ========================================================================== */

:root {
  /* Color Palette - Dark Theme Default */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-tertiary: #1f293d;
  --bg-card: #182234;
  --bg-card-hover: #212d45;
  --bg-input: #0f172a;
  
  /* Accent Colors */
  --accent-primary: #6366f1;       /* Indigo */
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #06b6d4;     /* Cyan */
  --accent-secondary-hover: #0891b2;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  --accent-gradient-glow: 0 4px 20px rgba(99, 102, 241, 0.35);

  /* Status Colors */
  --color-success: #10b981;        /* Emerald */
  --color-success-bg: rgba(16, 185, 129, 0.12);
  --color-warning: #f59e0b;        /* Amber */
  --color-warning-bg: rgba(245, 158, 11, 0.12);
  --color-error: #ef4444;          /* Red */
  --color-error-bg: rgba(239, 68, 68, 0.12);
  --color-info: #3b82f6;           /* Blue */
  --color-info-bg: rgba(59, 130, 246, 0.12);

  /* Text Colors */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  /* Borders & Dividers */
  --border-color: #1e293b;
  --border-color-light: #334155;
  --border-color-active: #6366f1;

  /* Typography */
  --font-family-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-mono: 'Fira Code', monospace;

  /* Spacing System */
  --space-xs: 0.25rem;  /* 4px */
  --space-sm: 0.5rem;   /* 8px */
  --space-md: 0.75rem;  /* 12px */
  --space-lg: 1rem;     /* 16px */
  --space-xl: 1.5rem;   /* 24px */
  --space-2xl: 2rem;    /* 32px */

  /* Border Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout Constants */
  --header-height: 60px;
  --nav-height: 65px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Light Theme Variables Override */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f1f5f9;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --border-color: #e2e8f0;
  --border-color-light: #cbd5e1;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family-sans);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Code Snippet Formatting Fix for Hebrew RTL */
code, pre, kbd, samp, .code-inline {
  font-family: var(--font-family-mono) !important;
  direction: ltr !important;
  unicode-bidi: isolate !important;
  text-align: left !important;
}

code, .code-inline {
  background: rgba(99, 102, 241, 0.15);
  color: #38bdf8;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  border: 1px solid rgba(56, 189, 248, 0.2);
  display: inline-block;
  vertical-align: middle;
}

pre {
  background: #0d1117;
  color: #e6edf3;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  margin: var(--space-md) 0;
  line-height: 1.45;
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: none;
  display: block;
}

/* App View Wrapper */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-primary);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

#view-container {
  flex: 1;
  padding-top: calc(var(--header-height) + var(--space-md));
  padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + var(--space-lg));
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
  overflow-y: auto;
}

/* Header Bar Layout */
#top-bar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  height: var(--header-height);
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  z-index: 100;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  font-size: 1.25rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.icon-btn:active {
  transform: scale(0.92);
  background: var(--bg-tertiary);
}

/* Bottom Navigation Bar Layout */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  height: calc(var(--nav-height) + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background: rgba(17, 24, 39, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
  transition: var(--transition-fast);
}

.nav-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  transition: var(--transition-fast);
}

.nav-item.active {
  color: var(--accent-primary);
}

.nav-item.active svg {
  transform: translateY(-2px);
  stroke: var(--accent-primary);
  filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.4));
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-normal);
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:active {
  transform: scale(0.98);
  border-color: var(--border-color-active);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--transition-bounce);
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: var(--accent-gradient-glow);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: var(--space-xs) var(--space-md);
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

/* Badges & Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-error {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.badge-accent {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
}

/* Progress Bar */
.progress-container {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

/* HDLBits Style ModelSim Console Box */
.modelsim-console {
  background: #f8fafc;
  color: #1e293b;
  border: 1.5px solid #60a5fa;
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-family-mono);
  font-size: 0.78rem;
  line-height: 1.4;
  max-height: 180px;
  overflow-y: auto;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  margin-bottom: var(--space-md);
}

[data-theme="dark"] .modelsim-console {
  background: #0f172a;
  color: #cbd5e1;
  border-color: #3b82f6;
}
