/* ============================================
   THE BIG BIN TOOLBOX — Design System
   ============================================ */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Outfit:wght@400;500;600;700;800;900&display=swap');

/* --- Design Tokens --- */
:root {
  /* Base Colors */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --bg-glass: rgba(255, 255, 255, 0.05);
  --bg-glass-heavy: rgba(255, 255, 255, 0.08);

  /* Text Colors */
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;
  --text-accent: var(--accent);

  /* Accent Colors — overridden per tool page */
  --accent: #00D4FF;
  --accent-dim: rgba(0, 212, 255, 0.15);
  --accent-glow: rgba(0, 212, 255, 0.3);

  /* Tool-Specific Accent Presets */
  --color-word-unscrambler: #00D4FF;
  --color-sleep-calculator: #8B5CF6;
  --color-password-generator: #22C55E;
  --color-qr-code: #EC4899;
  --color-unit-converter: #F59E0B;
  --color-color-picker: #EC4899;
  --color-json-formatter: #06B6D4;
  --color-word-counter: #F97316;
  --color-lorem-ipsum: #EAB308;
  --color-mortgage-calc: #10B981;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.1);
  --border-accent: var(--accent-dim);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-dim);

  /* Spacing (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --space-10: 128px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;
  --text-5xl: 3.5rem;
  --text-6xl: 4.5rem;

  /* Transitions */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;

  /* Z-index layers */
  --z-canvas: 0;
  --z-content: 10;
  --z-header: 100;
  --z-modal: 1000;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
a:hover { color: var(--text-primary); }

code, pre {
  font-family: var(--font-mono);
}

/* --- Utility Classes --- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.container--narrow { max-width: 800px; }
.container--wide { max-width: 1440px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* --- Glass Card --- */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--duration-normal) var(--ease-out);
}

.glass-card:hover {
  background: var(--bg-glass-heavy);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-5);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  text-transform: none;
  letter-spacing: 0.01em;
}

.btn--primary {
  background: var(--accent);
  color: var(--bg-primary);
  box-shadow: 0 0 20px var(--accent-dim);
}
.btn--primary:hover {
  box-shadow: 0 0 30px var(--accent-glow);
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.btn--secondary {
  background: var(--bg-glass-heavy);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
}
.btn--secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent);
}

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

.btn--lg {
  font-size: var(--text-base);
  padding: var(--space-4) var(--space-7);
  border-radius: var(--radius-lg);
}

/* --- Input Fields --- */
.input-field {
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--text-base);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-glass);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: all var(--duration-fast) var(--ease-out);
  outline: none;
}

.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-field::placeholder {
  color: var(--text-muted);
}

textarea.input-field {
  resize: vertical;
  min-height: 120px;
}

/* --- Labels & Form Groups --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Toggle Switch --- */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  cursor: pointer;
  border: 1px solid var(--border-medium);
  transition: background var(--duration-fast);
}

.toggle.active {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform var(--duration-fast) var(--ease-spring);
}

.toggle.active::after {
  transform: translateX(20px);
}

/* --- Badge / Tag --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-full);
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
}

/* --- Section Headers --- */
.section-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.section-header h2 {
  margin-bottom: var(--space-3);
}

.section-header p {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  max-width: 600px;
  margin: 0 auto;
}

/* --- Tool Page Layout --- */
.tool-page {
  position: relative;
  min-height: 100vh;
}

.tool-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-canvas);
  pointer-events: none;
}

.tool-content {
  position: relative;
  z-index: var(--z-content);
  padding: var(--space-7) 0;
}

.tool-header {
  text-align: center;
  padding: var(--space-8) 0 var(--space-7);
}

.tool-header h1 {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-3);
}

.tool-header p {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  max-width: 600px;
  margin: 0 auto;
}

.tool-main {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--space-6);
  align-items: start;
}

.tool-main--full {
  grid-template-columns: 1fr;
}

.tool-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  position: sticky;
  top: var(--space-6);
}

/* --- Back to Toolbox Link --- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding: var(--space-4) 0;
  transition: color var(--duration-fast);
}
.back-link:hover { color: var(--accent); }
.back-link::before { content: '←'; }

/* --- Footer --- */
.site-footer {
  margin-top: var(--space-9);
  padding: var(--space-7) 0;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.site-footer a { color: var(--text-secondary); }
.site-footer a:hover { color: var(--accent); }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .tool-main {
    grid-template-columns: 1fr;
  }
  .tool-sidebar {
    position: static;
  }
}

@media (max-width: 768px) {
  h1 { font-size: var(--text-4xl); }
  h2 { font-size: var(--text-2xl); }
  .tool-header h1 { font-size: var(--text-3xl); }
  .container { padding: 0 var(--space-4); }
}

@media (max-width: 480px) {
  h1 { font-size: var(--text-3xl); }
  .tool-header h1 { font-size: var(--text-2xl); }
  .glass-card { padding: var(--space-4); }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Selection --- */
::selection {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ==========================================================================
   Language Selector (Global i18n)
   ========================================================================== */

.lang-selector-wrapper {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  font-family: var(--font-primary);
}

.lang-selector-btn {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 16px;
  border-radius: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition-bounce);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.lang-selector-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 250px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.lang-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-search {
  margin-bottom: 12px;
}

.lang-search input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s;
}

.lang-search input:focus {
  border-color: var(--accent-blue);
  background: rgba(255, 255, 255, 0.1);
}

.lang-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 300px;
  overflow-y: auto;
}

.lang-list::-webkit-scrollbar {
  width: 6px;
}
.lang-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.lang-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
}

.lang-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.lang-flag {
  font-size: 1.2rem;
}

.lang-name {
  font-size: 0.9rem;
  font-weight: 500;
}
