/* =========================================================
   VARIABLES
========================================================= */

:root {
    --primary: #0e7a46;
    --primary-dark: #075f35;
    --primary-light: #e8f6ef;

    --secondary: #ffb800;
    --danger: #d92d20;
    --warning: #d97706;

    --text: #18231d;
    --text-soft: #64726a;
    --background: #f5f7f6;
    --surface: #ffffff;
    --border: #dde5e0;

    --shadow-sm: 0 4px 14px rgba(16, 46, 31, 0.07);
    --shadow-md: 0 14px 35px rgba(16, 46, 31, 0.12);

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;

    --container-width: 1240px;
}


/* =========================================================
   RESET
========================================================= */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color: var(--text);
    background: var(--background);
}

body.cart-open {
    overflow: hidden;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    border: 0;
}

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

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

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* =========================================================
   EN-TÊTE
========================================================= */

.shop-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.header-container {
    width: min(calc(100% - 32px), var(--container-width));
    min-height: 74px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
}

.shop-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.logo-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: #ffffff;
    background: var(--primary);
    border-radius: 12px;
    font-size: 1.25rem;
    font-weight: 900;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.logo-text strong {
    font-size: 1rem;
    letter-spacing: 0.04em;
}

.logo-text small {
    margin-top: 4px;
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.18em;
}

.selected-store {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-right: auto;
    padding-left: 24px;
    border-left: 1px solid var(--border);
}

.selected-store-label {
    color: var(--text-soft);
    font-size: 0.75rem;
}

