/* ==========================================================================
   ToolForYou - Core Design System & Main Stylesheet
   ========================================================================== */

/* 1. CSS VARIABLES & THEME TOKENS */
:root {
  /* Color Palette - Light Theme */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  
  --border-color: #e2e8f0;
  --border-color-hover: #cbd5e1;
  --border-focus: #0ea5e9;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  
  --brand-primary: #0ea5e9;
  --brand-primary-hover: #0284c7;
  --brand-light: #e0f2fe;
  --brand-dark: #0369a1;
  
  --accent-success: #10b981;
  --accent-success-bg: #d1fae5;
  --accent-warning: #f59e0b;
  --accent-warning-bg: #fef3c7;
  --accent-danger: #ef4444;
  --accent-danger-bg: #fee2e2;

  --code-bg: #0f172a;
  --code-text: #f8fafc;
  
  /* Shadows & Glassmorphism */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-glass: 0 8px 32px 0 rgba(15, 23, 42, 0.05);
  
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "ui-monospace", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  
  --header-height: 4rem;
  --max-width: 1280px;
}

/* Dark Theme Overrides */
[data-theme="dark"] {
  --bg-primary: #090d16;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-surface-hover: #334155;
  
  --border-color: #1e293b;
  --border-color-hover: #334155;
  --border-focus: #38bdf8;
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;
  
  --brand-primary: #38bdf8;
  --brand-primary-hover: #7dd3fc;
  --brand-light: #075985;
  --brand-dark: #bae6fd;
  
  --accent-success: #34d399;
  --accent-success-bg: #064e3b;
  --accent-warning: #fbbf24;
  --accent-warning-bg: #78350f;
  --accent-danger: #f87171;
  --accent-danger-bg: #7f1d1d;

  --code-bg: #030712;
  --code-text: #f3f4f6;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* 2. BASE RESET & ACCESSIBILITY */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Accessible focus styling */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--brand-primary-hover);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

/* 3. LAYOUT CONTAINERS */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

main {
  flex: 1;
  padding: 2rem 0;
}

/* 4. HEADER & NAVIGATION */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

[data-theme="dark"] .site-header {
  background-color: rgba(15, 23, 42, 0.85);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 1.5rem;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
}

.logo-icon {
  width: 32px;
  height: 32px;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-link {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-sm);
}

.nav-link:hover, .nav-link.active {
  color: var(--brand-primary);
  background-color: var(--bg-surface-elevated);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Quick Search Trigger */
.search-trigger-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.4rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

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

.search-shortcut {
  font-size: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.1rem 0.375rem;
  font-family: var(--font-mono);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

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

/* Mobile Menu Toggle */
.mobile-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  padding: 0.5rem;
}

.mobile-nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background-color: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* 5. BREADCRUMBS */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.breadcrumbs a {
  color: var(--text-secondary);
}

.breadcrumbs a:hover {
  color: var(--brand-primary);
}

.breadcrumbs-separator {
  color: var(--text-muted);
}

/* 6. BUTTONS & CONTROLS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--brand-primary-hover);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-color-hover);
}

.btn-outline {
  background-color: transparent;
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary);
}

.btn-outline:hover {
  background-color: var(--brand-light);
}

.btn-danger {
  background-color: var(--accent-danger);
  color: #ffffff;
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1.0625rem;
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-md);
}

/* 7. CARDS & HERO */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

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

.hero-section {
  text-align: center;
  padding: 3rem 1rem 2.5rem 1rem;
  background: radial-gradient(circle at top, var(--brand-light) 0%, transparent 70%);
  border-radius: var(--radius-xl);
  margin-bottom: 2.5rem;
}

[data-theme="dark"] .hero-section {
  background: radial-gradient(circle at top, rgba(14, 165, 233, 0.12) 0%, transparent 70%);
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin-bottom: 1rem;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 auto 1.75rem auto;
}

.trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 0.375rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  margin-top: 1rem;
}

/* 8. ADSENSE SAFE CONTAINERS */
.ad-slot {
  display: none;
  width: 100%;
  margin: 0;
  padding: 0;
  background-color: var(--bg-surface-elevated);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  text-align: center;
  box-sizing: border-box;
  overflow: hidden;
  transition: opacity 0.3s ease;
}

.ad-slot.ad-loaded,
.ad-slot:has(ins.adsbygoogle[data-ad-status="filled"]),
.ad-slot:has(iframe[data-google-container-id]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 2rem 0;
  padding: 1.25rem;
  min-height: 100px;
}

.ad-placeholder {
  display: none;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.ad-slot.ad-loaded .ad-placeholder {
  display: block;
}

/* 9. GLOBAL SEARCH MODAL */
.search-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

.search-modal-backdrop.active {
  display: flex;
}

.search-modal {
  width: 100%;
  max-width: 640px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 75vh;
}

.search-modal-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  gap: 0.75rem;
}

.search-modal-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1.125rem;
  color: var(--text-primary);
  outline: none;
}

.search-modal-results {
  overflow-y: auto;
  padding: 0.75rem;
  list-style: none;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
  transition: background-color var(--transition-fast);
}

.search-result-item:hover, .search-result-item.selected {
  background-color: var(--bg-surface-elevated);
}

.search-result-title {
  font-weight: 600;
  font-size: 0.9375rem;
}

.search-result-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.search-result-category {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  background-color: var(--bg-surface-hover);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

/* 10. TOAST NOTIFICATIONS */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background-color: var(--code-bg);
  color: var(--code-text);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  animation: slideIn 0.2s ease-out forwards;
}

@keyframes slideIn {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 11. FOOTER */
.site-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 3rem 0 1.5rem 0;
  margin-top: 4rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

.footer-brand p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.75rem;
  max-width: 300px;
}

.footer-col h4 {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.footer-col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-col a {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.footer-col a:hover {
  color: var(--brand-primary);
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-muted);
}
