/* ==========================================================
   CSC All Tools — Linear & Raycast Inspired Pro Design System
   Three-Layer Token Architecture • Obsidian Surfaces • Micro-Springs
   ========================================================== */

/* Layer 1: Primitive Tokens */
:root {
  --primitive-slate-950: #030712;
  --primitive-slate-900: #090e1a;
  --primitive-slate-850: #0e1526;
  --primitive-slate-800: #131c31;
  --primitive-slate-750: #18233d;
  --primitive-slate-700: #1e293b;
  --primitive-slate-600: #334155;
  --primitive-slate-500: #475569;
  --primitive-slate-400: #94a3b8;
  --primitive-slate-300: #cbd5e1;
  --primitive-slate-200: #e2e8f0;
  --primitive-slate-100: #f1f5f9;
  --primitive-white: #ffffff;

  --primitive-indigo-600: #4f46e5;
  --primitive-indigo-500: #6366f1;
  --primitive-indigo-400: #818cf8;
  --primitive-indigo-300: #a5b4fc;
  
  --primitive-emerald-600: #059669;
  --primitive-emerald-500: #10b981;
  --primitive-emerald-400: #34d399;

  --primitive-amber-600: #d97706;
  --primitive-amber-500: #f59e0b;
  --primitive-amber-400: #fbbf24;

  --primitive-purple-600: #7c3aed;
  --primitive-purple-500: #8b5cf6;
  --primitive-purple-400: #a78bfa;

  --primitive-cyan-500: #06b6d4;
  --primitive-rose-500: #f43f5e;

  /* Layer 2: Semantic Tokens */
  --canvas: var(--primitive-slate-950);
  --surface-0: #050811;
  --surface-1: #090e1a;
  --surface-2: #0e1526;
  --surface-3: #131c31;
  --surface-card: #0c1222;
  --surface-elevated: #16203b;
  --surface-hover: #1b2645;
  
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.20);
  --border-focus: var(--primitive-indigo-500);
  --border-glow: rgba(99, 102, 241, 0.45);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --text-inverse: #030712;

  --accent-primary: var(--primitive-indigo-500);
  --accent-primary-hover: var(--primitive-indigo-400);
  --accent-primary-active: var(--primitive-indigo-600);

  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Document Setup */
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "cv02" 1, "cv03" 1, "cv04" 1, "cv11" 1;
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  background-color: var(--canvas);
  background-image: 
    radial-gradient(ellipse 80% 50% at 50% -15%, rgba(99, 102, 241, 0.14), transparent 70%),
    radial-gradient(ellipse 50% 30% at 90% 15%, rgba(139, 92, 246, 0.08), transparent 60%),
    radial-gradient(ellipse 40% 25% at 10% 25%, rgba(16, 185, 129, 0.05), transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  transition: background 0.2s ease;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.55);
}
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.25) transparent;
}

/* Text Selection */
::selection {
  background: rgba(99, 102, 241, 0.85);
  color: #ffffff;
}

/* Accessible Focus Rings */
*:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ==========================================================
   Header & Command Bar (Linear / Raycast Style)
   ========================================================== */
.glass-header {
  background: rgba(5, 8, 17, 0.82);
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 4px 24px -1px rgba(0, 0, 0, 0.35);
}

.search-command-bar {
  background: rgba(14, 21, 38, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.09);
  transition: all 0.2s var(--ease-spring);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
}
.search-command-bar:focus-within {
  background: rgba(17, 26, 48, 0.95);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2), inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
}

/* Profile Chip Button */
.vle-profile-chip {
  background: rgba(14, 21, 38, 0.85);
  border: 1px solid rgba(99, 102, 241, 0.3);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.06), 0 4px 14px -2px rgba(79, 70, 229, 0.15);
  transition: all 0.2s var(--ease-spring);
}
.vle-profile-chip:hover {
  background: rgba(20, 31, 56, 0.95);
  border-color: var(--primitive-indigo-400);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.1), 0 6px 20px -2px rgba(99, 102, 241, 0.3);
  transform: translateY(-1px);
}
.vle-profile-chip:active {
  transform: scale(0.97);
}

