/* ============================================================
   TOOLIFY — MAIN.CSS
   Sistema de diseño global | Stack: HTML5 + CSS3 + Vanilla JS
   ============================================================ */

/* ─── 1. CSS VARIABLES (DESIGN TOKENS) ─────────────────────── */
:root {
  /* Colors */
  --bg-color:        #ffffff;
  --primary-color:   #2059d2;
  --primary-dark:    #1646b0;
  --primary-light:   #e8eefb;
  --accent-color:    #10b981;
  --accent-dark:     #059669;
  --text-color:      #111827;
  --text-muted:      #6b7280;
  --text-light:      #9ca3af;
  --border-color:    #e5e7eb;
  --surface-color:   #f9fafb;
  --surface-hover:   #f3f4f6;
  --shadow-sm:       0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:       0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-lg:       0 10px 40px rgba(0, 0, 0, 0.10), 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-primary:  0 8px 25px rgba(32, 89, 210, 0.25);

  /* Typography */
  --font-main:   'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;

  /* Sizing */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --container:   1200px;
  --nav-height:  68px;

  /* Transitions */
  --transition:  all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── 2. RESET CSS ──────────────────────────────────────────── */
*, *::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-main);
  color: var(--text-color);
  background-color: var(--bg-color);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

ul, ol {
  list-style: none;
}

/* ─── 3. UTILIDADES ─────────────────────────────────────────── */

/* Contenedores */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 24px;
}

.container-sm {
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
  padding-inline: 24px;
}

/* Flexbox helpers */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-4  { gap: 1rem; }
.gap-6  { gap: 1.5rem; }
.gap-8  { gap: 2rem; }

/* Grid helpers */
.grid           { display: grid; }
.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-fit  { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* Texto */
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); }
.text-primary { color: var(--primary-color); }
.text-accent  { color: var(--accent-color); }
.font-medium  { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold    { font-weight: 700; }

/* Spacing */
.mt-4  { margin-top: 1rem; }
.mt-8  { margin-top: 2rem; }
.mt-12 { margin-top: 3rem; }
.mb-4  { margin-bottom: 1rem; }
.mb-8  { margin-bottom: 2rem; }
.mb-12 { margin-bottom: 3rem; }
.py-4  { padding-block: 1rem; }
.py-8  { padding-block: 2rem; }
.py-16 { padding-block: 4rem; }
.py-24 { padding-block: 6rem; }

/* Section padding */
.section {
  padding-block: 80px;
}

.section-sm {
  padding-block: 48px;
}

/* Visibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ─── 4. TIPOGRAFÍA ─────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-color);
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); }
h3 { font-size: clamp(1.1rem, 2vw, 1.4rem); }
h4 { font-size: 1.125rem; }

p {
  color: var(--text-muted);
  line-height: 1.75;
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary-color);
  background: var(--primary-light);
  padding: 4px 12px;
  border-radius: 100px;
  margin-bottom: 16px;
}

/* ─── 5. BOTONES ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-color);
  color: #fff;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(32, 89, 210, 0.35);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: var(--text-color);
  border: 1.5px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--text-color);
  color: var(--text-color);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  color: var(--accent-color);
  border: 1.5px solid var(--accent-color);
}

.btn-outline:hover {
  background: var(--accent-color);
  color: #fff;
  transform: translateY(-2px);
}

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

.btn-accent:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
}

.btn-lg {
  padding: 15px 32px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* ─── 6. NAVBAR ─────────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}

.navbar.scrolled {
  box-shadow: var(--shadow-md);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

/* Logo */
.navbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  color: var(--text-color);
  letter-spacing: -0.03em;
}

.logo-img {
  height: 32px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.navbar-logo strong {
  font-weight: 800;
}

/* Nav links */
.navbar-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-links a {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.navbar-links a:hover,
.navbar-links a.active {
  color: var(--primary-color);
  background: var(--primary-light);
}

.navbar-cta {
  margin-left: 8px;
}

/* Hamburger */
.navbar-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.navbar-hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-color);
  border-radius: 2px;
  transition: var(--transition);
}

