/* ============================================
   UTILWARE SOLUTIONS — Blog Stylesheet
   Listing + 5 Article Templates + Light/Dark Mode
   ============================================ */

/* ===========================
   LIGHT/DARK MODE
   =========================== */

/* Dark mode defaults — defined on body so blog-light can override */
body {
  --blog-bg: var(--dark-900);
  --blog-surface: var(--dark-800);
  --blog-border: rgba(255, 255, 255, 0.06);
  --blog-text: var(--light-200);
  --blog-text-secondary: var(--light-400);
  --blog-heading: var(--white);
  --blog-code-bg: var(--dark-800);
  --blog-callout-tip-bg: var(--green-subtle);
  --blog-callout-warn-bg: rgba(245, 158, 11, 0.08);
  --blog-callout-info-bg: var(--accent-subtle);
  --blog-hr: rgba(255, 255, 255, 0.08);
}

/* Light mode overrides */
body.blog-light {
  --blog-bg: #FFFFFF;
  --blog-surface: #F8FAFC;
  --blog-border: #E2E8F0;
  --blog-text: #334155;
  --blog-text-secondary: #64748B;
  --blog-heading: #0F172A;
  --blog-code-bg: #F1F5F9;
  --blog-callout-tip-bg: #ECFDF5;
  --blog-callout-warn-bg: #FFFBEB;
  --blog-callout-info-bg: #EFF6FF;
  --blog-hr: #E2E8F0;
}

/* Light mode: everything below hero becomes light */
body.blog-light main article > .section {
  background: var(--blog-bg);
}

/* Footer stays dark regardless */
body.blog-light .footer {
  background: var(--dark-900);
  --blog-heading: var(--white);
  --blog-text: var(--light-200);
  --blog-text-secondary: var(--light-400);
  --blog-border: rgba(255, 255, 255, 0.06);
}

/* Theme toggle button */
.theme-toggle {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 50;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--dark-700);
  color: #F59E0B;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

body.blog-light .theme-toggle {
  background: #1E293B;
  color: #93C5FD;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Hide sun/moon based on mode — dark shows sun (switch to light), light shows moon (switch to dark) */
.theme-toggle .fa-sun { display: none; }
.theme-toggle .fa-moon { display: inline; }
body.blog-light .theme-toggle .fa-moon { display: none; }
body.blog-light .theme-toggle .fa-sun { display: inline; }


/* ===========================
   BLOG LISTING PAGE
   =========================== */

.blog-hero {
  padding-top: 140px;
  padding-bottom: 60px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--dark-900) 0%, #0f1a33 50%, var(--dark-900) 100%);
}

.blog-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 20%, var(--accent-glow), transparent 60%),
              radial-gradient(ellipse at 70% 80%, var(--green-subtle), transparent 50%);
  pointer-events: none;
}

/* --- Category Filters --- */
.blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 40px;
  justify-content: center;
}

.blog-filter {
  padding: 8px 20px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--light-400);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.blog-filter:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.blog-filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}

/* --- Blog Grid --- */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: var(--gap);
}

.blog-card {
  display: block;
  background: var(--dark-800);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform var(--duration) var(--ease), border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.blog-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-glow);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.blog-card__image {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--dark-700);
}

.blog-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--ease);
}

.blog-card:hover .blog-card__image img {
  transform: scale(1.05);
}

.blog-card__body {
  padding: 24px;
}

.blog-card__category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.blog-card__title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--white);
  margin-top: 8px;
  line-height: 1.4;
}

.blog-card__excerpt {
  font-size: 0.9375rem;
  color: var(--light-400);
  margin-top: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-card__meta {
  display: flex;
  gap: 16px;
  font-size: 0.8125rem;
  color: var(--light-400);
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.blog-card__meta i {
  margin-right: 6px;
}

/* --- Empty State --- */
.blog-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--light-400);
}

.blog-empty i {
  font-size: 3rem;
  margin-bottom: 16px;
  color: var(--dark-600);
}

.blog-empty p {
  font-size: 1.125rem;
}


/* ===========================
   ARTICLE — SHARED STYLES
   =========================== */