/* ==========================================================
   Hero & Quick Ribbon
   ========================================================== */
.hero-container {
  background: linear-gradient(180deg, rgba(14, 21, 38, 0.8) 0%, rgba(9, 14, 26, 0.85) 100%);
  border: 1px solid var(--border-subtle);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.08), 0 16px 40px -8px rgba(0, 0, 0, 0.4);
}

.hero-headline {
  background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.03em;
}

.quick-chip {
  background: rgba(14, 21, 38, 0.8);
  border: 1px solid var(--border-subtle);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.04);
  transition: all 0.18s var(--ease-spring);
}
.quick-chip:hover {
  background: rgba(22, 33, 61, 0.95);
  border-color: rgba(99, 102, 241, 0.45);
  transform: translateY(-1.5px);
  box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(99, 102, 241, 0.2);
}
.quick-chip:active {
  transform: scale(0.96);
}

/* ==========================================================
   Segmented Category Tabs
   ========================================================== */
.segmented-control {
  background: rgba(9, 14, 26, 0.85);
  border: 1px solid var(--border-subtle);
  padding: 4px;
  border-radius: 18px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
}

.segmented-tab {
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.18s var(--ease-spring);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.segmented-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}
.segmented-tab.active {
  background: var(--primitive-indigo-600);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4), inset 0 1px 0 0 rgba(255, 255, 255, 0.2);
}
.segmented-tab.active-amber {
  background: var(--primitive-amber-500);
  color: #030712;
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4), inset 0 1px 0 0 rgba(255, 255, 255, 0.4);
}

/* ==========================================================
   Tool Cards (Grid)
   ========================================================== */
.tool-card {
  background: linear-gradient(180deg, rgba(14, 21, 38, 0.75) 0%, rgba(9, 14, 26, 0.85) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.06), 0 8px 24px -4px rgba(0, 0, 0, 0.35);
  transition: all 0.22s var(--ease-spring);
  will-change: transform, box-shadow;
  transform: translate3d(0, 0, 0);
  opacity: 0;
  animation: cardEntrance 0.32s var(--ease-spring) forwards;
}

.tool-card:hover {
  background: linear-gradient(180deg, rgba(19, 29, 52, 0.9) 0%, rgba(12, 18, 33, 0.95) 100%);
  border-color: rgba(99, 102, 241, 0.45);
  transform: translateY(-3px);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.12), 0 16px 36px -6px rgba(79, 70, 229, 0.22), 0 0 0 1px rgba(99, 102, 241, 0.25);
}

.tool-card:hover .tool-icon-wrapper {
  transform: scale(1.06);
  box-shadow: 0 8px 18px -2px rgba(99, 102, 241, 0.35);
}

.tool-card:hover .tool-arrow-icon {
  transform: translateX(4px);
  color: var(--primitive-indigo-400);
}