.navbar-hamburger.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.navbar-hamburger.is-open span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.navbar-hamburger.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Mobile nav overlay */
.navbar-mobile {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-color);
  padding: 24px;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
  border-top: 1px solid var(--border-color);
  animation: slideDown 0.2s ease;
}

.navbar-mobile.is-open {
  display: flex;
}

.navbar-mobile a {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.navbar-mobile a:hover {
  background: var(--primary-light);
  color: var(--primary-color);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Spacer debajo del navbar fijo */
.navbar-spacer {
  height: var(--nav-height);
}

/* ─── 7. HERO SECTION ───────────────────────────────────────── */
.hero {
  padding-block: 100px 80px;
  background: linear-gradient(160deg, #f0f4ff 0%, #ffffff 55%, #f0fdf9 100%);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(32, 89, 210, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -150px;
  left: -150px;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.05) 0%, transparent 70%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 800px;
  margin-inline: auto;
}

.hero h1 {
  margin-bottom: 20px;
}

.hero h1 .highlight {
  color: var(--primary-color);
  position: relative;
}

.hero p.subtitle {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: 580px;
  margin-inline: auto;
  margin-bottom: 40px;
}

/* Search bar */
.hero-search {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 8px 8px 8px 20px;
  max-width: 560px;
  margin-inline: auto;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.hero-search:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(32, 89, 210, 0.1), var(--shadow-md);
}

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

.hero-search input::placeholder {
  color: var(--text-light);
}

.hero-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ─── 8. TOOL CARDS ─────────────────────────────────────────── */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.tool-card {
  background: var(--bg-color);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: var(--transition-bounce);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  display: block;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-color);
  transform: scaleX(0);
  transform-origin: left;
  transition: var(--transition);
}

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

.tool-card:hover::before {
  transform: scaleX(1);
}

.tool-card-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.tool-card-icon.blue   { background: #e8eefb; }
.tool-card-icon.green  { background: #d1fae5; }
.tool-card-icon.purple { background: #ede9fe; }
.tool-card-icon.orange { background: #fef3c7; }
.tool-card-icon.red    { background: #fee2e2; }
.tool-card-icon.teal   { background: #ccfbf1; }

.tool-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 6px;
}

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

.tool-card-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--accent-color);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── 9. CATEGORY CARDS ─────────────────────────────────────── */
.category-card {
  background: var(--surface-color);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: block;
}

.category-card:hover {
  background: var(--primary-light);
  border-color: var(--primary-color);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.category-card-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}

.category-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 4px;
}

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

.category-card:hover h3 {
  color: var(--primary-color);
}

/* ─── 10. ADSENSE PLACEHOLDERS Y PROTECCIÓN CLS ──────────────── */
.ad-placeholder {
  width: 100%;
  background: repeating-linear-gradient(
    45deg,
    #f9fafb,
    #f9fafb 10px,
    #f3f4f6 10px,
    #f3f4f6 20px
  );
  border: 1.5px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  /* Anti-CLS baseline */
  min-height: 90px;
  contain: content;
}

.ad-placeholder.ad-banner  { 
  min-height: 90px; 
  aspect-ratio: 728 / 90;
  max-width: 100%;
  margin-inline: auto;
}
.ad-placeholder.ad-square  { 
  min-height: 250px; 
  max-width: 300px;
  aspect-ratio: 300 / 250;
  margin-inline: auto;
}
.ad-placeholder.ad-rect    { 
  min-height: 280px;
  max-width: 336px;
  aspect-ratio: 336 / 280;
  margin-inline: auto;
}

/* ─── 11. FOOTER ────────────────────────────────────────────── */
.footer {
  background: var(--text-color);
  color: rgba(255, 255, 255, 0.75);
  padding-top: 64px;
  padding-bottom: 32px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 48px;
  padding-bottom: 48px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 32px;
}

.footer-brand .navbar-logo {
  color: #fff;
  margin-bottom: 16px;
}

.footer-brand p {
  font-size: 0.87rem;
  color: rgba(255, 255, 255, 0.55);
  max-width: 280px;
  line-height: 1.7;
}

.footer-col h4 {
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 16px;
}

.footer-col ul {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-col ul li a {
  font-size: 0.87rem;
  color: rgba(255, 255, 255, 0.55);
  transition: var(--transition);
}

.footer-col ul li a:hover {
  color: #fff;
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-bottom p {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.4);
}

.footer-bottom a {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.82rem;
  transition: var(--transition);
}

.footer-bottom a:hover { color: #fff; }

.footer-legal {
  display: flex;
  gap: 20px;
}

/* ─── 12. SECTION HEADING ───────────────────────────────────── */
.section-heading {
  text-align: center;
  margin-bottom: 48px;
}

.section-heading h2 {
  margin-bottom: 12px;
}

.section-heading p {
  max-width: 560px;
  margin-inline: auto;
  font-size: 1.05rem;
}

/* ─── 13. STATS BAR ─────────────────────────────────────────── */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding-block: 40px;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
}

.stat-item .stat-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-color);
  letter-spacing: -0.03em;
  line-height: 1;
  display: block;
}

.stat-item .stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── 14. RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 1024px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }

  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .navbar-links,
  .navbar-cta { display: none; }

  .navbar-hamburger { display: flex; }

  .hero { padding-block: 80px 60px; }

  .hero p.subtitle { font-size: 1rem; }

  .grid-3,
  .grid-2 { grid-template-columns: 1fr; }

  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .stats-bar { gap: 28px; }

  .hero-search {
    flex-direction: column;
    border-radius: var(--radius-lg);
    padding: 12px;
    gap: 10px;
  }

  .hero-search input { width: 100%; padding: 4px 4px; }

  .section { padding-block: 56px; }
}

@media (max-width: 480px) {
  .container { padding-inline: 16px; }

  .tools-grid { grid-template-columns: 1fr; }

  h1 { font-size: 1.9rem; }

  .btn-lg { padding: 13px 24px; font-size: 0.95rem; }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }

  .footer-legal { flex-direction: column; gap: 10px; }
}

