/* =============================================
   GLOBAL CSS — AI Tools Directory
   ============================================= */

/* 1. CSS Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
}

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

a {
  text-decoration: none;
  color: inherit;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* 2. Design Tokens — Light Theme (Default) */
:root {
  --primary: #6366f1;
  --primary-hover: #4f52d9;
  --primary-light: rgba(99, 102, 241, 0.08);
  --primary-glow: rgba(99, 102, 241, 0.2);

  --bg: #f8fafc;
  --bg-secondary: #f1f5f9;
  --card: #ffffff;
  --card-hover: #f8fafc;
  --border: rgba(0, 0, 0, 0.07);
  --border-hover: rgba(99, 102, 241, 0.4);

  --text: #334155;
  --text-strong: #0f172a;
  --muted: #64748b;
  --muted-light: #94a3b8;

  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12), 0 4px 16px rgba(0,0,0,0.07);
  --shadow-glow: 0 0 0 2px var(--border-hover), 0 4px 24px var(--primary-glow);

  --transition: all 0.2s ease;
  --transition-slow: all 0.3s ease;

  --header-height: 64px;
  --sidebar-width: 260px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 300;
  --z-tooltip: 400;
}

/* Dark Theme Override */
[data-theme="dark"] {
  --primary-light: rgba(99, 102, 241, 0.12);
  --primary-glow: rgba(99, 102, 241, 0.3);

  --bg: #0f172a;
  --bg-secondary: #111827;
  --card: #1e293b;
  --card-hover: #253347;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(99, 102, 241, 0.4);

  --text: #e2e8f0;
  --text-strong: #f8fafc;
  --muted: #94a3b8;
  --muted-light: #64748b;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 4px 16px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.3);
}

/* 3. Base Typography */
body {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text);
  background-color: var(--bg);
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-strong);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 700; }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p { color: var(--muted); line-height: 1.7; }

small { font-size: 0.8125rem; color: var(--muted); }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.125em 0.375em;
  border-radius: 4px;
}

/* 4. Layout Utilities */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

.container--narrow {
  max-width: 768px;
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 80px 0;
}

.section--sm {
  padding: 48px 0;
}

.grid {
  display: grid;
  gap: 24px;
}

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

.grid--auto {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.flex {
  display: flex;
  align-items: center;
}

.flex--col { flex-direction: column; }
.flex--wrap { flex-wrap: wrap; }
.flex--between { justify-content: space-between; }
.flex--center { justify-content: center; }
.flex--gap { gap: 12px; }
.flex--gap-lg { gap: 24px; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* 5. Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--sm {
  padding: 7px 14px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.btn--lg {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: var(--radius);
}

.btn--primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn--primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 0 20px var(--primary-glow);
  transform: translateY(-1px);
}

.btn--secondary {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.btn--secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: transparent;
}

.btn--ghost:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.btn--outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn--outline:hover {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 20px var(--primary-glow);
}

.btn--danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

/* 6. Card Styles */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: var(--shadow-glow);
  border-color: var(--border-hover);
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, var(--primary-light) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.card:hover::before {
  opacity: 1;
}

/* 7. Badge / Tag Styles */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge--primary {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge--success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge--warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge--muted {
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.1);
}

/* 8. Form Styles */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 11px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9375rem;
  transition: var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--muted-light);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--muted);
}

.form-error {
  font-size: 0.8125rem;
  color: var(--danger);
}

/* 9. Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* 10. Skeleton Loading */
@keyframes skeleton-shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 0%,
    var(--card) 40%,
    var(--bg-secondary) 80%
  );
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
}

.skeleton--text {
  height: 14px;
  border-radius: var(--radius-full);
}

.skeleton--title {
  height: 20px;
  border-radius: var(--radius-full);
  width: 60%;
}

.skeleton--card {
  height: 200px;
  border-radius: var(--radius-lg);
}

.skeleton--avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  flex-shrink: 0;
}

/* 11. Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--card);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted-light);
}

/* 12. Section Headings */
.section-heading {
  margin-bottom: 48px;
}

.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
  margin-bottom: 12px;
}

.section-eyebrow::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
}

.section-title {
  margin-bottom: 12px;
}

.section-subtitle {
  font-size: 1.0625rem;
  color: var(--muted);
  max-width: 560px;
}