.tool-card:active {
  transform: scale(0.98);
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger Animation Delays */
.tool-card:nth-child(1) { animation-delay: 0.02s; }
.tool-card:nth-child(2) { animation-delay: 0.04s; }
.tool-card:nth-child(3) { animation-delay: 0.06s; }
.tool-card:nth-child(4) { animation-delay: 0.08s; }
.tool-card:nth-child(5) { animation-delay: 0.10s; }
.tool-card:nth-child(6) { animation-delay: 0.12s; }
.tool-card:nth-child(7) { animation-delay: 0.14s; }
.tool-card:nth-child(8) { animation-delay: 0.16s; }
.tool-card:nth-child(9) { animation-delay: 0.18s; }
.tool-card:nth-child(10) { animation-delay: 0.20s; }
.tool-card:nth-child(11) { animation-delay: 0.22s; }
.tool-card:nth-child(12) { animation-delay: 0.24s; }

/* ==========================================================
   Buttons & Interactive Elements
   ========================================================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s var(--ease-spring);
  min-height: 42px;
  user-select: none;
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.25), 0 4px 14px rgba(79, 70, 229, 0.35);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #818cf8 0%, #6366f1 100%);
  transform: translateY(-1.5px);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.35), 0 8px 22px rgba(79, 70, 229, 0.45);
}
.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.2);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(14, 21, 38, 0.85);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s var(--ease-spring);
  min-height: 42px;
  user-select: none;
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.04);
}
.btn-secondary:hover {
  background: rgba(22, 33, 61, 0.95);
  color: #ffffff;
  border-color: var(--border-medium);
  transform: translateY(-1px);
}
.btn-secondary:active {
  transform: scale(0.97);
}

.btn-success {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s var(--ease-spring);
  min-height: 42px;
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.25), 0 4px 14px rgba(16, 185, 129, 0.35);
}
.btn-success:hover {
  background: linear-gradient(180deg, #34d399 0%, #10b981 100%);
  transform: translateY(-1.5px);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.35), 0 8px 22px rgba(16, 185, 129, 0.45);
}
.btn-success:active {
  transform: scale(0.97);
}

/* ==========================================================
   Dropzones, Textareas & Form Controls
   ========================================================== */
.dropzone {
  border: 2px dashed rgba(99, 102, 241, 0.3);
  border-radius: 18px;
  padding: 2rem 1.5rem;
  text-align: center;
  background: rgba(9, 14, 26, 0.6);
  transition: all 0.2s var(--ease-spring);
  cursor: pointer;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primitive-indigo-400);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.2), inset 0 0 20px rgba(99, 102, 241, 0.05);
}

.tool-textarea {
  width: 100%;
  min-height: 150px;
  padding: 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  font-family: 'Inter', monospace;
  font-size: 13px;
  resize: vertical;
  background: rgba(9, 14, 26, 0.85);
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}
.tool-textarea:focus {
  border-color: var(--border-focus);
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2), inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Custom Numeric Steppers */
.numeric-stepper-wrapper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  background: rgba(9, 14, 26, 0.85);
  overflow: hidden;
  height: 42px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}
.numeric-stepper-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 40px;
  height: 100%;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.numeric-stepper-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}
.numeric-stepper-input {
  width: 55px;
  text-align: center;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13px;
  outline: none;
  font-family: 'JetBrains Mono', monospace;
}

/* Hide spin buttons */
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;
}

/* Checkerboard Background for Canvas / Transparent Images */
.bg-checkered {
  background-image:
    linear-gradient(45deg, rgba(30, 41, 59, 0.5) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(30, 41, 59, 0.5) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(30, 41, 59, 0.5) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(30, 41, 59, 0.5) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* Micro-Animations & Star Burst */
@keyframes starBurst {
  0% { transform: scale(1); }
  35% { transform: scale(1.4) rotate(18deg); filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.8)); }
  65% { transform: scale(0.88) rotate(-10deg); }
  100% { transform: scale(1) rotate(0); }
}
.star-active {
  animation: starBurst 0.4s var(--ease-spring);
}

@keyframes toastSpring {
  0% { transform: translateY(35px) scale(0.92); opacity: 0; }
  60% { transform: translateY(-4px) scale(1.02); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes profileGlow {
  0%, 100% {
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.3), 0 0 0 1px rgba(99, 102, 241, 0.4);
  }
  50% {
    box-shadow: 0 0 24px rgba(99, 102, 241, 0.6), 0 0 0 2px rgba(129, 140, 248, 0.8);
  }
}
.profile-badge-highlight {
  animation: profileGlow 2.8s ease-in-out infinite;
}

/* Skeleton Loading Shimmer */
.skeleton {
  background: linear-gradient(90deg, #0f172a 25%, #1e293b 50%, #0f172a 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 12px;
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Mobile & Touch Adjustments */
@media (max-width: 640px) {
  .btn-primary, .btn-secondary, .btn-success, .segmented-tab {
    min-height: 44px;
  }
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Print Optimization */
@media print {
  @page { size: A4 portrait; margin: 0; }
  body { background: white !important; color: black !important; }
  header, footer, #offline-banner, #toast, .segmented-control, .btn-primary, .btn-secondary { display: none !important; }
  #workspace { padding: 0 !important; }
  canvas { max-width: 100% !important; box-shadow: none !important; }
}
