/* =====================================================
   Marendins – Comanda WhatsApp v2.1
   Especificitat màxima: #mwo-app prefix a tot
   ===================================================== */

#mwo-app {
    --accent: var(--mwo-accent, #005FFF);
    --green:  #25D366;
    --red:    #e53e3e;
    --g50:    #f8f9fa;
    --g100:   #f1f3f5;
    --g200:   #e9ecef;
    --g400:   #adb5bd;
    --g600:   #6c757d;
    --g900:   #1a1a2e;
    --rsm:    8px;
    --rmd:    14px;
    --rlg:    20px;
    --sh1:    0 1px 4px rgba(0,0,0,.07);
    --sh2:    0 4px 20px rgba(0,0,0,.10);
    --sh3:    0 12px 40px rgba(0,0,0,.16);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--g900);
    background: var(--g50);
    min-height: 60vh;
    box-sizing: border-box;
}
#mwo-app *, #mwo-app *::before, #mwo-app *::after { box-sizing: border-box; }

/* Reset global de botons dins del plugin */
#mwo-app button {
    font-family: inherit;
    font-size: inherit;
    line-height: 1;
    margin: 0;
    cursor: pointer;
    border: none;
    outline: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

/* ── TOPBAR ──────────────────────────────────────────── */
#mwo-app .mwo-topbar {
    background: #fff;
    border-bottom: 1px solid var(--g200);
    position: sticky;
    top: 0;
    z-index: 100;
}
#mwo-app .mwo-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    max-width: 960px;
    margin: 0 auto;
}
#mwo-app .mwo-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
#mwo-app .mwo-logo-badge {
    width: 42px; height: 42px;
    background: var(--accent);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
#mwo-app .mwo-shop-name { font-size: 1rem; font-weight: 700; color: var(--g900); line-height: 1.2; margin: 0; }
#mwo-app .mwo-shop-sub  { font-size: .73rem; color: var(--g600); margin: 0; }

/* Botó cistella */
#mwo-app button.mwo-cart-btn {
    position: relative;
    width: 44px; height: 44px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    transition: opacity .15s;
    flex-shrink: 0;
    padding: 0;
}
#mwo-app button.mwo-cart-btn:hover,
#mwo-app button.mwo-cart-btn:focus { opacity: .85; background: var(--accent); color: #fff; outline: none; }

#mwo-app .mwo-badge {
    position: absolute;
    top: -3px; right: -3px;
    background: var(--red);
    color: #fff;
    font-size: .62rem;
    font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
    line-height: 1;
}

/* ── FILTRES ─────────────────────────────────────────── */
#mwo-app .mwo-filters-bar {
    background: #fff;
    border-bottom: 1px solid var(--g200);
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: sticky;
    top: 71px;
    z-index: 99;
    width: 100%;
}
#mwo-app .mwo-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--g100);
    border-radius: var(--rsm);
    padding: 0 12px;
    height: 40px;
}
#mwo-app .mwo-search-box input[type="text"] {
    border: none;
    background: transparent;
    outline: none;
    font-size: .9rem;
    width: 100%;
    color: var(--g900);
    font-family: inherit;
    padding: 0;
    margin: 0;
    box-shadow: none;
}
#mwo-app .mwo-search-box input[type="text"]::placeholder { color: var(--g400); }

#mwo-app .mwo-cats-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}
#mwo-app .mwo-cats-row::-webkit-scrollbar { display: none; }

/* Chips – inactiu gris, actiu/hover BLAU AMB LLETRA BLANCA */
#mwo-app button.mwo-chip {
    flex-shrink: 0;
    background: var(--g100);
    border: 1.5px solid transparent;
    border-radius: 50px;
    padding: 7px 16px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--g600);
    white-space: nowrap;
    transition: all .15s;
    height: auto;
    line-height: 1.3;
}
#mwo-app button.mwo-chip:hover,
#mwo-app button.mwo-chip:focus {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    outline: none;
}
#mwo-app button.mwo-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ── GRID ───────────────────────────────────────────── */
#mwo-app .mwo-grid {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 20px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
}
#mwo-app .mwo-loading {
    grid-column: 1/-1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 60px 0;
    color: var(--g400);
    font-size: .9rem;
}
#mwo-app .mwo-spinner {
    width: 20px; height: 20px;
    border: 3px solid var(--g200);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: mwo-spin .7s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}
