/* ═══════════════════════════════════════════════════════════════════════════════
   Liam's Toolbox — Dark Mode Design System
   Modern coder aesthetic, gradient accents, glass morphism
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
  /* ─── Navigation (shared across all pages) ────────────────────────────── */
.top-nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-primary);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top, 0px));
}
.nav-inner {
  max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
}
.nav-brand { font-weight: 700; font-size: 15px; color: var(--text-primary); }
.nav-back { color: var(--accent-primary); font-size: 14px; text-decoration: none; }

/* Theme-able via shared/theme.js — these are defaults (dark) */
  --bg: #0a0a0f;
  --surface: #16161f;
  --surface-elevated: #1e1e2a;
  --text: #e8e8ed;
  --text-secondary: #8888a0;
  --border: rgba(255,255,255,0.06);
  --border-subtle: rgba(255,255,255,0.12);
  --accent-primary: #6366f1;
  --accent-danger: #ef4444;
  --accent-warn: #f59e0b;
  --input-bg: #1a1a25;
  --input-border: rgba(255,255,255,0.06);

  /* Legacy aliases for backward compat */
  --bg-primary: var(--bg);
  --bg-secondary: var(--surface);
  --bg-card: var(--surface);
  --bg-card-hover: var(--surface-elevated);
  --bg-input: var(--input-bg);
  --bg-elevated: var(--surface-elevated);
  --text-primary: var(--text);
  --text-muted: var(--text-secondary);
  --accent-1: var(--accent-primary);
  --accent-2: #a855f7;
  --accent-3: #06b6d4;
  --accent-green: #22c55e;
  --accent-orange: var(--accent-warn);
  --accent-red: var(--accent-danger);
  --border-focus: rgba(99,102,241,0.5);

  --gradient-main: linear-gradient(135deg, #6366f1, #a855f7, #06b6d4);
  --gradient-warm: linear-gradient(135deg, #f59e0b, #ef4444);
  --gradient-cool: linear-gradient(135deg, #06b6d4, #6366f1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 20px rgba(99,102,241,0.15);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ─── Typography ─────────────────────────────────────────────────────────── */

.heading-xl { font-size: 28px; font-weight: 800; line-height: 1.2; }
.heading-lg { font-size: 22px; font-weight: 700; line-height: 1.3; }
.heading-md { font-size: 18px; font-weight: 700; line-height: 1.3; }
.heading-sm { font-size: 15px; font-weight: 600; line-height: 1.4; }
.body { font-size: 15px; line-height: 1.5; }
.body-sm { font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.caption { font-size: 11px; line-height: 1.4; color: var(--text-muted); }
.label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
}

.card-glow {
  border: 1px solid rgba(99,102,241,0.15);
  box-shadow: var(--shadow-glow);
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(99,102,241,0.15), transparent, rgba(168,85,247,0.1));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  min-height: 48px;
  padding: 12px 20px;
  font-size: 15px;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  font-family: inherit;
}

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

.btn-primary {
  background: var(--gradient-main);
  color: white;
  box-shadow: 0 4px 15px rgba(99,102,241,0.3);
}

.btn-primary:active {
  box-shadow: 0 2px 8px rgba(99,102,241,0.2);
}

.btn-magic {
  background: var(--gradient-main);
  background-size: 200% 200%;
  animation: gradientShift 4s ease infinite;
  color: white;
  font-weight: 700;
  box-shadow: 0 4px 20px rgba(99,102,241,0.35);
  letter-spacing: 0.3px;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

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

.btn-ghost {
  background: transparent;
  color: var(--accent-1);
}

.btn-sm {
  min-height: 36px;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

/* ─── Inputs ─────────────────────────────────────────────────────────────── */

.input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: inherit;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

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

.input:focus {
  outline: none;
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2), 0 0 20px rgba(99,102,241,0.1);
}

.textarea { resize: none; min-height: 100px; }

/* ─── Chips / Pills ──────────────────────────────────────────────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  min-height: 36px;
  font-family: inherit;
}

.chip.active {
  background: rgba(99,102,241,0.15);
  border-color: var(--accent-1);
  color: var(--accent-1);
  box-shadow: 0 0 12px rgba(99,102,241,0.15);
}

.chip:active { transform: scale(0.95); }

/* ─── Tab Bar ────────────────────────────────────────────────────────────── */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  opacity: 0.95;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  padding-bottom: var(--safe-bottom);
  display: flex;
  justify-content: space-around;
  z-index: 100;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 0 10px;
  min-width: 64px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s ease;
}

.tab-item.active { color: var(--accent-1); }
.tab-icon { font-size: 22px; line-height: 1; }

/* ─── Bottom Sheet ───────────────────────────────────────────────────────── */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
  z-index: 201;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 85vh;
  overflow-y: auto;
}

.sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 2px;
  margin: 0 auto 16px;
}

