:root {
    --brand-primary: #9E1B22;
    --brand-secondary: #2E6F40;
    --bg-body: #F8F9FA;
    --bg-card: #FFFFFF;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    --radius: 10px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.07);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.09);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.45;
}

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

.site-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =========================================================
   1. MENÚ SUPERIOR INTEL·LIGENT (Auto-hide on scroll down)
   ========================================================= */
.smart-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #FFFFFF;
    border-bottom: 2px solid var(--brand-primary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    transition: transform 0.26s ease-in-out;
}

.smart-header.header-hidden {
    transform: translateY(-105%);
}

.header-container {
    max-width: 1380px;
    margin: 0 auto;
    padding: 0.55rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.brand-logo {
    height: 46px;
    width: auto;
    border-radius: 8px;
}

.brand-titles {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--brand-primary);
    line-height: 1.1;
}

.brand-slogan {
    font-size: 0.76rem;
    color: var(--brand-secondary);
    font-weight: 600;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.nav-item {
    font-size: 1.02rem;
    font-weight: 700;
    color: #222;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover, .nav-item.active {
    background-color: var(--brand-primary);
    color: #FFFFFF;
}

.nav-sep {
    color: #CBD5E1;
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.fav-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.42rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    background: #FFF;
}

.fav-pill:hover {
    border-color: var(--brand-primary);
}

.pill-count {
    background: var(--brand-primary);
    color: #FFF;
    font-size: 0.75rem;
    padding: 0.05rem 0.42rem;
    border-radius: 99px;
}

.cart-pill {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: var(--brand-secondary);
    color: #FFFFFF;
    padding: 0.38rem 0.9rem;
    border-radius: 8px;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.cart-pill:hover {
    filter: brightness(1.08);
}

.cart-pill-info {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.cart-pill-title {
    font-size: 0.78rem;
    opacity: 0.92;
}

.cart-pill-amount {
    font-size: 0.95rem;
}

/* =========================================================
   CONTINGUT PRINCIPAL & UTILITATS
   ========================================================= */
.main-content {
    flex: 1;
    max-width: 1380px;
    width: 100%;
    margin: 0 auto;
    padding: 1.2rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.05rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.92rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--brand-primary);
    color: #FFF;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-secondary {
    background: var(--brand-secondary);
    color: #FFF;
}

.btn-secondary:hover {
    filter: brightness(1.1);
}

.btn-outline {
    background: #FFF;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

/* =========================================================
   BOTIGA ONLINE (ESTIL BONÀREA)
   ========================================================= */
.shop-toolbar {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 240px;
    max-width: 460px;
    border: 1px solid #CBD5E1;
    border-radius: 99px;
    padding: 0.35rem 0.85rem;
    background: #F8FAFC;
}

.search-box input {
    border: none;
    background: transparent;
    width: 100%;
    font-size: 0.95rem;
    outline: none;
    margin-left: 0.4rem;
}

.quick-filters {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.filter-chip {
    background: #F3F4F6;
    border: 1px solid transparent;
    padding: 0.35rem 0.75rem;
    border-radius: 99px;
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
}

.filter-chip.active {
    background: #FEE2E2;
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

/* Graella d'icones de famílies només entrar a la botiga */
.family-icons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.family-icon-card {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.9rem 0.6rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
}

.family-icon-card:hover, .family-icon-card.active {
    transform: translateY(-2px);
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-md);
}

.family-emoji-circle {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #FEF2F2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.9rem;
}

.family-icon-title {
    font-size: 0.86rem;
    font-weight: 700;
    color: #1F2937;
}

/* Layout Botiga amb Menú Lateral Esquerre + Graella Densa de Productes */
.shop-main-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 1.25rem;
    align-items: start;
}

.category-sidebar {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    position: sticky;
    top: 76px;
}

.sidebar-header {
    background: #262626;
    color: #FFFFFF;
    padding: 0.7rem 1rem;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-tree {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-tree li {
    border-bottom: 1px solid #F1F5F9;
}

.sidebar-cat-btn {
    width: 100%;
    background: transparent;
    border: none;
    padding: 0.65rem 0.9rem;
    text-align: left;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1F2937;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-cat-btn:hover, .sidebar-cat-btn.active {
    background: #FEF2F2;
    color: var(--brand-primary);
}

.sidebar-sublist {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #F8FAFC;
}

.sidebar-sub-btn {
    width: 100%;
    background: transparent;
    border: none;
    padding: 0.48rem 0.9rem 0.48rem 2.1rem;
    text-align: left;
    font-size: 0.84rem;
    color: #4B5563;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
}

.sidebar-sub-btn:hover, .sidebar-sub-btn.active {
    color: var(--brand-primary);
    font-weight: 700;
    background: #FEE2E2;
}

/* GRAELLA COMPACTA DE PRODUCTES (4-5 per fila en PC, 2 en mòbil) */
.products-dense-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
    gap: 0.85rem;
}

.product-card {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.7rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.product-card:hover {
    border-color: #CBD5E1;
    box-shadow: var(--shadow-md);
}

.product-badges {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    display: flex;
    gap: 0.25rem;
    z-index: 2;
}

.badge-tag {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.12rem 0.42rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-eco {
    background: #DCFCE7;
    color: #166534;
}

.badge-new {
    background: #FEF3C7;
    color: #92400E;
}

.badge-offer {
    background: #FEE2E2;
    color: #991B1B;
}

.fav-btn {
    position: absolute;
    top: 0.45rem;
    right: 0.45rem;
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    z-index: 2;
}

.product-thumb-box {
    height: 120px;
    background: #F8FAFC;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-bottom: 0.55rem;
    overflow: hidden;
}

.product-thumb-box img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.product-thumb-placeholder {
    font-size: 3.1rem;
}

.product-title {
    font-size: 0.89rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.25rem 0;
    cursor: pointer;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.45em;
}

.product-title:hover {
    color: var(--brand-primary);
}

.product-format {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.product-price-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.55rem;
}

.product-main-price {
    font-size: 1.08rem;
    font-weight: 800;
    color: #111827;
}

.product-unit-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.product-ref-kg {
    font-size: 0.73rem;
    color: #6B7280;
}

.buy-direct-btn {
    width: 100%;
    background: #F0FDF4;
    border: 1px solid #86EFAC;
    color: #166534;
    font-weight: 700;
    font-size: 0.84rem;
    padding: 0.42rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.buy-direct-btn:hover {
    background: var(--brand-secondary);
    border-color: var(--brand-secondary);
    color: #FFFFFF;
}

.qty-inline-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--brand-secondary);
    color: #FFF;
    border-radius: 6px;
    padding: 0.2rem 0.35rem;
}

.qty-inline-control button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #FFF;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    font-weight: 800;
    cursor: pointer;
}

.qty-inline-control span {
    font-size: 0.82rem;
    font-weight: 700;
}

/* =========================================================
   MODAL DE FITXA DETALLADA D'ARTICLE
   ========================================================= */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.modal-card {
    background: #FFFFFF;
    border-radius: 14px;
    max-width: 720px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: 0 20px 35px rgba(0,0,0,0.2);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    background: #F1F5F9;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
}

.detail-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1.4rem;
}

.detail-specs {
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
    padding-top: 0.85rem;
    display: grid;
    gap: 0.45rem;
    font-size: 0.88rem;
}

/* =========================================================
   SECCIONS INICI, PRODUCTORS, TRANSPORT, COMANDA I ADMIN
   ========================================================= */
.hero-banner {
    background: linear-gradient(135deg, #FFF5F5 0%, #F0FDF4 100%);
    border: 1px solid #FECACA;
    border-radius: 14px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.hero-content {
    max-width: 720px;
}

.hero-content h1 {
    font-size: 1.85rem;
    color: var(--brand-primary);
    margin: 0 0 0.6rem 0;
}

.info-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.1rem;
    margin-bottom: 1.75rem;
}

.info-card {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.info-card h3 {
    margin-top: 0;
    color: var(--brand-primary);
}

.producers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.15rem;
}

.producer-card {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.checkout-layout {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.form-group {
    margin-bottom: 0.85rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.form-control {
    width: 100%;
    padding: 0.52rem 0.7rem;
    border: 1px solid #CBD5E1;
    border-radius: 7px;
    font-size: 0.92rem;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* =========================================================
   2. PEU DE PÀGINA & BOTÓ WHATSAPP
   ========================================================= */
.site-footer {
    background: #1F2937;
    color: #E5E7EB;
    margin-top: 2.5rem;
    padding: 2rem 1.2rem 1rem;
    font-size: 0.88rem;
}

.footer-container {
    max-width: 1380px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.footer-col h4 {
    color: #FFFFFF;
    margin: 0 0 0.6rem 0;
    font-size: 1rem;
}

.footer-col p {
    margin: 0.3rem 0;
    color: #D1D5DB;
}

.footer-links {
    margin-top: 0.7rem;
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: #93C5FD;
}

.footer-bottom {
    max-width: 1380px;
    margin: 1.4rem auto 0;
    padding-top: 0.9rem;
    border-top: 1px solid #374151;
    text-align: center;
    font-size: 0.79rem;
    color: #9CA3AF;
}

.whatsapp-float {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    background: #25D366;
    color: #FFFFFF;
    padding: 0.65rem 1.05rem;
    border-radius: 99px;
    font-weight: 800;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.4);
    z-index: 1500;
}

.whatsapp-float:hover {
    transform: scale(1.04);
}

/* Taules d'administració */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.admin-table th, .admin-table td {
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.admin-table th {
    background: #F8FAFC;
    font-weight: 700;
}

/* =========================================================
   RESPONSIVE MÒBIL
   ========================================================= */
@media (max-width: 900px) {
    .shop-main-layout {
        grid-template-columns: 1fr;
    }

    .category-sidebar {
        position: static;
    }

    .checkout-layout, .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .hide-sm {
        display: none;
    }

    .products-dense-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .family-icons-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.55rem;
    }

    .header-container {
        padding: 0.45rem 0.75rem;
    }

    .main-nav {
        width: 100%;
        justify-content: center;
        order: 3;
        padding-top: 0.25rem;
        border-top: 1px solid #F1F5F9;
    }
}
