/* ==========================================================================
   ZeroTools — Global Styles & Design Tokens
   File: css/main.css
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Geist:wght@300;400;500;600&display=swap');

/* --- 1. DESIGN TOKENS (CSS Variables) --- */
:root {
  /* Backgrounds */
  --bg-primary:    #0a0a0a;
  --bg-secondary:  #111111;
  --bg-tertiary:   #1a1a1a;
  --bg-elevated:   #222222;

  /* Borders */
  --border-subtle:  #1f1f1f;
  --border-default: #2a2a2a;
  --border-strong:  #3a3a3a;

  /* Text */
  --text-primary:   #f0f0f0;
  --text-secondary: #888888;
  --text-tertiary:  #555555;
  --text-muted:     #3a3a3a;

  /* Accents & Semantic */
  --accent:         #00dc82;
  --accent-dim:     #00dc8220;
  --accent-border:  #00dc8240;
  --color-error:    #ff4d4d;
  --color-warning:  #ffd60a;
  --color-info:     #0ea5e9;
  --color-success:  #00dc82;

  /* Code Syntax Highlight Tokens */
  --syntax-key:     #ff6b9d;
  --syntax-string:  #00dc82;
  --syntax-number:  #ffd60a;
  --syntax-bool:    #0ea5e9;
  --syntax-null:    #888888;
  --syntax-comment: #555555;

  /* Typography */
  --font-sans:  'Geist', 'Helvetica Neue', sans-serif;
  --font-mono:  'IBM Plex Mono', 'Fira Code', monospace;
  
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-md:   17px;
  --text-lg:   20px;
  --text-xl:   26px;
  --text-2xl:  34px;

  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;

  --line-height-tight:  1.3;
  --line-height-normal: 1.6;
  --line-height-loose:  1.8;

  /* Spacing & Layout */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --max-width: 1280px;
  --tool-max-width: 960px;
  --sidebar-width: 240px;
  --header-height: 56px;
}

/* --- Light Mode Override --- */
html[data-theme="light"] {
  --bg-primary:    #fafafa;
  --bg-secondary:  #ffffff;
  --bg-tertiary:   #f4f4f4;
  --bg-elevated:   #ebebeb;
  --border-subtle:  #e8e8e8;
  --border-default: #d8d8d8;
  --border-strong:  #c0c0c0;
  --text-primary:   #111111;
  --text-secondary: #555555;
  --text-tertiary:  #888888;
  --text-muted:     #cccccc;
  --accent:         #009955;
  --accent-dim:     #00995520;
}

/* --- 2. BASE RESET & HTML CONFIG --- */
html {
  transition: background-color 0.2s ease, color 0.2s ease;
  scroll-behavior: smooth;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: var(--line-height-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

a:hover {
  opacity: 0.8;
}

/* --- 3. NAVBAR & SEARCH --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
}

.navbar-brand {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: var(--weight-semibold);
  text-decoration: none;
  flex-shrink: 0;
}

.brand-zero { color: var(--accent); }
.brand-tools { color: var(--text-primary); }

.navbar-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.navbar-search input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  transition: border-color 0.15s ease;
}

.navbar-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 360px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
}

.navbar-actions {
  display: flex;
  gap: var(--space-2);
  margin-left: auto;
}

/* --- 4. HERO SECTION --- */
.hero {
  padding: var(--space-16) var(--space-6) var(--space-10);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-inner {
  max-width: 800px;
  width: 100%;
}

.hero-badge {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  margin-bottom: var(--space-6);
}

.hero-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-4);
}

.hero-title .accent {
  color: var(--accent);
}

.hero-sub {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-bottom: var(--space-8);
}

.search-wrap {
  position: relative;
  max-width: 500px;
  margin: 0 auto var(--space-6);
}

.hero-search {
  width: 100%;
  padding: 16px 20px;
  font-size: var(--text-base);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.hero-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search-hint {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  background: var(--bg-primary);
  padding: 4px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.hero-stats {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  align-items: center;
}

.hero-stats .divider {
  color: var(--border-strong);
}

/* --- 5. HOMEPAGE GRID & TABS --- */
.category-tabs {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
  padding: 0 var(--space-4);
}

.tab-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.tab-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* --- 6. ADVERTISEMENTS --- */
.ad-container {
  width: 100%;
  overflow: hidden;
  margin: var(--space-6) 0;
  min-height: 90px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- 7. FOOTER --- */
.footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  margin-top: var(--space-16);
  padding: var(--space-10) var(--space-6) var(--space-6);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-10);
  justify-content: space-between;
}

.footer-brand p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-top: var(--space-2);
  max-width: 250px;
}

.footer-links {
  display: flex;
  gap: var(--space-10);
  flex-wrap: wrap;
}

.footer-col h4 {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-4);
}

.footer-col a {
  display: block;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
  text-decoration: none;
}

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

.footer-bottom {
  max-width: var(--max-width);
  margin: var(--space-10) auto 0;
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
}

/* --- 8. RESPONSIVE BREAKPOINTS --- */
@media (max-width: 768px) {
  .tool-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .navbar-search {
    display: none; /* Hide on small screens, map to an icon later if needed */
  }

  .footer-inner {
    flex-direction: column;
    gap: var(--space-8);
  }
}

@media (max-width: 480px) {
  .tool-grid {
    grid-template-columns: 1fr;
    padding: 0 var(--space-4);
  }

  .hero-title {
    font-size: var(--text-xl);
  }

  .hero-stats {
    flex-direction: column;
    gap: var(--space-1);
  }

  .hero-stats .divider {
    display: none;
  }
  
  .footer-bottom {
    flex-direction: column;
    gap: var(--space-4);
    text-align: center;
  }
}