@keyframes mwo-spin { to { transform: rotate(360deg); } }

#mwo-app .mwo-empty-state { text-align: center; padding: 60px 20px; color: var(--g400); }
#mwo-app .mwo-empty-state span { font-size: 2.5rem; display: block; margin-bottom: 10px; }
#mwo-app .mwo-empty-state p   { font-size: .9rem; margin: 0; }

/* ── CARD ───────────────────────────────────────────── */
#mwo-app .mwo-card {
    background: #fff;
    border-radius: var(--rmd);
    overflow: hidden;
    box-shadow: var(--sh1);
    cursor: pointer;
    transition: transform .18s, box-shadow .18s, border-color .18s;
    border: 1.5px solid transparent;
    position: relative;
}
#mwo-app .mwo-card:hover { transform: translateY(-3px); box-shadow: var(--sh2); border-color: var(--accent); }
#mwo-app .mwo-card.in-cart { border-color: var(--accent); }
#mwo-app .mwo-card.hidden  { display: none; }

#mwo-app .mwo-card-img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--g100); }
#mwo-app .mwo-card-body { padding: 10px 12px 14px; }
#mwo-app .mwo-card-name {
    font-size: .88rem; font-weight: 700; color: var(--g900);
    margin: 0 0 5px; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
#mwo-app .mwo-card-price { font-size: .8rem; font-weight: 600; color: var(--accent); margin: 0; }
#mwo-app .mwo-card-price ins { text-decoration: none; }
#mwo-app .mwo-card-in-cart {
    position: absolute; top: 8px; right: 8px;
    background: var(--accent); color: #fff;
    font-size: .68rem; font-weight: 700;
    padding: 3px 8px; border-radius: 50px;
    display: none; line-height: 1.4;
}
#mwo-app .mwo-card.in-cart .mwo-card-in-cart { display: block; }

/* ── OVERLAY ────────────────────────────────────────── */
#mwo-app .mwo-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 9998;
    backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
#mwo-app .mwo-overlay.active { display: block; }

/* ── MODAL ──────────────────────────────────────────── */
#mwo-app .mwo-modal {
    display: none; position: fixed;
    bottom: 0; left: 0; right: 0;
    max-height: 92vh; background: #fff;
    border-radius: var(--rlg) var(--rlg) 0 0;
    z-index: 9999; overflow-y: auto; box-shadow: var(--sh3);
}
#mwo-app .mwo-modal.active { display: block; }

@media (min-width: 640px) {
    #mwo-app .mwo-modal {
        bottom: auto; top: 50%; left: 50%;
        transform: translate(-50%, -50%);
        max-width: 480px; width: 92%;
        border-radius: var(--rlg); max-height: 90vh;
    }
}

#mwo-app button.mwo-modal-close {
    position: absolute; top: 12px; right: 12px;
    width: 34px; height: 34px;
    background: rgba(0,0,0,.38); color: #fff;
    border-radius: 50%; z-index: 10; padding: 0;
    transition: background .15s;
}
#mwo-app button.mwo-modal-close:hover { background: rgba(0,0,0,.58); color: #fff; }

#mwo-app .mwo-modal-img-wrap { width: 100%; aspect-ratio: 4/3; background: var(--g100); overflow: hidden; }
#mwo-app .mwo-modal-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }

#mwo-app .mwo-modal-body { padding: 22px 22px 30px; }

#mwo-app .mwo-modal-cats-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
#mwo-app .mwo-modal-cat-badge {
    background: var(--g100); color: var(--g600);
    font-size: .68rem; font-weight: 700;
    padding: 3px 10px; border-radius: 20px;
    text-transform: uppercase; letter-spacing: .05em;
}
#mwo-app .mwo-modal-name { font-size: 1.3rem; font-weight: 800; margin: 0 0 6px; color: var(--g900); line-height: 1.2; }
#mwo-app .mwo-modal-price { font-size: 1rem; font-weight: 700; color: var(--accent); margin-bottom: 20px; }
#mwo-app .mwo-modal-price ins { text-decoration: none; }

#mwo-app .mwo-section-label {
    display: block; font-size: .7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .07em;
    color: var(--g600); margin-bottom: 8px;
}
#mwo-app .mwo-optional { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: .75rem; color: var(--g400); }