.article-hero {
  padding-top: 140px;
  padding-bottom: 40px;
  position: relative;
  background: linear-gradient(135deg, var(--dark-900) 0%, #0f1a33 50%, var(--dark-900) 100%);
}

.article-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 20%, var(--accent-glow), transparent 60%);
  pointer-events: none;
}

.article-hero .container {
  position: relative;
  z-index: 1;
}

.article-hero__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 0.875rem;
}

.article-hero__category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-subtle);
  padding: 4px 12px;
  border-radius: 100px;
}

.article-hero__date,
.article-hero__read-time {
  color: var(--light-400);
  font-size: 0.875rem;
}

.article-hero__date i,
.article-hero__read-time i {
  margin-right: 6px;
}

.article-hero__title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  color: var(--white);
  line-height: 1.15;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.article-hero__excerpt {
  font-size: 1.1875rem;
  color: var(--light-300);
  max-width: 720px;
  line-height: 1.7;
}

.article-hero__author {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  font-size: 0.9375rem;
}

.article-hero__author-name {
  color: var(--white);
  font-weight: 600;
}

.article-hero__image {
  margin-top: 40px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-height: 500px;
}

.article-hero__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Remove excess padding from article sections */
article > .section {
  padding: 0;
}

/* --- Article Body (improved reading typography) --- */
.article-body {
  padding: 48px 0 60px;
  transition: background 0.3s ease, color 0.3s ease;
}

.article-content {
  max-width: 720px;
  margin: 0 auto;
}

.article-body h2 {
  font-size: clamp(1.5rem, 3vw, 1.875rem);
  font-weight: 700;
  color: var(--blog-heading);
  margin-top: 56px;
  margin-bottom: 20px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--blog-hr);
}

.article-body h2:first-child {
  margin-top: 0;
}

.article-body h3 {
  font-size: clamp(1.1875rem, 2.5vw, 1.375rem);
  font-weight: 600;
  color: var(--blog-heading);
  margin-top: 36px;
  margin-bottom: 12px;
  line-height: 1.4;
}

.article-body p {
  font-size: 1.0625rem;
  line-height: 1.85;
  color: var(--blog-text);
  margin-bottom: 24px;
}

.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(59, 130, 246, 0.4);
  transition: all var(--duration) var(--ease);
}

.article-body a:hover {
  color: var(--accent-hover);
  text-decoration-color: var(--accent-hover);
}

.article-body strong {
  color: var(--blog-heading);
  font-weight: 600;
}

.article-body ul,
.article-body ol {
  list-style: disc;
  padding-left: 24px;
  margin-bottom: 24px;
}

.article-body ol {
  list-style: decimal;
}

.article-body li {
  margin-bottom: 10px;
  font-size: 1.0625rem;
  color: var(--blog-text);
  line-height: 1.75;
}

.article-body li::marker {
  color: var(--accent);
}

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 16px 0 16px 24px;
  margin: 28px 0;
  font-style: italic;
  color: var(--blog-text-secondary);
  font-size: 1.0625rem;
  line-height: 1.75;
}

.article-body pre {
  background: var(--blog-code-bg);
  border: 1px solid var(--blog-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.65;
  margin: 28px 0;
  color: var(--blog-text);
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--blog-code-bg);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--accent);
  border: 1px solid var(--blog-border);
}

.article-body pre code {
  background: none;
  padding: 0;
  color: inherit;
  border: none;
}

.article-body img {
  border-radius: var(--radius);
  margin: 32px 0;
  max-width: 100%;
}

.article-body hr {
  border: none;
  height: 1px;
  background: var(--blog-hr);
  margin: 48px 0;
}

/* --- Article CTA --- */
.article-cta {
  background: var(--blog-surface);
  border: 1px solid var(--blog-border);
  border-radius: var(--radius-lg);
  padding: 48px;
  text-align: center;
  margin-top: 64px;
}

body.blog-light .article-cta {
  background: linear-gradient(135deg, #EFF6FF, #F0FDF4);
  border-color: rgba(59, 130, 246, 0.15);
}

/* Fix buttons in light mode */
body.blog-light .btn--outline {
  color: #334155;
  border-color: #CBD5E1;
}

body.blog-light .btn--outline:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.article-cta h3 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--blog-heading);
  margin-bottom: 12px;
  margin-top: 0;
}

