/* ============================================================
 * Panamerik · DhabBlogEnhancements
 * Mejoras visuales incrementales al blog (Amasty Blog + Hyva).
 * CSS plano (sin @apply Tailwind) servido como asset del módulo.
 * Specificity: scopeo con body.amblog-index-index / body.amblog-index-post
 * Y BEM-namespacing dhab-blog-* para evitar colisiones.
 * @author Panamerik · 2026-05-10
 * ============================================================ */

/* ============================================================
   Featured post (primer post del listado, ancho completo)
   ============================================================ */
body.amblog-index-index .dhab-blog-card--featured {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding-bottom: 1.75rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}
@media (min-width: 1024px) {
    body.amblog-index-index .dhab-blog-card--featured {
        grid-template-columns: 1.3fr 1fr;
        gap: 2rem;
        align-items: center;
    }
}
body.amblog-index-index .dhab-blog-card--featured > a.post-image {
    aspect-ratio: 16 / 10;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    display: block;
}
body.amblog-index-index .dhab-blog-card--featured > a.post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
body.amblog-index-index .dhab-blog-card--featured h1.amblog-post-title,
body.amblog-index-index .dhab-blog-card--featured h2.amblog-post-title {
    font-size: 1.75rem;
    line-height: 1.15;
    margin-top: 0.5rem;
}

/* ============================================================
   Grid wrapper (resto de posts en 2 cols en md+)
   ============================================================ */
body.amblog-index-index .dhab-blog-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.75rem 1.5rem;
    margin-top: 1.5rem;
}
@media (min-width: 768px) {
    body.amblog-index-index .dhab-blog-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================================
   Cards (grid, no featured): radius, jerarquía, hover
   ============================================================ */
body.amblog-index-index .dhab-blog-grid .dhab-blog-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
    border-bottom: 0 !important;
}
body.amblog-index-index .dhab-blog-grid .dhab-blog-card > a.post-image {
    display: block;
    aspect-ratio: 3 / 2;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f3f4f6;
    overflow: hidden;
}
body.amblog-index-index .dhab-blog-grid .dhab-blog-card > a.post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}
body.amblog-index-index .dhab-blog-grid .dhab-blog-card:hover > a.post-image img {
    transform: scale(1.03);
}
body.amblog-index-index .dhab-blog-grid .dhab-blog-card h2.amblog-post-title {
    font-size: 1.125rem;
    line-height: 1.3;
    font-weight: 700;
    margin-top: 0.25rem;
}

/* ============================================================
   "Leer más" → link sutil con flecha (en grid de cards)
   ============================================================ */
body.amblog-index-index .dhab-blog-grid .dhab-blog-card a.amblog-read {
    display: inline-flex !important;
    align-items: center;
    align-self: flex-start;
    background: transparent !important;
    color: #254336 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    font-weight: 700;
    font-size: 0.875rem;
    text-decoration: none;
    height: auto !important;
    margin-top: 0.25rem;
}
body.amblog-index-index .dhab-blog-grid .dhab-blog-card a.amblog-read::after {
    content: " →";
    display: inline-block;
    margin-left: 6px;
    transition: transform 0.15s ease;
}
body.amblog-index-index .dhab-blog-grid .dhab-blog-card a.amblog-read:hover {
    color: #1a3327 !important;
}
body.amblog-index-index .dhab-blog-grid .dhab-blog-card a.amblog-read:hover::after {
    transform: translateX(3px);
}

/* Featured: mantener "Leer más" como botón sólido grande pero respetar el verde */
body.amblog-index-index .dhab-blog-card--featured a.amblog-read {
    align-self: flex-start;
}

/* ============================================================
   Imágenes redondeadas en post detalle
   ============================================================ */
body.amblog-index-post .amblog-post-image,
body.amblog-index-post .post-image {
    border-radius: 8px;
    overflow: hidden;
}
body.amblog-index-post .amblog-post-content img {
    border-radius: 8px;
}

/* ============================================================
   Sidebar refinement (sticky en desktop + spacing)
   ============================================================ */
