/* ============================================
   AtuinTools - Modern Developer Tools
   Fast, clean, professional design
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --color-primary: #6366f1;
  --color-primary-dark: #4f46e5;
  --color-primary-light: #818cf8;
  --color-accent: #0ea5e9;
  --color-accent-dark: #0284c7;
  --color-success: #10b981;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --color-bg: #f8fafc;
  --color-bg-alt: #f1f5f9;
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.08), 0 8px 10px -6px rgba(0,0,0,.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --max-width: 1200px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-dark);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.main-content {
  flex: 1;
}

/* ============================================
   HEADER / NAVIGATION
   ============================================ */
.header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,.92);
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: .625rem;
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -.02em;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 900;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav a {
  color: var(--color-text-secondary);
  font-size: .9rem;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.nav a:hover,
.nav a.active {
  color: var(--color-primary);
}

.nav-mobile-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
  cursor: pointer;
}

.nav-mobile-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: var(--transition-fast);
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero {
  padding: 5rem 0 4rem;
  text-align: center;
  background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-bg) 100%);
}

.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -.03em;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--color-text) 0%, var(--color-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.2rem;
  color: var(--color-text-secondary);
  max-width: 600px;
  margin: 0 auto 2rem;
  line-height: 1.7;
}

.hero-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.hero-badge {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.hero-badge svg {
  width: 18px;
  height: 18px;
  color: var(--color-success);
}

/* ============================================
   TOOL CARDS GRID
   ============================================ */
.tools-section {
  padding: 3rem 0 5rem;
}

.section-header {
  text-align: center;
  margin-bottom: 3rem;
}

.section-header h2 {
  margin-bottom: .5rem;
}

.section-header p {
  color: var(--color-text-secondary);
  font-size: 1.05rem;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.tool-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}

.tool-card:hover {
  border-color: var(--color-primary-light);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  color: inherit;
}

.tool-card-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  font-size: 1.5rem;
}

.tool-card-icon.json {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #d97706;
}

.tool-card-icon.format {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #2563eb;
}

.tool-card-icon.encode {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #059669;
}

.tool-card-icon.convert {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  color: #7c3aed;
}

.tool-card-icon.generate {
  background: linear-gradient(135deg, #fce7f3, #fbcfe8);
  color: #db2777;
}

.tool-card-icon.compare {
  background: linear-gradient(135deg, #cffafe, #a5f3fc);
  color: #0891b2;
}

.tool-card h3 {
  font-size: 1.15rem;
  margin-bottom: .5rem;
  font-weight: 700;
}

.tool-card p {
  color: var(--color-text-secondary);
  font-size: .9rem;
  line-height: 1.6;
  flex: 1;
}

.tool-card-tag {
  display: inline-block;
  margin-top: 1rem;
  padding: .25rem .75rem;
  background: var(--color-bg-alt);
  border-radius: 100px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.tool-card-arrow {
  position: absolute;
  top: 2rem;
  right: 2rem;
  color: var(--color-text-muted);
  transition: all var(--transition-base);
}

.tool-card:hover .tool-card-arrow {
  color: var(--color-primary);
  transform: translateX(4px);
}

/* ============================================
   PRIVACY NOTICE
   ============================================ */
.privacy-notice {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}

.privacy-notice svg {
  width: 20px;
  height: 20px;
  color: var(--color-success);
  flex-shrink: 0;
  margin-top: 2px;
}

.privacy-notice-text {
  font-size: .875rem;
  color: #166534;
  line-height: 1.5;
}

.privacy-notice-text strong {
  font-weight: 700;
}

/* ============================================
   TOOL PAGE LAYOUT
   ============================================ */
.tool-page-header {
  padding: 2rem 0 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.tool-page-breadcrumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--color-text-muted);
  margin-bottom: .75rem;
}

.tool-page-breadcrumb a {
  color: var(--color-text-secondary);
}

.tool-page-breadcrumb span {
  color: var(--color-text-muted);
}

.tool-page-title {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.tool-page-title h1 {
  font-size: 1.75rem;
}

.tool-page-title p {
  color: var(--color-text-secondary);
  margin-top: .25rem;
  font-size: .95rem;
}

.tool-workspace {
  padding: 2rem 0 4rem;
}

/* ============================================
   JSON PRETTIFIER SPECIFIC
   ============================================ */
.json-toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  flex-wrap: wrap;
}

.json-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
  min-height: 500px;
}

.json-panel {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
}

.json-panel:first-child {
  border-right: 1px solid var(--color-border);
}

.json-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.json-panel-stats {
  font-weight: 400;
  font-size: .75rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--color-text-muted);
}