.article-cta p {
  color: var(--blog-text-secondary);
  margin-bottom: 24px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

/* --- Share Buttons --- */
.article-share {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--blog-border);
}

.article-share__label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--blog-text-secondary);
  margin-right: 4px;
}

.article-share__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--blog-border);
  background: transparent;
  color: var(--blog-text-secondary);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.article-share__btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

/* --- Prev/Next Navigation --- */
.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 48px;
  padding-top: 48px;
  border-top: 1px solid var(--blog-border);
}

.article-nav__link {
  display: block;
  padding: 24px;
  background: var(--blog-surface);
  border: 1px solid var(--blog-border);
  border-radius: var(--radius);
  transition: border-color var(--duration) var(--ease);
}

.article-nav__link:hover {
  border-color: var(--accent-glow);
}

.article-nav__link--next {
  text-align: right;
}

.article-nav__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
}

.article-nav__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--blog-heading);
  margin-top: 8px;
}


/* ===========================
   TEMPLATE 1: ESTANDAR
   =========================== */

.template--estandar .article-hero__image {
  border-radius: 0;
  max-height: 500px;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  width: 100vw;
  margin-top: 40px;
}

.template--estandar .article-content {
  max-width: 720px;
}


/* ===========================
   TEMPLATE 2: REVISTA
   =========================== */

.template--revista .article-hero__inner {
  display: flex;
  align-items: center;
  gap: 48px;
}

.template--revista .article-hero__text {
  flex: 1;
}

.template--revista .article-hero__image {
  flex: 0 0 40%;
  margin-top: 0;
  border-radius: var(--radius-lg);
  max-height: 400px;
}

.template--revista .article-content {
  max-width: 900px;
  columns: 2;
  column-gap: 48px;
}

.template--revista .article-body > .article-content > p:first-of-type::first-letter {
  float: left;
  font-size: 4rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 0.8;
  margin-right: 8px;
  margin-top: 6px;
}

.article-pullquote {
  font-size: 1.375rem;
  font-weight: 500;
  font-style: italic;
  color: var(--accent);
  border-left: 4px solid var(--green);
  padding: 16px 0 16px 24px;
  margin: 32px 0;
  break-inside: avoid;
  line-height: 1.5;
}


/* ===========================
   TEMPLATE 3: VISUAL
   =========================== */

.template--visual .article-hero__image {
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  width: 100vw;
  max-height: 600px;
  border-radius: 0;
  margin-top: 40px;
}

.template--visual .article-content {
  max-width: 720px;
}

.article-fullbleed {
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin: 48px calc(-50vw + 50%);
  position: relative;
}

.article-fullbleed img {
  width: 100%;
  max-height: 500px;
  object-fit: cover;
  border-radius: 0;
  margin: 0;
}

.article-fullbleed figcaption {
  max-width: 720px;
  margin: 12px auto 0;
  padding: 0 20px;
  font-size: 0.8125rem;
  color: var(--blog-text-secondary);
  text-align: center;
}

.article-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 32px 0;
}

.article-gallery img {
  border-radius: var(--radius);
  margin: 0;
  width: 100%;
  height: 250px;
  object-fit: cover;
}


/* ===========================
   TEMPLATE 4: GUIA
   =========================== */

.template--guia .article-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 48px;
  align-items: start;
}

.template--guia .article-content {
  max-width: none;
}

/* Sticky TOC Sidebar */
.article-toc {
  position: sticky;
  top: 100px;
  background: var(--blog-surface);
  border: 1px solid var(--blog-border);
  border-radius: var(--radius);
  padding: 24px;
}

.article-toc__title {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blog-heading);
  margin-bottom: 16px;
}

.article-toc__list {
  list-style: none;
  padding: 0;
}

.article-toc__link {
  display: block;
  padding: 8px 0 8px 12px;
  font-size: 0.8125rem;
  color: var(--blog-text-secondary);
  border-left: 2px solid transparent;
  transition: all var(--duration) var(--ease);
  text-decoration: none;
}

.article-toc__link:hover,
.article-toc__link.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* Callout Boxes */
.article-callout {
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 28px 0;
}

.article-callout--tip {
  background: var(--blog-callout-tip-bg);
  border-left: 3px solid var(--green);
}