body.amblog-index-index .sidebar.sidebar-additional,
body.amblog-index-post .sidebar.sidebar-additional {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
@media (min-width: 1024px) {
    body.amblog-index-index .sidebar.sidebar-additional,
    body.amblog-index-post .sidebar.sidebar-additional {
        position: sticky;
        top: 1.5rem;
        align-self: start;
    }
}

/* ============================================================
   DHAB Blog CTA (bloque persistente a tienda)
   ============================================================ */
.dhab-blog-cta {
    background: #254336;
    color: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    display: block;
}
.dhab-blog-cta__eyebrow {
    display: block;
    font-size: 0.6875rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.5rem;
}
.dhab-blog-cta__title {
    font-size: 1.125rem;
    font-weight: 800;
    line-height: 1.25;
    color: #fff;
    margin: 0 0 0.5rem;
}
.dhab-blog-cta__copy {
    font-size: 0.875rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.85);
    margin: 0 0 1rem;
}
.dhab-blog-cta__btn {
    display: block;
    text-align: center;
    width: 100%;
    background: #fff;
    color: #254336;
    padding: 0.625rem 1rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: 0.02em;
    text-decoration: none;
    transition: background 0.15s ease;
}
.dhab-blog-cta__btn:hover {
    background: #f3f4f6;
    color: #254336;
    text-decoration: none;
}

/* ============================================================
   Paginación: dar VISIBILIDAD a las flechas prev/next (Amasty
   las renderiza como <a> vacíos y mostraba nada con override
   incorrecto). Usamos pseudo-content + aria-label fallback.
   ============================================================ */
body.amblog-index-index .amblog-pager-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid #e5e7eb;
    flex-wrap: wrap;
}
body.amblog-index-index .amblog-pager-container .amblog-links {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
body.amblog-index-index .amblog-pager-container .amblog-link {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: #374151;
    text-decoration: none;
    background: #fff;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
body.amblog-index-index .amblog-pager-container .amblog-link[rel="prev"]::before {
    content: "‹";
}
body.amblog-index-index .amblog-pager-container .amblog-link[rel="next"]::before {
    content: "›";
}
body.amblog-index-index .amblog-pager-container .amblog-link:hover {
    color: #254336;
    border-color: #254336;
    background: #f1f6f3;
}
body.amblog-index-index .amblog-pager-container .amblog-link.-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}
body.amblog-index-index .amblog-pager-container .amblog-pagination {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 600;
    padding: 0 0.75rem;
}

/* ============================================================
   SIDEBAR — Recent Posts widget (Amasty native + Hyva compat,
   restyled para sidebar vertical de 1 columna).
   El template Hyva default emite .grid.md:grid-cols-4 (horizontal)
   que se ve mal en sidebar. Sobreescribimos a flex-column.
   ============================================================ */
body.amblog-index-index .sidebar-additional .amblog-widget-container.-recent-posts,
body.amblog-index-post .sidebar-additional .amblog-widget-container.-recent-posts,
.sidebar-additional .amblog-widget-container.-recent-posts {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.25rem;
    display: block;
}
.sidebar-additional .amblog-widget-container.-recent-posts .amblog-sidebar-heading-container .amblog-title,
.sidebar-additional .amblog-widget-container.-recent-posts h3.amblog-title {
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #111827;
    margin: 0 0 0.875rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

/* Sobrescribir grid horizontal del template Hyva → vertical de 1 col en sidebar */
.sidebar-additional .amblog-widget-container.-recent-posts > .grid,
.sidebar-additional .amblog-widget-container.-recent-posts > .amblog-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.875rem !important;
    grid-template-columns: none !important;
}

/* Cada item del recent post (el template Hyva los rendera con .mb-6, ajustamos) */
.sidebar-additional .amblog-widget-container.-recent-posts > .grid > div,
.sidebar-additional .amblog-widget-container.-recent-posts > .amblog-list .post-item-info {
    display: grid !important;
    grid-template-columns: 60px 1fr !important;
    gap: 0.75rem !important;
    align-items: start !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Imagen del recent post */
.sidebar-additional .amblog-widget-container.-recent-posts a.post-image {
    display: block !important;
    width: 60px !important;
    height: 60px !important;
    overflow: hidden;
    border-radius: 4px;
    background: #f3f4f6;
    flex-shrink: 0;
}
.sidebar-additional .amblog-widget-container.-recent-posts a.post-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

/* Container del título / fecha */
.sidebar-additional .amblog-widget-container.-recent-posts .post-item-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    margin-top: 0 !important;
}

/* Título del post (Hyva emite <h6>, Amasty emite <a>) */
.sidebar-additional .amblog-widget-container.-recent-posts .post-title.amblog-headline,
.sidebar-additional .amblog-widget-container.-recent-posts h6.amblog-headline,
.sidebar-additional .amblog-widget-container.-recent-posts a.amblog-headline {
    font-family: inherit;
    font-size: 0.8125rem !important;
    line-height: 1.3 !important;
    font-weight: 600 !important;
    color: #111827 !important;
    text-decoration: none;
    transition: color 0.15s ease;
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0 !important;
}
.sidebar-additional .amblog-widget-container.-recent-posts .post-title.amblog-headline:hover {
    color: #254336 !important;
}
.sidebar-additional .amblog-widget-container.-recent-posts .amblog-dates {
    font-size: 0.6875rem !important;
    color: #9ca3af !important;
    letter-spacing: 0.04em;
    margin-top: 2px;
}
.sidebar-additional .amblog-widget-container.-recent-posts .amblog-dates .amblog-date {
    display: inline;
}

/* ============================================================
   POST DETALLE — Tabla de contenido sticky
   ============================================================ */
.dhab-blog-toc {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.25rem 1.25rem 1rem;
}
.dhab-blog-toc__title {
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #111827;
    margin: 0 0 0.875rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}
.dhab-blog-toc__list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: dhab-toc;
}
.dhab-blog-toc__list li {
    counter-increment: dhab-toc;
    border-bottom: 1px solid #f3f4f6;
}
.dhab-blog-toc__list li:last-child { border-bottom: 0; }
.dhab-blog-toc__list a {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.625rem 0;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: #4b5563;
    text-decoration: none;
    transition: color 0.15s ease;
}
.dhab-blog-toc__list a::before {
    content: counter(dhab-toc, decimal-leading-zero);
    flex-shrink: 0;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #9ca3af;
    padding-top: 2px;
}
.dhab-blog-toc__list a:hover,
.dhab-blog-toc__list a.is-active {
    color: #254336;
}
.dhab-blog-toc__list a:hover::before,
.dhab-blog-toc__list a.is-active::before {
    color: #254336;
}