/* SELECTs – variants i preparació */
#mwo-app .mwo-attr-group { margin-bottom: 18px; }

#mwo-app select.mwo-attr-select,
#mwo-app select.mwo-prep-select {
    width: 100%; height: 46px;
    border: 2px solid var(--g200); border-radius: var(--rsm);
    padding: 0 40px 0 14px;
    font-size: .9rem; font-weight: 500; color: var(--g900);
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    cursor: pointer; outline: none; font-family: inherit;
    transition: border-color .15s; display: block; box-shadow: none;
    margin-bottom: 0;
}
#mwo-app select.mwo-attr-select:focus,
#mwo-app select.mwo-prep-select:focus { border-color: var(--accent); }

#mwo-app #mwo-modal-prep-wrap { margin-bottom: 18px; }

/* Quantitat */
#mwo-app .mwo-qty-row { margin-bottom: 22px; }
#mwo-app .mwo-qty-ctrl {
    display: inline-flex; align-items: center;
    border-radius: var(--rsm); border: 2px solid var(--g200); overflow: hidden;
}
#mwo-app button.mwo-qty-btn {
    width: 44px; height: 44px;
    background: var(--accent); color: #fff;
    font-size: 1.4rem; font-weight: 300;
    padding: 0; line-height: 1; flex-shrink: 0;
    transition: opacity .15s;
}
#mwo-app button.mwo-qty-btn:hover,
#mwo-app button.mwo-qty-btn:focus { opacity: .8; background: var(--accent); color: #fff; outline: none; }

#mwo-app #mwo-modal-qty-display {
    min-width: 48px; text-align: center;
    font-size: 1rem; font-weight: 700; color: var(--g900); padding: 0 4px;
}
#mwo-app .mwo-unit-label { font-size: .8rem; color: var(--g600); padding: 0 12px 0 6px; }

/* Botó afegir – blau/blanc */
#mwo-app button.mwo-add-btn {
    width: 100%; background: var(--accent); color: #fff;
    border-radius: var(--rmd); padding: 15px 20px;
    font-size: .95rem; font-weight: 700; gap: 8px;
    transition: opacity .15s, transform .1s; margin-top: 4px; height: auto;
}
#mwo-app button.mwo-add-btn:hover,
#mwo-app button.mwo-add-btn:focus { opacity: .9; background: var(--accent); color: #fff; outline: none; }
#mwo-app button.mwo-add-btn:active { transform: scale(.98); }

/* ── DRAWER ─────────────────────────────────────────── */
#mwo-app .mwo-drawer {
    display: none; position: fixed;
    top: 0; right: 0; bottom: 0; width: 100%; max-width: 400px;
    background: #fff; z-index: 9999; box-shadow: var(--sh3); flex-direction: column;
}
#mwo-app .mwo-drawer.active { display: flex; }

#mwo-app .mwo-drawer-top {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px; border-bottom: 1px solid var(--g200); flex-shrink: 0;
}
#mwo-app .mwo-drawer-top h3 { margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--g900); }

#mwo-app button.mwo-drawer-close {
    width: 32px; height: 32px;
    background: var(--g100); color: var(--g600);
    border-radius: 50%; padding: 0; transition: background .15s;
}
#mwo-app button.mwo-drawer-close:hover { background: var(--g200); color: var(--g900); }

#mwo-app .mwo-drawer-scroll { flex: 1; overflow-y: auto; padding: 8px 0; }
#mwo-app .mwo-drawer-empty { text-align: center; padding: 60px 20px; color: var(--g400); }
#mwo-app .mwo-drawer-empty span { font-size: 2.5rem; display: block; margin-bottom: 10px; }
#mwo-app .mwo-drawer-empty p   { font-size: .9rem; margin: 0; }

#mwo-app .mwo-cart-list { list-style: none; margin: 0; padding: 0; }
#mwo-app .mwo-cart-item {
    display: grid; grid-template-columns: 52px 1fr auto;
    align-items: center; gap: 12px;
    padding: 12px 20px; border-bottom: 1px solid var(--g100);
}
#mwo-app .mwo-cart-item:last-child { border-bottom: none; }

