/* ============================================
   DevToolBox - Main Stylesheet
   ============================================ */

:root {
  /* Colors - Dark Theme */
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d2e;
  --bg-card: #1e2139;
  --bg-card-hover: #252949;
  --bg-input: #16182b;
  --bg-toolbar: #1a1d2e;

  --text-primary: #e8eaed;
  --text-secondary: #9aa0b0;
  --text-muted: #5f6578;
  --text-accent: #7c8cff;

  --border-color: #2a2d45;
  --border-hover: #3d4170;

  --accent-primary: #6366f1;
  --accent-primary-hover: #5457e5;
  --accent-secondary: #22d3ee;
  --accent-green: #34d399;
  --accent-red: #f87171;
  --accent-orange: #fb923c;

  --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 32px rgba(0,0,0,0.5);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', sans-serif;

  --transition: 0.2s ease;
}

/* Light Theme */
[data-theme="light"] {
  --bg-primary: #f8f9fc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f1f8;
  --bg-input: #f0f1f8;
  --bg-toolbar: #f0f1f8;

  --text-primary: #1a1d2e;
  --text-secondary: #5f6578;
  --text-muted: #9aa0b0;
  --text-accent: #4f46e5;

  --border-color: #e2e4ef;
  --border-hover: #c4c8db;

  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-secondary: #0891b2;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

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

/* ============================================
   Header / Nav
   ============================================ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.logo:hover { color: var(--accent-primary); }

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: white;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.nav-link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  background: none;
  border: none;
  font-family: inherit;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

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

/* Language Switcher */
.lang-switch {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.lang-btn {
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  transition: var(--transition);
  font-family: inherit;
}

.lang-btn.active {
  background: var(--accent-primary);
  color: white;
}

.lang-btn:hover:not(.active) { color: var(--text-primary); }

/* Theme Toggle */
.theme-toggle {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--transition);
}

.theme-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* ============================================
   Hero Section
   ============================================ */
.hero {
  text-align: center;
  padding: 80px 24px 60px;
  max-width: 800px;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* ============================================
   Features Section
   ============================================ */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 800px;
  margin: -20px auto 48px;
  padding: 0 24px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  transition: var(--transition);
}

.feature-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.feature-icon {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.feature-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.feature-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ============================================
   Tools Grid
   ============================================ */
.section-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 32px;
  color: var(--text-primary);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  opacity: 0;
  transition: var(--transition);
}

.tool-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.tool-card:hover::before { opacity: 1; }

.tool-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--bg-input), var(--bg-card));
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 16px;
}

.tool-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.tool-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ============================================
   Tool Page (inside SPA)
   ============================================ */
.tool-page {
  display: none;
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.tool-page.active { display: block; }

.tool-header {
  margin-bottom: 28px;
}

.tool-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.tool-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  cursor: pointer;
  margin-bottom: 20px;
  transition: var(--transition);
  font-family: inherit;
}

.back-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* ============================================
   Tool UI Components
   ============================================ */
.tool-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.tool-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 8px;
}

.tool-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tool-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tool-content {
  padding: 20px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
}

.btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
  color: white;
}

.btn-success {
  background: var(--accent-green);
  color: #0f1117;
  border-color: var(--accent-green);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

/* Textarea / Input */
.tool-textarea {
  width: 100%;
  min-height: 200px;
  padding: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
  resize: vertical;
  transition: var(--transition);
  outline: none;
}

.tool-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

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

.tool-input {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition);
  font-family: var(--font-mono);
}

.tool-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

/* Label */
.tool-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.tool-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

/* Split Layout */
.split-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.split-layout .split-pane {
  display: flex;
  flex-direction: column;
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-badge.success {
  background: rgba(52,211,153,0.15);
  color: var(--accent-green);
}

.status-badge.error {
  background: rgba(248,113,113,0.15);
  color: var(--accent-red);
}

/* ============================================
   UUID Generator Specific
   ============================================ */
.uuid-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 0;
}

.uuid-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.uuid-controls input[type="number"] {
  width: 70px;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
}

.uuid-controls select {
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
}

.uuid-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.uuid-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.uuid-item .copy-btn {
  padding: 3px 10px;
  font-size: 0.75rem;
  opacity: 0.6;
  transition: var(--transition);
}

.uuid-item:hover .copy-btn { opacity: 1; }

/* Toggle Switch */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-color);
  border-radius: 20px;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent-primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

/* ============================================
   Regex Tester Specific
   ============================================ */
.regex-matches {
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  min-height: 60px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-all;
}

.regex-match-highlight {
  background: rgba(99,102,241,0.3);
  border-radius: 2px;
  padding: 1px 0;
}

.regex-group-highlight {
  background: rgba(34,211,238,0.2);
  border-radius: 2px;
}

.regex-match-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ============================================
   SEO Content (Tool tutorial & FAQ)
   ============================================ */
.seo-content {
  max-width: 800px;
  margin: 40px auto 20px;
  padding: 0 4px;
}

.seo-content h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 32px 0 12px;
  color: var(--text-primary);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.seo-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 24px 0 10px;
  color: var(--text-primary);
}

.seo-content p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.seo-content ol, .seo-content ul {
  padding-left: 20px;
  margin-bottom: 16px;
}

.seo-content li {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.seo-content li strong {
  color: var(--text-primary);
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 12px;
  transition: var(--transition);
}

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

.faq-item h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.faq-item p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

.related-tools {
  margin-top: 28px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.related-tools span {
  font-weight: 600;
  margin-right: 8px;
}

.related-tools a {
  display: inline-block;
  padding: 4px 12px;
  margin: 2px 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--accent-primary);
  font-size: 0.85rem;
  text-decoration: none;
  transition: var(--transition);
}

.related-tools a:hover {
  border-color: var(--accent-primary);
  background: rgba(99,102,241,0.1);
}

.regex-cheatsheet {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 2;
  color: var(--text-accent);
  margin-bottom: 20px;
}

.regex-cheatsheet code {
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* ============================================
   Footer
   ============================================ */
.footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer p { margin-bottom: 4px; }

/* ============================================
   Ad Placeholder
   ============================================ */
.ad-placeholder {
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 20px 0;
}

.ad-placeholder-top {
  max-width: 728px;
  margin: 0 auto 32px;
}

.ad-placeholder-side {
  /* For future sidebar ads */
}

/* ============================================
   Toast Notification
   ============================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--accent-primary);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  z-index: 999;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .hero { padding: 48px 20px 40px; }

  .features {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .tools-grid {
    grid-template-columns: 1fr;
    padding: 0 16px 60px;
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .tool-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .tool-toolbar-left,
  .tool-toolbar-right {
    justify-content: center;
  }

  .header-inner {
    padding: 0 16px;
  }

  .nav-links {
    gap: 4px;
  }

  .logo span.text { display: none; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.6rem; }
  .tool-content { padding: 14px; }
  .uuid-controls { flex-direction: column; align-items: flex-start; }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.tool-page.active {
  animation: fadeIn 0.3s ease;
}

.tool-card {
  animation: fadeIn 0.4s ease backwards;
}

.tool-card:nth-child(1) { animation-delay: 0.05s; }
.tool-card:nth-child(2) { animation-delay: 0.1s; }
.tool-card:nth-child(3) { animation-delay: 0.15s; }
.tool-card:nth-child(4) { animation-delay: 0.2s; }
.tool-card:nth-child(5) { animation-delay: 0.25s; }