/* ============================================================
   POST DETALLE — Share buttons
   ============================================================ */
.dhab-blog-share {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    padding: 1.25rem 0;
    margin: 2rem 0 1rem;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
}
.dhab-blog-share__label {
    font-size: 0.6875rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #6b7280;
}
.dhab-blog-share__list {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0;
}
.dhab-blog-share__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
    background: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1;
    font-family: inherit;
}
.dhab-blog-share__btn svg { flex-shrink: 0; }
.dhab-blog-share__btn:hover {
    background: #254336;
    color: #fff;
    border-color: #254336;
    text-decoration: none;
}
.dhab-blog-share__btn--copy { font: inherit; }

/* ============================================================
   POST DETALLE — Final CTA box
   ============================================================ */
.dhab-blog-final-cta {
    margin: 2.5rem 0 1.5rem;
    padding: 2rem 1.75rem;
    background: linear-gradient(135deg, #254336 0%, #122620 100%);
    border-radius: 8px;
    text-align: center;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.dhab-blog-final-cta::before {
    content: "";
    position: absolute;
    top: -40%;
    right: -20%;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(255, 104, 0, 0.18), transparent 60%);
    pointer-events: none;
}
.dhab-blog-final-cta > * { position: relative; z-index: 1; }
.dhab-blog-final-cta__eyebrow {
    display: block;
    font-size: 0.6875rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #ff6800;
    margin-bottom: 0.75rem;
}
.dhab-blog-final-cta__title {
    font-family: inherit;
    font-size: clamp(1.25rem, 2.4vw, 1.75rem);
    font-weight: 800;
    line-height: 1.2;
    color: #fff;
    margin: 0 0 0.75rem;
    max-width: 32ch;
    margin-left: auto;
    margin-right: auto;
    letter-spacing: -0.012em;
}
.dhab-blog-final-cta__copy {
    font-size: 0.875rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.9);
    margin: 0 auto 1.5rem;
    max-width: 56ch;
}
.dhab-blog-final-cta__actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}
.dhab-blog-final-cta__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: 0.02em;
    text-decoration: none;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    line-height: 1;
}
.dhab-blog-final-cta__btn--primary {
    background: #fff;
    color: #254336;
}
.dhab-blog-final-cta__btn--primary:hover {
    background: #f3f4f6;
    color: #254336;
    text-decoration: none;
}
.dhab-blog-final-cta__btn--secondary {
    background: transparent;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
}
.dhab-blog-final-cta__btn--secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
    color: #fff;
    text-decoration: none;
}

/* ============================================================
   Mobile: 1 col, sin sticky
   ============================================================ */
@media (max-width: 767px) {
    body.amblog-index-index .dhab-blog-card--featured {
        gap: 1rem;
        padding-bottom: 1.25rem;
    }
    body.amblog-index-index .dhab-blog-card--featured h1.amblog-post-title,
    body.amblog-index-index .dhab-blog-card--featured h2.amblog-post-title {
        font-size: 1.375rem;
    }
    body.amblog-index-index .dhab-blog-grid {
        gap: 1.5rem;
    }
    .dhab-blog-share__btn span { display: none; }
    .dhab-blog-share__btn { padding: 0.5rem 0.625rem; }
    .dhab-blog-final-cta { padding: 1.5rem 1.25rem; }
    .dhab-blog-final-cta__btn { width: 100%; }
}