/* 13. Responsive Breakpoints */
@media (max-width: 1024px) {
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .section { padding: 56px 0; }
  .grid--4, .grid--3, .grid--2 { grid-template-columns: 1fr; }
  h1 { font-size: 2rem; }
}

@media (max-width: 480px) {
  .btn--lg { padding: 12px 20px; font-size: 0.9375rem; }
}

/* ═══════════════════════════════════════════
   14. Header Component Styles
   ═══════════════════════════════════════════ */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: var(--z-sticky);
  background: var(--card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: var(--transition-slow);
  height: var(--header-height);
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.site-header.scrolled {
  background: var(--card);
  border-bottom-color: var(--border);
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  transition: var(--transition);
}
.header-logo:hover { opacity: 0.85; }
.logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 0 16px var(--primary-glow);
}
.logo-text {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.03em;
}
.logo-accent { color: var(--primary); }
.header-search-wrap { flex: 1; max-width: 480px; }
.search-input-group { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--muted-light);
  pointer-events: none;
}
.header-search-input {
  width: 100%;
  padding: 9px 40px 9px 38px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition);
}
.header-search-input::placeholder { color: var(--muted-light); }
.header-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--bg-secondary);
}
.search-kbd {
  position: absolute;
  right: 10px;
  font-size: 0.7rem;
  color: var(--muted-light);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 5px;
  pointer-events: none;
  font-family: var(--font-mono);
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.nav-link {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.nav-link:hover, .nav-link.active {
  color: var(--primary);
  background: var(--primary-light);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.theme-btn { color: var(--muted); padding: 8px; border-radius: var(--radius-sm); }
.theme-btn:hover { color: var(--primary); background: var(--primary-light); }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }
.mobile-menu-btn { display: none; color: var(--muted); }

/* Dropdown Styles */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  z-index: var(--z-dropdown);
  margin-top: 8px;
}

.dropdown-menu::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--card);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

.nav-dropdown:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.dropdown-item {
  display: block;
  padding: 10px 16px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  transition: var(--transition);
}

.dropdown-item:hover {
  background: var(--primary-light);
  color: var(--primary);
  padding-left: 20px;
}
.mobile-menu {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0 16px;
  border-top: 1px solid var(--border);
}
.mobile-menu.open { display: flex; }
.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.mobile-nav-link:hover { color: var(--primary); background: var(--primary-light); }
@media (max-width: 768px) {
  .header-search-wrap { display: none; }
  .header-nav { display: none; }
  .mobile-menu-btn { display: flex; }
}
@media (max-width: 480px) {
  .logo-text { display: none; }
}

/* ═══════════════════════════════════════════
   15. Footer Component Styles
   ═══════════════════════════════════════════ */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 64px 0 0;
  margin-top: auto;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 48px;
}
.footer-brand .footer-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.footer-desc {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
  margin-bottom: 24px;
  max-width: 280px;
}
.footer-socials { display: flex; gap: 8px; }
.social-link {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: var(--transition);
}
.social-link:hover {
  color: var(--primary);
  border-color: var(--border-hover);
  background: var(--primary-light);
  transform: translateY(-2px);
}
.footer-col-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-strong);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}
.footer-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.footer-link { display: block; color: var(--muted); font-size: 0.9rem; transition: var(--transition); }
.footer-link:hover { color: var(--primary); padding-left: 4px; }
.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
  margin-top: 48px;
  border-top: 1px solid var(--border);
}
.footer-copy, .footer-made { font-size: 0.8125rem; color: var(--muted-light); }
@media (max-width: 1024px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 40px; }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .footer-grid { grid-template-columns: 1fr; gap: 32px; }
  .footer-bottom { flex-direction: column; gap: 8px; text-align: center; }
}

/* ═══════════════════════════════════════════
   16. Toast Notifications
   ═══════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: var(--z-tooltip);
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem; color: var(--text);
  min-width: 240px; max-width: 360px;
  transform: translateX(110%); opacity: 0;
  transition: var(--transition-slow);
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast--success { border-left: 3px solid var(--success); }
.toast--error   { border-left: 3px solid var(--danger); }
.toast--warning { border-left: 3px solid var(--warning); }
.toast--info    { border-left: 3px solid var(--primary); }
.toast-icon { font-size: 1.1em; }