.selected-store-name {
    max-width: 320px;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-button {
    position: relative;
    min-height: 45px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 15px;
    color: #ffffff;
    background: var(--primary);
    border-radius: 14px;
    cursor: pointer;
    font-weight: 800;
    transition:
        background-color 0.2s ease,
        transform 0.2s ease;
}

.cart-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.cart-button-icon {
    font-size: 1.05rem;
}

.cart-count {
    min-width: 24px;
    height: 24px;
    display: inline-grid;
    place-items: center;
    padding: 0 6px;
    color: var(--primary-dark);
    background: #ffffff;
    border-radius: 999px;
    font-size: 0.75rem;
}


/* =========================================================
   HERO
========================================================= */

.store-hero {
    padding: 36px 16px 18px;
}

.store-hero-container {
    position: relative;
    width: min(100%, var(--container-width));
    min-height: 210px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    overflow: hidden;
    padding: 40px;
    color: #ffffff;
    background:
        radial-gradient(
            circle at 85% 25%,
            rgba(255, 255, 255, 0.18),
            transparent 28%
        ),
        linear-gradient(
            135deg,
            var(--primary-dark),
            var(--primary)
        );
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.store-hero-content {
    position: relative;
    z-index: 2;
    max-width: 700px;
}

.store-eyebrow {
    margin: 0 0 10px;
    color: #d6f5e5;
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.store-hero h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 3.7rem);
    line-height: 1.05;
}

.store-address {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 18px 0 0;
    color: #effbf5;
}

.store-description {
    margin: 10px 0 0;
    color: #d9f2e5;
    font-size: 1rem;
}

.store-hero-decoration {
    position: absolute;
    right: 7%;
    top: 50%;
    transform: translateY(-50%);
    font-size: clamp(5rem, 12vw, 9rem);
    opacity: 0.2;
}


/* =========================================================
   CATALOGUE
========================================================= */

.catalogue-section {
    padding: 18px 16px 90px;
}

.catalogue-container {
    width: min(100%, var(--container-width));
    margin: 0 auto;
}

.catalogue-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.search-wrapper {
    position: relative;
    width: min(100%, 560px);
}

.search-icon {
    position: absolute;
    left: 17px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.product-search {
    width: 100%;
    height: 52px;
    padding: 0 48px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 15px;
    outline: none;
    box-shadow: var(--shadow-sm);
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.product-search:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(14, 122, 70, 0.12);
}

.clear-search-button {
    position: absolute;
    right: 11px;
    top: 50%;
    width: 32px;
    height: 32px;
    transform: translateY(-50%);
    color: var(--text-soft);
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
}

.clear-search-button:hover {
    color: var(--text);
    background: var(--background);
}

.catalogue-summary {
    flex-shrink: 0;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.catalogue-summary span:first-child {
    color: var(--text);
    font-weight: 900;
}


/* =========================================================
   FILTRES
========================================================= */

.category-filter-wrapper {
    display: flex;
    gap: 9px;
    margin-bottom: 24px;
    padding: 2px 0 8px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.category-filter {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 17px;
    color: var(--text-soft);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 750;
    white-space: nowrap;
    transition:
        color 0.2s ease,
        background-color 0.2s ease,
        border-color 0.2s ease;
}

.category-filter:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.category-filter.active {
    color: #ffffff;
    background: var(--primary);
    border-color: var(--primary);
}


/* =========================================================
   GRILLE PRODUITS
========================================================= */

.products-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.product-card {
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition:
        transform 0.22s ease,
        box-shadow 0.22s ease,
        border-color 0.22s ease;
}

.product-card:hover {
    transform: translateY(-4px);
    border-color: #c7d8ce;
    box-shadow: var(--shadow-md);
}

.product-card.filtered-out {
    display: none;
}

.product-image-wrapper {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #edf2ef;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.product-card:hover .product-image {
    transform: scale(1.04);
}

.product-image-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: #91a399;
    background:
        linear-gradient(
            135deg,
            #edf2ef,
            #f8faf9
        );
    font-size: 3rem;
}

.product-category-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    max-width: calc(100% - 24px);
    overflow: hidden;
    padding: 6px 9px;
    color: var(--primary-dark);
    background: rgba(255, 255, 255, 0.92);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    font-size: 0.7rem;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 17px;
}

.product-code {
    margin: 0 0 7px;
    color: var(--text-soft);
    font-size: 0.7rem;
    font-weight: 650;
    text-transform: uppercase;
}

.product-name {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    font-size: 1rem;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.product-description {
    display: -webkit-box;
    min-height: 42px;
    margin: 8px 0 0;
    overflow: hidden;
    color: var(--text-soft);
    font-size: 0.82rem;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.product-description-empty {
    font-style: italic;
}

.product-stock {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 13px;
    color: var(--text-soft);
    font-size: 0.76rem;
}

.stock-dot {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
    background: var(--primary);
    border-radius: 50%;
}

.stock-dot-warning {
    background: var(--warning);
}

.product-bottom {
    margin-top: auto;
    padding-top: 16px;
}

.product-price {
    margin-bottom: 13px;
    color: var(--primary-dark);
    font-size: 1.25rem;
    font-weight: 950;
}

.product-price span {
    font-size: 0.72rem;
    font-weight: 800;
}

.product-actions {
    min-height: 43px;
}

.add-to-cart-button {
    width: 100%;
    min-height: 43px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 12px;
    color: #ffffff;
    background: var(--primary);
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 850;
    transition:
        background-color 0.2s ease,
        transform 0.2s ease;
}

.add-to-cart-button:hover {
    background: var(--primary-dark);
}

.add-to-cart-button:active {
    transform: scale(0.97);
}


/* =========================================================
   CONTRÔLE DE QUANTITÉ DANS LA CARTE
========================================================= */

.product-quantity-control {
    width: 100%;
    min-height: 43px;
    display: grid;
    grid-template-columns: 42px 1fr 42px;
    align-items: center;
    overflow: hidden;
    background: var(--primary-light);
    border: 1px solid #cce6d8;
    border-radius: 12px;
}

.product-quantity-button {
    height: 100%;
    color: var(--primary-dark);
    background: transparent;
    cursor: pointer;
    font-size: 1.25rem;
    font-weight: 900;
}

.product-quantity-button:hover {
    background: rgba(14, 122, 70, 0.1);
}

.product-quantity-value {
    text-align: center;
    font-weight: 900;
}


/* =========================================================
   ÉTATS VIDES
========================================================= */

.empty-catalogue,
.no-search-results {
    padding: 70px 24px;
    text-align: center;
    background: var(--surface);
    border: 1px dashed #cbd7d0;
    border-radius: var(--radius-lg);
}

.empty-state-icon {
    margin-bottom: 14px;
    font-size: 3rem;
}

.empty-catalogue h2,
.no-search-results h2 {
    margin: 0;
    font-size: 1.4rem;
}

.empty-catalogue p,
.no-search-results p {
    max-width: 500px;
    margin: 10px auto 22px;
    color: var(--text-soft);
    line-height: 1.6;
}

.primary-link-button,
.secondary-button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 850;
}

.primary-link-button {
    color: #ffffff;
    background: var(--primary);
}

.secondary-button {
    color: var(--primary-dark);
    background: var(--primary-light);
}


/* =========================================================
   PANIER LATÉRAL
========================================================= */

.cart-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(12, 22, 16, 0.52);
    backdrop-filter: blur(3px);
}

.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 100;
    width: min(430px, 100%);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    box-shadow: -20px 0 50px rgba(12, 31, 20, 0.18);
    transform: translateX(105%);
    transition: transform 0.28s ease;
}

.cart-drawer.open {
    transform: translateX(0);
}

.cart-drawer-header {
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.cart-drawer-eyebrow {
    margin: 0 0 3px;
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.cart-drawer-header h2 {
    margin: 0;
    font-size: 1.35rem;
}

.close-cart-button {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    color: var(--text);
    background: var(--background);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.7rem;
}

.cart-drawer-store {
    display: flex;
    gap: 5px;
    padding: 12px 20px;
    color: var(--text-soft);
    background: var(--primary-light);
    font-size: 0.78rem;
}

.cart-drawer-store strong {
    color: var(--primary-dark);
}

.empty-cart {
    flex: 1;
    display: grid;
    align-content: center;
    justify-items: center;
    padding: 30px;
    text-align: center;
}

.empty-cart-icon {
    margin-bottom: 14px;
    font-size: 3.6rem;
    opacity: 0.65;
}

.empty-cart h3 {
    margin: 0;
}

.empty-cart p {
    margin: 8px 0 0;
    color: var(--text-soft);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 8px 20px 20px;
}

.cart-item {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr) auto;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.cart-item-image {
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--background);
    border-radius: 12px;
    font-size: 1.8rem;
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item-content {
    min-width: 0;
}

.cart-item-name {
    margin: 0;
    overflow: hidden;
    font-size: 0.87rem;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-item-price {
    margin: 5px 0 10px;
    color: var(--primary-dark);
    font-size: 0.82rem;
    font-weight: 850;
}

.cart-item-controls {
    width: max-content;
    display: grid;
    grid-template-columns: 31px 34px 31px;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 9px;
}

.cart-item-controls button {
    height: 31px;
    color: var(--text);
    background: var(--background);
    cursor: pointer;
    font-weight: 900;
}

.cart-item-controls span {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 900;
}

.remove-cart-item {
    align-self: start;
    padding: 4px;
    color: var(--danger);
    background: transparent;
    cursor: pointer;
    font-size: 1.1rem;
}

.cart-drawer-footer {
    padding: 18px 20px max(18px, env(safe-area-inset-bottom));
    background: #ffffff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -10px 25px rgba(12, 31, 20, 0.06);
}

.cart-summary-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 8px;
    color: var(--text-soft);
    font-size: 0.88rem;
}

.cart-summary-line strong {
    color: var(--text);
}

.cart-total-line {
    margin-top: 12px;
    margin-bottom: 18px;
    padding-top: 15px;
    border-top: 1px dashed var(--border);
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 900;
}

.cart-total-line strong {
    color: var(--primary-dark);
    font-size: 1.25rem;
}

.checkout-button {
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 18px;
    color: #ffffff;
    background: var(--primary);
    border-radius: 13px;
    font-weight: 900;
    transition: background-color 0.2s ease;
}

.checkout-button:hover {
    background: var(--primary-dark);
}

.continue-shopping-button {
    width: 100%;
    min-height: 42px;
    margin-top: 8px;
    color: var(--text-soft);
    background: transparent;
    cursor: pointer;
    font-weight: 750;
}


/* =========================================================
   TOAST
========================================================= */

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 120;
    max-width: calc(100% - 32px);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 17px;
    color: #ffffff;
    background: #15241c;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 20px);
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
}

.toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast-icon {
    width: 23px;
    height: 23px;
    display: grid;
    place-items: center;
    color: var(--primary-dark);
    background: #d8f8e7;
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 900;
}


/* =========================================================
   BARRE PANIER MOBILE
========================================================= */

.mobile-cart-bar {
    position: fixed;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    z-index: 60;
    min-height: 58px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 15px;
    color: #ffffff;
    background: var(--primary-dark);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
}

.mobile-cart-bar span {
    font-size: 0.77rem;
}

.mobile-cart-bar span:nth-child(2) {
    font-size: 0.95rem;
    font-weight: 900;
}


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

@media (max-width: 1050px) {
    .products-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 780px) {
    .header-container {
        min-height: 66px;
        gap: 12px;
    }

    .selected-store {
        padding-left: 12px;
    }

    .selected-store-label {
        display: none;
    }

    .selected-store-name {
        max-width: 180px;
        font-size: 0.85rem;
    }

    .cart-button-text {
        display: none;
    }

    .store-hero {
        padding-top: 20px;
    }

    .store-hero-container {
        min-height: 190px;
        padding: 28px 24px;
    }

    .catalogue-tools {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .search-wrapper {
        width: 100%;
    }

    .catalogue-summary {
        padding-left: 3px;
    }

    .products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 13px;
    }

    .product-content {
        padding: 13px;
    }

    .product-description {
        min-height: 38px;
    }

    .toast {
        bottom: 86px;
    }

    .mobile-cart-bar:not([hidden]) {
        display: flex;
    }
}

@media (max-width: 520px) {
    .header-container {
        width: min(calc(100% - 20px), var(--container-width));
    }

    .logo-text {
        display: none;
    }

    .logo-icon {
        width: 39px;
        height: 39px;
    }

    .selected-store {
        border-left: 0;
        padding-left: 0;
    }

    .selected-store-name {
        max-width: 150px;
    }

    .cart-button {
        min-width: 45px;
        padding: 0 10px;
    }

    .cart-button-icon {
        display: none;
    }

    .store-hero,
    .catalogue-section {
        padding-right: 10px;
        padding-left: 10px;
    }

    .store-hero-container {
        min-height: 170px;
        padding: 24px 20px;
        border-radius: 18px;
    }

    .store-hero h1 {
        font-size: 1.8rem;
    }

    .store-address {
        margin-top: 13px;
        font-size: 0.84rem;
    }

    .store-description {
        font-size: 0.86rem;
    }

    .store-hero-decoration {
        right: 4%;
        font-size: 5.8rem;
    }

    .product-search {
        height: 49px;
    }

    .products-grid {
        gap: 10px;
    }

    .product-category-badge {
        top: 8px;
        left: 8px;
        max-width: calc(100% - 16px);
        padding: 5px 7px;
        font-size: 0.61rem;
    }

    .product-content {
        padding: 11px;
    }

    .product-code {
        font-size: 0.61rem;
    }

    .product-name {
        font-size: 0.88rem;
    }

    .product-description {
        display: none;
    }

    .product-stock {
        margin-top: 9px;
        font-size: 0.66rem;
    }

    .product-bottom {
        padding-top: 12px;
    }

    .product-price {
        margin-bottom: 10px;
        font-size: 1rem;
    }

    .add-to-cart-button {
        min-height: 40px;
        padding: 7px 8px;
        font-size: 0.75rem;
    }

    .product-quantity-control {
        min-height: 40px;
        grid-template-columns: 35px 1fr 35px;
    }

    .cart-drawer {
        width: 100%;
    }
}