.json-input {
  width: 100%;
  flex: 1;
  padding: 1rem;
  border: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: .875rem;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  tab-size: 2;
}

.json-input::placeholder {
  color: var(--color-text-muted);
}

.json-output {
  flex: 1;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: .875rem;
  line-height: 1.7;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: #1e1e2e;
  color: #cdd6f4;
}

/* JSON Syntax Highlighting */
.json-key { color: #89b4fa; }
.json-string { color: #a6e3a1; }
.json-number { color: #fab387; }
.json-boolean { color: #cba6f7; }
.json-null { color: #f38ba8; }
.json-bracket { color: #cdd6f4; }
.json-comma { color: #6c7086; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1rem;
  font-size: .85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  color: #fff;
}

.btn-secondary {
  background: var(--color-bg-alt);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.btn-success {
  background: var(--color-success);
  color: #fff;
}

.btn-success:hover {
  background: #059669;
  color: #fff;
}

.btn-danger {
  background: transparent;
  color: var(--color-error);
}

.btn-danger:hover {
  background: #fef2f2;
}

.btn-icon {
  padding: .5rem;
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: var(--color-border);
}

.indent-select {
  padding: .5rem .75rem;
  font-size: .85rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  outline: none;
}

.indent-select:focus {
  border-color: var(--color-primary-light);
}

/* --- Status Bar --- */
.json-status {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .625rem 1rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-size: .8rem;
  color: var(--color-text-secondary);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: .375rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-muted);
}

.status-dot.valid {
  background: var(--color-success);
  box-shadow: 0 0 6px rgba(16,185,129,.4);
}

.status-dot.invalid {
  background: var(--color-error);
  box-shadow: 0 0 6px rgba(239,68,68,.4);
}

.json-error-msg {
  color: var(--color-error);
  font-weight: 500;
}

/* ============================================
   AD CONTAINERS
   ============================================ */
.ad-container {
  margin: 2rem 0;
  text-align: center;
  min-height: 90px;
}

.ad-container-sidebar {
  margin: 1.5rem 0;
  text-align: center;
}

.ad-container-banner {
  padding: 1rem 0;
  text-align: center;
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 2.5rem 0;
  margin-top: auto;
}

.footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: .625rem;
  font-size: .875rem;
  color: var(--color-text-secondary);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  font-size: .875rem;
  color: var(--color-text-secondary);
}

.footer-links a:hover {
  color: var(--color-primary);
}

/* ============================================
   FEATURES LIST (for tool pages)
   ============================================ */
.features-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.feature-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.feature-item svg {
  width: 20px;
  height: 20px;
  color: var(--color-primary);
  flex-shrink: 0;
  margin-top: 2px;
}

.feature-item-text h4 {
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: .25rem;
}

.feature-item-text p {
  font-size: .8rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: .75rem 1.25rem;
  background: var(--color-text);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  transform: translateY(120%);
  opacity: 0;
  transition: all var(--transition-base);
  z-index: 1000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  background: var(--color-success);
}

.toast.error {
  background: var(--color-error);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .hero {
    padding: 3rem 0 2.5rem;
  }

  .tools-grid {
    grid-template-columns: 1fr;
  }

  .json-panels {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .json-panel:first-child {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .json-input {
    min-height: 200px;
  }

  .json-output {
    min-height: 250px;
  }

  .json-toolbar {
    gap: .5rem;
  }

  .nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    padding: 1rem 1.5rem;
    gap: .75rem;
    box-shadow: var(--shadow-lg);
  }

  .nav.open {
    display: flex;
  }

  .nav-mobile-toggle {
    display: flex;
  }

  .footer .container {
    flex-direction: column;
    text-align: center;
  }

  .tool-page-title h1 {
    font-size: 1.35rem;
  }

  .features-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 1.65rem;
  }

  .hero-badges {
    flex-direction: column;
    gap: .75rem;
  }

  .json-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-separator {
    width: 100%;
    height: 1px;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