/* ─── Badge ──────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-free {
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
}
.badge-pro {
  background: rgba(168,85,247,0.15);
  color: #a855f7;
}

/* ─── Utility ────────────────────────────────────────────────────────────── */

.icon-mask { border-radius: 22.37%; overflow: hidden; }

.sparkle { animation: sparkle 2s ease-in-out infinite; }
@keyframes sparkle {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}

.fade-in { animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.glass {
  background: rgba(16,16,24,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Selection */
::selection { background: rgba(99,102,241,0.3); color: white; }

/* Safe area padding for content behind tab bar */
.has-tab-bar { padding-bottom: calc(80px + var(--safe-bottom)); }

/* ─── Desktop Responsive ─────────────────────────────────────────────────── */

@media (min-width: 768px) {
  .heading-xl { font-size: 32px; }

  .desktop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px;
  }

  .desktop-grid > * { min-width: 0; }

  /* Hide tab bar on desktop */
  .tab-bar { display: none; }
  .has-tab-bar { padding-bottom: 40px; }

  /* Show all screens on desktop */
  .desktop-show { display: block !important; }
}

@media (min-width: 1024px) {
  .desktop-grid {
    grid-template-columns: 1fr 1fr 1fr;
    max-width: 1200px;
    gap: 24px;
  }
}

/* ─── Loading spinner ────────────────────────────────────────────────────── */

.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(10,10,15,0.9);
  display: none; align-items: center; justify-content: center;
  flex-direction: column; gap: 12px; z-index: 150;
}
.loading-overlay.active { display: flex; }
.loading-overlay .spinner { font-size: 36px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty state ────────────────────────────────────────────────────────── */

.empty-state { text-align: center; padding: 48px 20px; }
.empty-state .emoji { font-size: 48px; margin-bottom: 12px; }

/* ═══════════════════════════════════════════════════════════════════════════════
   Theme Selector
   ═══════════════════════════════════════════════════════════════════════════════ */
.theme-selector {
  position: relative;
  margin-left: auto;
}
.theme-toggle {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  transition: border-color 0.2s;
}
.theme-toggle:hover { border-color: var(--accent-primary); }
.theme-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  min-width: 120px;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.theme-selector.open .theme-dropdown { display: block; }
.theme-opt {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.theme-opt:hover { background: rgba(99,102,241,0.1); }
.theme-opt.active { color: var(--accent-primary); background: rgba(99,102,241,0.08); }

/* ═══════════════════════════════════════════════════════════════════════════════
   Magical Gradient Borders
   ═══════════════════════════════════════════════════════════════════════════════ */
.gradient-border {
  position: relative;
  border: none;
  border-radius: var(--radius-lg);
  padding: 2px;
  background: linear-gradient(135deg, #6366f1, #a855f7, #06b6d4, #22c55e, #f59e0b, #6366f1);
  background-size: 300% 300%;
  animation: gradient-shimmer 4s ease infinite;
}
.gradient-border > * {
  background: var(--surface);
  border-radius: calc(var(--radius-lg) - 2px);
}
@keyframes gradient-shimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Glow effect on hover for gradient-bordered elements */
.gradient-border:hover {
  box-shadow: 0 0 20px rgba(99,102,241,0.2), 0 0 40px rgba(168,85,247,0.1);
}

/* Gradient text */
.gradient-text {
  background: linear-gradient(135deg, #6366f1, #a855f7, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Gradient button */
.btn-gradient {
  background: linear-gradient(135deg, #6366f1, #a855f7, #06b6d4);
  background-size: 200% 200%;
  animation: gradient-shimmer 3s ease infinite;
  border: none;
  color: #fff;
  font-weight: 700;
}
.btn-gradient:hover {
  box-shadow: 0 4px 20px rgba(99,102,241,0.3);
  transform: translateY(-1px);
}