/* ─── 15. TOAST NOTIFICATIONS ───────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--text-color);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  pointer-events: auto;
}

.toast.success { background: var(--accent-dark); }
.toast.error   { background: #ef4444; }
.toast.info    { background: var(--primary-color); }

.toast.hiding {
  animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(30px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(20px); }
}

/* ─── 16. SEO CONTENT & INTERLINKING ────────────────────────── */
.seo-content {
  color: var(--text-color);
}
.seo-content h2 { margin-top: 40px; margin-bottom: 24px; }
.seo-content h3 { margin-top: 32px; margin-bottom: 16px; font-size: 1.25rem; }
.seo-content p { margin-bottom: 16px; }
.seo-content ul { padding-left: 20px; margin-bottom: 16px; list-style-type: disc;}
.seo-content li { margin-bottom: 8px; color: var(--text-muted); }

.faq-item {
  border-bottom: 1px solid var(--border-color);
  padding-block: 16px;
}
.faq-question { font-weight: 600; color: var(--text-color); margin-bottom: 8px; }
.faq-answer { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

/* ─── 17. COOKIE BANNER ─────────────────────────────────────── */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: var(--text-color);
  color: #ffffff;
  z-index: 9999;
  padding-block: 20px;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cookie-banner.hidden {
  transform: translateY(120%);
}

@media (max-width: 768px) {
  .cookie-content {
    flex-direction: column !important;
    text-align: center !important;
    gap: 16px !important;
  }
  .cookie-content p {
    font-size: 0.85rem !important;
    line-height: 1.5 !important;
  }
  .cookie-content .btn {
    width: 100% !important;
  }
}