.article-callout--warning {
  background: var(--blog-callout-warn-bg);
  border-left: 3px solid var(--gold);
}

.article-callout--info {
  background: var(--blog-callout-info-bg);
  border-left: 3px solid var(--accent);
}

.article-callout__title {
  font-weight: 700;
  font-size: 0.9375rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--blog-heading);
}

.article-callout__title i {
  font-size: 1rem;
}

.article-callout--tip .article-callout__title i { color: var(--green); }
.article-callout--warning .article-callout__title i { color: var(--gold); }
.article-callout--info .article-callout__title i { color: var(--accent); }

.article-callout p:last-child {
  margin-bottom: 0;
}

/* Numbered Steps */
.article-step {
  display: flex;
  gap: 20px;
  margin: 28px 0;
  padding: 24px;
  background: var(--blog-surface);
  border: 1px solid var(--blog-border);
  border-radius: var(--radius);
}

.article-step__number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-mono);
  line-height: 1;
  flex-shrink: 0;
}

.article-step__content h3 {
  margin-top: 0;
  font-size: 1.125rem;
  color: var(--blog-heading);
}

.article-step__content p {
  color: var(--blog-text);
}


/* ===========================
   TEMPLATE 5: DESTACADO
   =========================== */

.template--destacado .article-hero {
  text-align: center;
  padding-bottom: 60px;
}

.template--destacado .article-hero__meta {
  justify-content: center;
}

.template--destacado .article-hero__excerpt {
  margin-left: auto;
  margin-right: auto;
}

.template--destacado .article-hero__author {
  justify-content: center;
}

.template--destacado .article-content {
  max-width: 800px;
}

/* Stat Row */
.article-stat-row {
  display: flex;
  justify-content: center;
  gap: 48px;
  padding: 48px;
  margin: 48px 0;
  background: var(--blog-surface);
  border: 1px solid var(--blog-border);
  border-radius: var(--radius-lg);
}

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

.article-stat__value {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-mono);
  line-height: 1;
}

.article-stat__label {
  font-size: 0.875rem;
  color: var(--blog-text-secondary);
  margin-top: 8px;
}

/* Highlight Box */
.article-highlight {
  background: linear-gradient(135deg, var(--blog-callout-info-bg), var(--blog-callout-tip-bg));
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: var(--radius-lg);
  padding: 40px;
  margin: 48px 0;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--blog-heading);
  line-height: 1.6;
}

/* Accent Section */
.article-accent-section {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: var(--white);
  padding: 48px;
  margin: 48px calc(-50vw + 50%);
  width: 100vw;
  text-align: center;
}

.article-accent-section h3 {
  color: var(--white);
  font-size: 1.5rem;
  margin-top: 0;
}

.article-accent-section p {
  color: rgba(255, 255, 255, 0.9);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.article-accent-section p:last-child {
  margin-bottom: 0;
}


/* ===========================
   RESPONSIVE
   =========================== */

@media (max-width: 1024px) {
  .blog-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }

  .template--guia .article-layout {
    grid-template-columns: 1fr;
  }

  .template--guia .article-toc {
    position: static;
    margin-bottom: 32px;
  }

  .template--revista .article-content {
    columns: 1;
  }

  .template--revista .article-hero__inner {
    flex-direction: column;
  }

  .template--revista .article-hero__image {
    flex: none;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .blog-grid {
    grid-template-columns: 1fr;
  }

  .article-hero__title {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
  }

  .article-stat-row {
    flex-direction: column;
    gap: 24px;
    padding: 32px;
  }

  .article-nav {
    grid-template-columns: 1fr;
  }

  .article-nav__link--next {
    text-align: left;
  }

  .article-cta {
    padding: 32px 20px;
  }

  .article-accent-section {
    padding: 32px 20px;
  }

  .article-step {
    flex-direction: column;
    gap: 12px;
  }

  .theme-toggle {
    top: 72px;
    right: 12px;
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }
}

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

  .article-body p,
  .article-body li {
    font-size: 1rem;
  }

  .blog-filters {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }

  .blog-filter {
    flex-shrink: 0;
  }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  .blog-card,
  .blog-card__image img,
  .article-body,
  .theme-toggle {
    transition: none;
  }
}
