/* ==========================================================================
   Woo Table Order v2 — Stylesheet
   ========================================================================== */

/* ── Variables ─────────────────────────────────────────────────────────── */
.wto-wrapper {
    --wto-accent:        #e07b39;
    --wto-accent-hover:  color-mix(in srgb, var(--wto-accent) 80%, #000);
    --wto-accent-light:  color-mix(in srgb, var(--wto-accent) 12%, #fff);
    --wto-radius:        8px;
    --wto-shadow:        0 2px 12px rgba(0,0,0,.08);
    --wto-border:        #e5e7eb;
    --wto-text:          #1f2937;
    --wto-text-muted:    #6b7280;
    --wto-bg:            #ffffff;
    --wto-bg-alt:        #f9fafb;
    --wto-sidebar-w:     300px;
    --wto-font:          'Segoe UI', system-ui, -apple-system, sans-serif;
    font-family: var(--wto-font);
    color: var(--wto-text);
    position: relative;
}

/* ── Layout principal ──────────────────────────────────────────────────── */
.wto-main-area     { display: flex; align-items: flex-start; gap: 1.5rem; }
.wto-products-area { flex: 1; min-width: 0; position: relative; }

/* ── Navigateur catégories ─────────────────────────────────────────────── */
.wto-cat-nav { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.wto-cat-btn {
    padding: .45rem 1.1rem;
    border: 2px solid var(--wto-border);
    border-radius: 999px;
    background: var(--wto-bg);
    color: var(--wto-text);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .18s;
    line-height: 1.4;
}
.wto-cat-btn:hover, .wto-cat-btn:focus-visible {
    border-color: var(--wto-accent); color: var(--wto-accent); outline: none;
}
.wto-cat-btn.active { background: var(--wto-accent); border-color: var(--wto-accent); color: #fff; }

/* ── Loader ────────────────────────────────────────────────────────────── */
.wto-loader {
    display: none; position: absolute; inset: 0;
    background: rgba(255,255,255,.7); z-index: 10;
    align-items: center; justify-content: center;
}
.wto-loader.visible { display: flex; }
.wto-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--wto-border); border-top-color: var(--wto-accent);
    border-radius: 50%; animation: wto-spin .7s linear infinite;
}
@keyframes wto-spin { to { transform: rotate(360deg); } }

/* ── Tableau produits ──────────────────────────────────────────────────── */
.wto-table-scroll { overflow-x: auto; }
.wto-table {
    width: 100%; border-collapse: collapse;
    background: var(--wto-bg);
    border-radius: var(--wto-radius);
    box-shadow: var(--wto-shadow);
    overflow: hidden;
    font-size: .9rem;
}
.wto-table thead th {
    background: var(--wto-accent); color: #fff;
    padding: .75rem 1rem; text-align: left;
    font-weight: 600; white-space: nowrap;
}
.wto-table tbody tr {
    border-bottom: 1px solid var(--wto-border); transition: background .15s;
}
.wto-table tbody tr:last-child  { border-bottom: none; }
.wto-table tbody tr:hover       { background: var(--wto-accent-light); }
.wto-table td                   { padding: .75rem 1rem; vertical-align: middle; }

/* Colonnes */
.wto-col-img        { width: 80px; }
.wto-col-name       { width: 150px; min-width: 110px; }
.wto-col-name-desc  { min-width: 180px; }
.wto-col-desc       { color: var(--wto-text-muted); font-size: .85rem; }
.wto-col-price      { width: 90px; white-space: nowrap; font-weight: 600; text-align: right; }
.wto-col-actions    { width: 160px; min-width: 150px; }

/* En-tête prix aligné à droite aussi */
.wto-table thead th.wto-col-price { text-align: right; }

/* Image produit */
.wto-product-img {
    width: 70px; height: 70px; object-fit: cover;
    border-radius: var(--wto-radius); display: block;
}

/* Nom produit */
.wto-product-name { font-weight: 700; color: var(--wto-text); text-decoration: none; }
.wto-product-name:hover { color: var(--wto-accent); }

/* Description courte dans colonne fusionnée */
.wto-product-short-desc {
    margin: .35rem 0 0;
    font-size: .84rem;
    color: var(--wto-text-muted);
    line-height: 1.45;
}

/* Badge stock */
.wto-badge { display: inline-block; margin-top: .2rem; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 500; }
.wto-badge--outofstock { background: #fee2e2; color: #b91c1c; }

/* ── Contrôle quantité ─────────────────────────────────────────────────── */
.wto-add-row { display: flex; flex-direction: column; gap: .35rem; align-items: flex-start; }
.wto-qty-ctrl {
    display: flex; align-items: center;
    border: 1px solid var(--wto-border); border-radius: 6px; overflow: hidden; height: 28px;
}
.wto-qty-btn {
    width: 24px; height: 100%;
    background: var(--wto-bg-alt); border: none;
    cursor: pointer; font-size: .95rem; font-weight: 700;
    color: var(--wto-text); transition: background .15s, color .15s;
    display: flex; align-items: center; justify-content: center; line-height: 1;
}
.wto-qty-btn:hover { background: var(--wto-accent); color: #fff; }
.wto-qty-input {
    width: 36px; text-align: center; border: none;
    border-left: 1px solid var(--wto-border); border-right: 1px solid var(--wto-border);
    height: 100%; font-size: .82rem; font-family: var(--wto-font);
    -moz-appearance: textfield; outline: none;
}
.wto-qty-input::-webkit-outer-spin-button, .wto-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ── Bouton Ajouter / Voir les options ─────────────────────────────────── */
.wto-add-btn {
    padding: .35rem .75rem;
    background: var(--wto-accent); color: #fff;
    border: none; border-radius: 6px;
    font-weight: 600; font-size: .8rem;
    cursor: pointer; transition: background .18s, transform .1s;
    white-space: nowrap;
}
.wto-add-btn:hover   { background: var(--wto-accent-hover); }
.wto-add-btn:active  { transform: scale(.97); }
.wto-add-btn.added   { background: #16a34a; }
.wto-add-btn:disabled { opacity: .6; cursor: not-allowed; }

/* Bouton variante (Voir les options) */
.wto-btn-variable {
    background: transparent;
    border: 2px solid var(--wto-accent);
    color: var(--wto-accent);
}
.wto-btn-variable:hover { background: var(--wto-accent); color: #fff; }

.wto-btn-outofstock { font-size: .82rem; color: var(--wto-text-muted); text-decoration: underline; }

/* ── Pagination ────────────────────────────────────────────────────────── */
.wto-pagination { display: flex; align-items: center; justify-content: center; gap: .75rem; margin-top: 1.25rem; }
.wto-page-btn {
    width: 36px; height: 36px;
    border: 1px solid var(--wto-border); border-radius: var(--wto-radius);
    background: var(--wto-bg); font-size: 1.25rem; cursor: pointer;
    transition: all .15s; display: flex; align-items: center; justify-content: center;
}
.wto-page-btn:hover:not(:disabled) { border-color: var(--wto-accent); color: var(--wto-accent); }
.wto-page-btn:disabled { opacity: .4; cursor: not-allowed; }
.wto-page-info { font-size: .9rem; color: var(--wto-text-muted); }

/* ── Espace vide latéral (alignement multi-tableaux) ───────────────────── */
.wto-sidebar-spacer {
    width: var(--wto-sidebar-w);
    flex-shrink: 0;
    /* Invisible mais maintient la largeur */
}

/* ── Sidebar panier ────────────────────────────────────────────────────── */
.wto-cart-sidebar {
    width: var(--wto-sidebar-w); flex-shrink: 0;
    position: sticky; top: 80px;
    max-height: calc(100vh - 100px); overflow-y: auto;
    background: var(--wto-bg);
    border: 1px solid var(--wto-border); border-radius: var(--wto-radius);
    box-shadow: var(--wto-shadow); scrollbar-width: thin;
}
.wto-cart-sidebar-inner { padding: 1rem; }
.wto-cart-title {
    font-size: 1.05rem; font-weight: 700; margin: 0 0 1rem;
    display: flex; align-items: center; gap: .5rem;
}
.wto-cart-count-badge {
    background: var(--wto-accent); color: #fff;
    font-size: .72rem; font-weight: 700;
    border-radius: 999px; min-width: 20px; height: 20px;
    display: inline-flex; align-items: center; justify-content: center; padding: 0 .35rem;
}
.wto-cart-items { display: flex; flex-direction: column; gap: .6rem; }
.wto-cart-item {
    display: grid; grid-template-columns: 48px 1fr auto;
    gap: .5rem; align-items: center;
    padding: .5rem 0; border-bottom: 1px solid var(--wto-border); font-size: .85rem;
}
.wto-cart-item:last-child { border-bottom: none; }
.wto-cart-item-img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.wto-cart-item-info { min-width: 0; }
.wto-cart-item-name {
    font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
}
.wto-cart-item-meta { color: var(--wto-text-muted); font-size: .8rem; margin-top: .15rem; display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.wto-cart-item-qty  { display: flex; align-items: center; gap: .2rem; margin-top: .2rem; }
.wto-cart-qty-btn {
    width: 22px; height: 22px;
    border: 1px solid var(--wto-border); border-radius: 4px;
    background: var(--wto-bg-alt); font-weight: 700; font-size: .8rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .12s, color .12s; line-height: 1;
}
.wto-cart-qty-btn:hover { background: var(--wto-accent); color: #fff; border-color: var(--wto-accent); }
.wto-cart-qty-val { font-size: .85rem; min-width: 18px; text-align: center; }
.wto-cart-item-remove {
    background: none; border: none; cursor: pointer; color: #dc2626;
    font-size: 1.1rem; padding: .2rem; opacity: .6; transition: opacity .15s; align-self: start;
}
.wto-cart-item-remove:hover { opacity: 1; }
.wto-cart-empty-msg { color: var(--wto-text-muted); font-size: .9rem; text-align: center; padding: 1.5rem 0; display: none; }
.wto-cart-empty-msg.visible { display: block; }
.wto-cart-footer { margin-top: 1rem; }
.wto-cart-total-row {
    display: flex; justify-content: space-between;
    font-weight: 700; padding: .6rem 0;
    border-top: 2px solid var(--wto-border); margin-bottom: .75rem;
}

/* ── Boutons génériques ────────────────────────────────────────────────── */
.wto-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .6rem 1.1rem; border-radius: var(--wto-radius);
    font-weight: 600; font-size: .875rem; text-decoration: none;
    cursor: pointer; transition: background .18s, color .18s; border: 2px solid transparent;
}
.wto-btn--primary   { background: var(--wto-accent); color: #fff; border-color: var(--wto-accent); }
.wto-btn--primary:hover { background: var(--wto-accent-hover); border-color: var(--wto-accent-hover); color: #fff; }
.wto-btn--secondary { background: var(--wto-bg); color: var(--wto-accent); border-color: var(--wto-accent); }
.wto-btn--secondary:hover { background: var(--wto-accent-light); }
.wto-btn--full { display: flex; margin-bottom: .5rem; }

/* ── Tableau récapitulatif ─────────────────────────────────────────────── */
.wto-summary-table-wrap {
    margin-top: 2rem; padding: 1.25rem;
    background: var(--wto-bg); border: 1px solid var(--wto-border);
    border-radius: var(--wto-radius); box-shadow: var(--wto-shadow);
}
.wto-summary-title { font-size: 1rem; font-weight: 700; margin: 0 0 1rem; }
.wto-summary-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.wto-summary-table th {
    background: var(--wto-bg-alt); padding: .55rem .75rem;
    text-align: left; font-weight: 600; border-bottom: 2px solid var(--wto-border);
}
.wto-summary-table td { padding: .55rem .75rem; border-bottom: 1px solid var(--wto-border); vertical-align: middle; }
.wto-summary-table tfoot td { border-bottom: none; font-weight: 700; padding-top: .75rem; }
.wto-summary-remove { background: none; border: none; color: #dc2626; cursor: pointer; font-size: 1rem; opacity: .6; transition: opacity .15s; }
.wto-summary-remove:hover { opacity: 1; }
.wto-summary-actions { display: flex; gap: .75rem; margin-top: 1rem; flex-wrap: wrap; }

/* ── Popup variantes ───────────────────────────────────────────────────── */
.wto-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.55);
    z-index: 99999; display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    animation: wto-fade-in .2s ease;
}
.wto-modal-overlay[hidden] { display: none; }
@keyframes wto-fade-in { from { opacity: 0; } to { opacity: 1; } }

.wto-modal {
    background: var(--wto-bg); border-radius: calc(var(--wto-radius)*1.5);
    box-shadow: 0 8px 40px rgba(0,0,0,.22);
    width: 100%; max-width: 520px;
    padding: 1.5rem; position: relative;
    animation: wto-slide-up .25s ease;
    max-height: 90vh; overflow-y: auto;
}
@keyframes wto-slide-up { from { transform: translateY(20px); opacity:0; } to { transform: translateY(0); opacity:1; } }

.wto-modal-close {
    position: absolute; top: .75rem; right: .75rem;
    background: var(--wto-bg-alt); border: 1px solid var(--wto-border);
    border-radius: 50%; width: 28px; height: 28px;
    font-size: .85rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .15s; line-height: 1;
}
.wto-modal-close:hover { background: #fee2e2; color: #dc2626; border-color: #dc2626; }

.wto-modal-header {
    display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.25rem;
}
.wto-modal-img { width: 80px; height: 80px; object-fit: cover; border-radius: var(--wto-radius); flex-shrink: 0; }
.wto-modal-title { font-size: 1.1rem; font-weight: 700; margin: 0 0 .35rem; line-height: 1.3; }
.wto-modal-desc { font-size: .85rem; color: var(--wto-text-muted); line-height: 1.45; }

/* Attributs dans le modal */
.wto-modal-attributes { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
.wto-attr-group label { display: block; font-weight: 600; margin-bottom: .4rem; font-size: .9rem; }
.wto-attr-group select {
    width: 100%; padding: .5rem .8rem;
    border: 1px solid var(--wto-border); border-radius: var(--wto-radius);
    font-size: .9rem; font-family: var(--wto-font);
    background: var(--wto-bg); cursor: pointer;
    transition: border-color .15s; outline: none;
}
.wto-attr-group select:focus { border-color: var(--wto-accent); }

.wto-modal-variation-price {
    font-size: 1.15rem; font-weight: 700; color: var(--wto-accent);
    min-height: 1.5em; margin-bottom: .75rem;
    transition: opacity .2s;
}

.wto-modal-footer { display: flex; align-items: center; gap: .75rem; }
.wto-modal-qty { flex-shrink: 0; }
.wto-modal-add-btn { flex: 1; padding: .6rem 1rem; font-size: .95rem; }

.wto-modal-msg {
    margin-top: .75rem; font-size: .875rem;
    min-height: 1.4em; text-align: center;
}
.wto-modal-msg.error   { color: #dc2626; }
.wto-modal-msg.success { color: #16a34a; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.wto-toast {
    position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 100000;
    background: #1f2937; color: #fff;
    padding: .7rem 1.2rem; border-radius: var(--wto-radius);
    font-size: .875rem; font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
    opacity: 0; transform: translateY(8px); pointer-events: none;
    transition: opacity .25s, transform .25s; max-width: 300px;
}
.wto-toast.show    { opacity: 1; transform: translateY(0); }
.wto-toast.success { background: #16a34a; }
.wto-toast.error   { background: #dc2626; }

/* ── Aucun produit ─────────────────────────────────────────────────────── */
.wto-no-products { text-align: center; padding: 2.5rem; color: var(--wto-text-muted); font-size: .95rem; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1024px) { .wto-wrapper { --wto-sidebar-w: 260px; } }

/* ── Tablette : sidebar en bas, quelques colonnes masquées ── */
@media (max-width: 768px) {
    .wto-main-area { flex-direction: column; }
    .wto-cart-sidebar { width: 100%; position: static; max-height: 400px; order: 2; }
    .wto-sidebar-spacer { display: none; }
    .wto-summary-actions { flex-direction: column; }
    .wto-modal { padding: 1rem; }

    /* Masquer description séparée sur tablette */
    .wto-col-desc { display: none; }
}

/* ── Mobile : vue "cartes" au lieu du tableau ── */
@media (max-width: 600px) {

    /* Cache les en-têtes et transforme chaque ligne en carte */
    .wto-table thead { display: none; }

    .wto-table,
    .wto-table tbody,
    .wto-table tr,
    .wto-table td {
        display: block;
        width: 100%;
    }

    .wto-product-row {
        display: grid !important;
        grid-template-columns: 64px 1fr;
        grid-template-rows: auto auto auto;
        gap: 0 .75rem;
        padding: .75rem;
        border-bottom: 1px solid var(--wto-border);
        background: var(--wto-bg);
    }
    .wto-product-row:hover { background: var(--wto-accent-light); }

    /* Image : occupe les 2 lignes de gauche */
    .wto-col-img {
        grid-column: 1;
        grid-row: 1 / 3;
        width: auto;
        padding: 0;
    }
    .wto-product-img { width: 58px; height: 58px; }

    /* Nom / Nom+Description : droite haut */
    .wto-col-name,
    .wto-col-name-desc {
        grid-column: 2;
        grid-row: 1;
        padding: 0;
        width: auto;
        min-width: 0;
        font-size: .875rem;
    }

    /* Description seule (si template 'default') : droite milieu */
    .wto-col-desc {
        display: block;
        grid-column: 2;
        grid-row: 2;
        padding: 0;
        margin-top: .2rem;
        width: auto;
        font-size: .875rem;
    }

    /* Prix : sous l'image, pleine largeur */
    .wto-col-price {
        grid-column: 1 / 3;
        grid-row: 3;
        padding: .4rem 0 0;
        width: auto;
        text-align: left;
        font-size: .95rem;
    }

    /* Actions : sous le prix, pleine largeur */
    .wto-col-actions {
        grid-column: 1 / 3;
        grid-row: 4;
        padding: .4rem 0 0;
        width: auto;
        min-width: 0;
    }

    /* Contrôles quantité en ligne */
    .wto-add-row { flex-direction: row; align-items: center; gap: .5rem; }

    /* Sidebar panier compacte */
    .wto-cart-sidebar { max-height: 320px; }

    /* Modal adapté mobile */
    .wto-modal-overlay { align-items: flex-end; padding: 0; }
    .wto-modal {
        border-radius: calc(var(--wto-radius)*2) calc(var(--wto-radius)*2) 0 0;
        max-height: 90vh;
        animation: wto-slide-up-mobile .25s ease;
    }
    @keyframes wto-slide-up-mobile {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
    .wto-modal-header { flex-direction: column; align-items: center; text-align: center; }
    .wto-modal-img { width: 100px; height: 100px; }
}
