/*
Theme Name: Arbar FSE Theme
Theme URI: https://arbar.co
Author: DreamTeam UTCM
Author URI: https://dreamteam.lat
Description: Tema FSE personalizado para Arbar Mobiliario, enfocado en eCommerce B2B/B2C y alto rendimiento SEO.
Requires at least: 6.2
Tested up to: 6.4
Requires PHP: 7.4
Version: 1.0.3
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: arbar
Tags: custom-background, custom-colors, custom-menu, custom-logo, editor-style, featured-images, block-patterns, full-site-editing
*/

/* === GLOBAL FIXES UX/UI EXPERT === */

/* Fix: Prevenir que cualquier SVG se desborde, específicamente los social links si FSE falla */
svg {
    max-width: 100%;
    height: auto;
}

.wp-block-social-links svg {
    max-width: 24px;
    height: 24px;
}

/* Fix: Asegurar variables locales de colores incluso si theme.json tiene caché */
:root {
    --wp--preset--color--contrast: #000000 !important;
    --wp--preset--color--base: #FFFFFF !important;
    --wp--preset--color--cta: #0056b3 !important;
    --wp--preset--color--accent: #333333 !important;
    --wp--preset--color--surface: #F5F5F5 !important;
}

/* Fix: Sobrescribir las clases pre-generadas por Gutenberg en la BD */
.has-cta-background-color,
.wp-block-button__link.has-cta-background-color {
    background-color: var(--wp--preset--color--cta) !important;
}

.has-cta-color,
.wp-block-button__link.has-cta-color {
    color: var(--wp--preset--color--cta) !important;
}

/* Fix: Cajas de categorías estilizadas correctamente en caso de que block no renderice CSS */
.category-card a {
    text-decoration: none !important;
    display: inline-block;
    padding: 12px 24px;
    background-color: var(--wp--preset--color--contrast);
    color: var(--wp--preset--color--base) !important;
    border-radius: 4px;
    font-weight: 600;
    transition: background 0.3s ease;
}

.category-card a:hover {
    background-color: var(--wp--preset--color--cta);
}

/* === HEADER & LOGO FIXES === */

.site-header {
    background-color: #ffffff;
    border-bottom: 1px solid #eaeaea;
}

.wp-block-site-logo img {
    max-width: 180px !important;
    max-height: 60px !important;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* === WOOCOMMERCE CATALOG — Responsive Grid === */

/* Products grid: 4 cols desktop, 3 tablet, 2 mobile, 1 small */
.woocommerce ul.products {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
    padding: 0;
    list-style: none;
}

.woocommerce ul.products li.product {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    padding-bottom: 20px;
}

.woocommerce ul.products li.product:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 86, 179, 0.12);
}

.woocommerce ul.products li.product img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
}

.woocommerce ul.products li.product .woocommerce-loop-product__title {
    font-size: 16px;
    font-weight: 600;
    padding: 12px 16px 4px;
    color: var(--wp--preset--color--contrast);
    line-height: 1.3;
}

/* === SINGLE PRODUCT — Responsive Layout === */

/* La plantilla FSE usa wp:columns que colapsa automáticamente.
   Estos estilos refinan la experiencia. */
.single-product .wp-block-columns {
    gap: 40px;
    align-items: flex-start;
}

.single-product .wp-block-post-featured-image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.single-product .wp-block-post-title {
    font-size: clamp(24px, 4vw, 36px);
    font-weight: 700;
    color: var(--wp--preset--color--contrast);
    margin-bottom: 20px;
    line-height: 1.2;
}

.single-product .wp-block-post-content h2 {
    font-size: clamp(18px, 2.5vw, 22px);
    font-weight: 600;
    color: var(--wp--preset--color--cta);
    margin-top: 28px;
    margin-bottom: 12px;
    border-bottom: 2px solid var(--wp--preset--color--surface);
    padding-bottom: 8px;
}

.single-product .wp-block-post-content ul {
    padding-left: 20px;
    margin-bottom: 16px;
}

.single-product .wp-block-post-content ul li {
    margin-bottom: 8px;
    line-height: 1.6;
    color: #444;
}

.single-product .wp-block-post-content p {
    line-height: 1.7;
    color: #444;
    margin-bottom: 16px;
}

/* Botón Cotizar — estilo consistente */
.single-product .wp-block-button__link,
.single-product .wp-element-button {
    background-color: var(--wp--preset--color--cta) !important;
    color: #fff !important;
    border-radius: 6px;
    padding: 14px 28px;
    font-weight: 600;
    font-size: 16px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.single-product .wp-block-button__link:hover,
.single-product .wp-element-button:hover {
    background-color: #003d80 !important;
    transform: translateY(-2px);
}

/* === GLOBAL TYPOGRAPHY & SPACING === */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

@media (max-width: 1024px) {
    .woocommerce ul.products {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .site-header {
        padding-top: 8px !important;
        padding-bottom: 8px !important;
        min-height: auto !important;
    }

    .site-header .wp-block-site-logo {
        margin: 0 !important;
    }

    .site-header .wp-block-site-logo img {
        max-width: 140px !important;
        max-height: 45px !important;
        height: auto !important;
    }

    body .site-header .wp-block-buttons {
        display: none !important;
    }

    .woocommerce ul.products {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .woocommerce ul.products li.product img {
        height: 180px;
    }

    /* Colapsar columnas del producto en mobile */
    .single-product .wp-block-columns {
        flex-direction: column !important;
        gap: 24px;
    }

    .single-product .wp-block-column {
        flex-basis: 100% !important;
        padding-left: 0 !important;
    }

    .single-product .wp-block-post-featured-image img {
        max-height: 400px;
        object-fit: cover;
    }
}

@media (max-width: 480px) {
    .woocommerce ul.products {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .woocommerce ul.products li.product img {
        height: 200px;
    }

    .single-product .wp-block-post-title {
        font-size: 22px;
    }

    .single-product .wp-block-button__link {
        width: 100%;
        text-align: center;
    }
}