#mwo-app .mwo-ci-img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--g100); display: block; }
#mwo-app .mwo-ci-info { min-width: 0; }
#mwo-app .mwo-ci-name {
    font-size: .88rem; font-weight: 700; color: var(--g900);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0;
}
#mwo-app .mwo-ci-meta {
    font-size: .73rem; color: var(--g600); margin: 2px 0 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#mwo-app .mwo-ci-price {
    font-size: .85rem; font-weight: 700; color: var(--accent);
    white-space: nowrap; text-align: right; align-self: start; padding-top: 2px;
}
#mwo-app .mwo-ci-controls {
    display: inline-flex; align-items: center; margin-top: 6px;
    border: 1.5px solid var(--g200); border-radius: var(--rsm); overflow: hidden;
}
#mwo-app button.mwo-ci-btn {
    width: 28px; height: 28px;
    background: #fff; color: var(--g600);
    font-size: .95rem; line-height: 1; padding: 0;
    transition: background .12s, color .12s; flex-shrink: 0;
}
#mwo-app button.mwo-ci-btn:hover  { background: var(--g100); color: var(--g900); }
#mwo-app button.mwo-ci-btn.delete { color: var(--red); font-size: .8rem; }
#mwo-app button.mwo-ci-btn.delete:hover { background: #fff5f5; color: var(--red); }

#mwo-app .mwo-ci-qty-val {
    min-width: 32px; text-align: center;
    font-size: .82rem; font-weight: 700; color: var(--g900); padding: 0 2px;
}

/* Drawer footer */
#mwo-app .mwo-drawer-footer { padding: 16px 20px 20px; border-top: 1px solid var(--g200); background: #fff; flex-shrink: 0; }
#mwo-app .mwo-total-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
#mwo-app .mwo-total-label { font-size: .85rem; color: var(--g600); font-weight: 500; margin: 0; }
#mwo-app .mwo-total-val   { font-size: 1.1rem; font-weight: 800; color: var(--g900); margin: 0; }

#mwo-app textarea.mwo-notes-ta {
    width: 100%; border: 1.5px solid var(--g200); border-radius: var(--rsm);
    padding: 10px 12px; font-size: .84rem; font-family: inherit; resize: none;
    outline: none; color: var(--g900); margin-bottom: 14px;
    transition: border-color .15s; display: block; background: #fff; box-shadow: none;
}
#mwo-app textarea.mwo-notes-ta:focus { border-color: var(--accent); }
#mwo-app textarea.mwo-notes-ta::placeholder { color: var(--g400); }

/* Botó WhatsApp – verd/blanc */
#mwo-app button.mwo-wa-btn {
    width: 100%; background: var(--green); color: #fff;
    border-radius: var(--rmd); padding: 15px 20px;
    font-size: .95rem; font-weight: 700; gap: 8px;
    box-shadow: 0 4px 14px rgba(37,211,102,.28);
    transition: opacity .15s; margin-bottom: 8px; height: auto;
}
#mwo-app button.mwo-wa-btn:hover,
#mwo-app button.mwo-wa-btn:focus { opacity: .9; background: var(--green); color: #fff; outline: none; }

#mwo-app .mwo-disclaimer { text-align: center; font-size: .71rem; color: var(--g400); margin: 0; }

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 860px) { #mwo-app .mwo-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (max-width: 600px) {
    #mwo-app .mwo-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 14px; }
    #mwo-app .mwo-filters-bar { padding: 10px 14px; }
    #mwo-app .mwo-topbar-inner { padding: 12px 14px; }
    #mwo-app .mwo-drawer { max-width: 100%; }
    #mwo-app .mwo-modal-body { padding: 18px 18px 28px; }
}

/* ── BOTÓ CISTELLA FLOTANT ───────────────────────────── */
#mwo-app .mwo-float-cart {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9997;
    display: none;
}
#mwo-app .mwo-float-cart.visible { display: flex; }

#mwo-app button.mwo-float-cart-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 14px 20px;
    font-size: .92rem;
    font-weight: 700;
    gap: 10px;
    box-shadow: 0 6px 24px rgba(0,0,95,.28);
    transition: transform .15s, opacity .15s;
    white-space: nowrap;
    height: auto;
}
#mwo-app button.mwo-float-cart-btn:hover { transform: scale(1.04); opacity: .93; background: var(--accent); color: #fff; }

#mwo-app .mwo-float-badge {
    background: var(--red);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    min-width: 20px; height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 1;
}
