/* ==========================================================
   Allfood Design System — Phase 5 Commerce
   Cart + Checkout only. Shared product/catalog styling remains
   in the existing Phase 4 modules.
========================================================== */

.af-cart-page,
.af-checkout-page{
    background:linear-gradient(180deg,#fbfdff 0,#fff 360px);
}
.af-commerce-page{
    width:100%;
    min-width:0;
}
.af-commerce-hero{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:28px;
    margin-bottom:22px;
    padding:30px 34px;
    border:1px solid var(--af-line);
    border-radius:var(--af-radius-large);
    background:
        radial-gradient(circle at 8% 8%,rgba(103,183,228,.16),transparent 30%),
        radial-gradient(circle at 92% 0%,rgba(242,92,46,.09),transparent 28%),
        #fff;
    box-shadow:var(--af-shadow-elevated);
}
.af-commerce-eyebrow{
    display:inline-flex;
    align-items:center;
    gap:7px;
    margin-bottom:8px;
    color:var(--af-blue-dark);
    font-size:11px;
    font-weight:900;
    letter-spacing:.45px;
    text-transform:uppercase;
}
.af-commerce-hero h1{
    margin:0 0 8px;
    color:#0f172a;
    font-size:clamp(30px,3.4vw,44px);
    line-height:1.05;
    font-weight:900;
    letter-spacing:-.9px;
}
.af-commerce-hero p{
    max-width:760px;
    margin:0;
    color:var(--af-muted);
    font-size:14px;
    line-height:1.7;
}
.af-commerce-hero-total{
    flex:0 0 auto;
    min-width:150px;
    padding:16px 20px;
    border:1px solid var(--af-line);
    border-radius:20px;
    background:#fff;
    text-align:right;
}
.af-commerce-hero-total span,
.af-commerce-hero-total strong{display:block}
.af-commerce-hero-total span{color:var(--af-muted);font-size:11px;font-weight:800}
.af-commerce-hero-total strong{margin-top:4px;color:var(--af-orange);font-size:25px;font-weight:900}
.af-commerce-alert{
    margin-bottom:18px;
    border-radius:var(--af-radius-card);
}
.af-commerce-empty{
    min-height:390px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    padding:48px 22px;
    border:1px solid var(--af-line);
    border-radius:var(--af-radius-large);
    background:#fff;
    box-shadow:var(--af-shadow-card);
    text-align:center;
}
.af-commerce-empty-icon{
    width:72px;
    height:72px;
    display:flex;
    align-items:center;
    justify-content:center;
    margin-bottom:16px;
    border-radius:24px;
    background:var(--af-blue-soft);
    color:var(--af-blue-dark);
    font-size:30px;
}
.af-commerce-empty h2{margin:0 0 8px;color:#0f172a;font-size:24px;font-weight:900}
.af-commerce-empty p{max-width:560px;margin:0 0 20px;color:var(--af-muted);font-size:13px;line-height:1.7}
.af-commerce-empty-actions{display:flex;gap:10px;flex-wrap:wrap;justify-content:center}
.af-commerce-grid{
    display:grid;
    grid-template-columns:minmax(0,1fr) 360px;
    gap:24px;
    align-items:start;
}

/* Free delivery progress */
.af-free-delivery-card{
    margin-bottom:18px;
    padding:16px 18px;
    border:1px solid #d8effc;
    border-radius:20px;
    background:linear-gradient(135deg,#f7fcff,#fff);
}
.af-free-delivery-card.is-complete{border-color:#bbf7d0;background:linear-gradient(135deg,#f0fdf4,#fff)}
.af-free-delivery-copy{display:flex;align-items:center;gap:12px}
.af-free-delivery-icon{
    flex:0 0 42px;
    width:42px;
    height:42px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:14px;
    background:var(--af-blue-soft);
    color:var(--af-blue-dark);
    font-size:19px;
}
.af-free-delivery-card.is-complete .af-free-delivery-icon{background:#dcfce7;color:#15803d}
.af-free-delivery-copy strong{display:block;color:#0f172a;font-size:13px;font-weight:900}
.af-free-delivery-copy small{display:block;margin-top:2px;color:var(--af-muted);font-size:10.5px;line-height:1.4}
.af-free-delivery-progress{height:7px;margin-top:12px;border-radius:999px;background:#eaf0f5;overflow:hidden}
.af-free-delivery-progress span{display:block;height:100%;border-radius:inherit;background:var(--af-blue-dark)}
.af-free-delivery-card.is-complete .af-free-delivery-progress span{background:var(--af-success)}

/* Cart items */
.af-cart-items{min-width:0;display:grid;gap:12px}
.af-cart-item{
    min-width:0;
    display:grid;
    grid-template-columns:118px minmax(0,1fr);
    gap:18px;
    padding:18px;
    border:1px solid var(--af-line);
    border-radius:var(--af-radius-panel);
    background:#fff;
    box-shadow:var(--af-shadow-card);
}
.af-cart-item-image{
    width:118px;
    height:118px;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:10px;
    border:1px solid #f0f3f6;
    border-radius:18px;
    background:#fff;
    overflow:hidden;
}
.af-cart-item-image img{width:100%;height:100%;object-fit:contain;display:block}
.af-cart-item-main{min-width:0;display:flex;flex-direction:column}
.af-cart-item-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}
.af-cart-item-title{display:block;color:#0f172a;font-size:15px;line-height:1.35;font-weight:900}
.af-cart-item-title:hover{color:var(--af-blue-dark)}
.af-cart-item-meta{display:flex;flex-wrap:wrap;gap:5px 12px;margin-top:6px;color:var(--af-muted);font-size:10.5px;font-weight:700}
.af-cart-item-unit-price{flex:0 0 auto;text-align:right;color:var(--af-orange);font-size:15px;font-weight:900}
.af-cart-item-unit-price small{display:block;margin-top:2px;color:var(--af-muted);font-size:9px;font-weight:700}
.af-cart-rule,
.af-cart-free{
    width:max-content;
    max-width:100%;
    display:flex;
    align-items:center;
    gap:6px;
    margin-top:9px;
    padding:6px 9px;
    border-radius:11px;
    background:#fff7ed;
    color:#9a3412;
    font-size:10px;
    font-weight:800;
}
.af-cart-free{background:#ecfdf5;color:#047857}
.af-cart-offers{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.af-cart-offers span{display:inline-flex;align-items:center;gap:5px;padding:5px 8px;border-radius:10px;background:#ecfdf5;color:#047857;font-size:10px;font-weight:800}
.af-cart-item-footer{margin-top:auto;padding-top:14px;display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.af-cart-qty-form{display:flex;align-items:center;gap:8px;min-width:0}
.af-cart-qty-control{
    display:grid;
    grid-template-columns:36px 58px 36px;
    min-height:42px;
    border:1px solid #dbe3ee;
    border-radius:14px;
    overflow:hidden;
    background:#fff;
}
.af-cart-qty-control button{border:0;background:#f8fafc;color:#334155;font-size:18px;font-weight:900}
.af-cart-qty-control input{width:58px;min-width:0;border:0;outline:0;background:#fff;text-align:center;color:#0f172a;font-size:12px;font-weight:900;-moz-appearance:textfield}
.af-cart-qty-control input::-webkit-inner-spin-button,.af-cart-qty-control input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
.af-cart-update-btn{min-height:42px;padding:7px 13px;border-radius:13px;font-size:11px}
.af-cart-remove-form{margin:0}
.af-cart-remove{min-height:40px;display:inline-flex;align-items:center;gap:6px;border:0;background:transparent;color:#b91c1c;font-size:10.5px;font-weight:800;padding:4px 6px}
.af-cart-remove:hover{color:#7f1d1d}
.af-cart-line-total{margin-left:auto;text-align:right}
.af-cart-line-total span,.af-cart-line-total strong{display:block}
.af-cart-line-total span{color:#94a3b8;text-decoration:line-through;font-size:10px}
.af-cart-line-total strong{color:#0f172a;font-size:18px;font-weight:900}

/* Shared summary card */
.af-commerce-summary{
    position:sticky;
    top:118px;
    min-width:0;
    padding:22px;
    border:1px solid var(--af-line);
    border-radius:var(--af-radius-panel);
    background:#fff;
    box-shadow:var(--af-shadow-elevated);
}
.af-commerce-summary-head{display:flex;align-items:center;justify-content:space-between;gap:14px;padding-bottom:16px;border-bottom:1px solid var(--af-line)}
.af-commerce-summary-head span,.af-commerce-summary-head strong{display:block}
.af-commerce-summary-head span{color:#0f172a;font-size:16px;font-weight:900}
.af-commerce-summary-head strong{margin-top:2px;color:var(--af-muted);font-size:10px;font-weight:700}
.af-commerce-summary-head>i{font-size:24px;color:var(--af-blue-dark)}
.af-commerce-summary-head>a{color:var(--af-blue-dark);font-size:10.5px;font-weight:900}
.af-summary-lines{display:grid;gap:10px;padding:17px 0}
.af-summary-lines>div{display:flex;align-items:center;justify-content:space-between;gap:14px;color:#475569;font-size:12px}
.af-summary-lines strong{color:#0f172a;font-weight:900}
.af-summary-lines .is-saving,.af-summary-lines .is-saving strong{color:#047857}
.af-summary-note{display:flex;align-items:flex-start;gap:9px;margin:0 0 10px;padding:10px 11px;border-radius:13px;background:#f8fafc;color:#64748b;font-size:9.5px;line-height:1.5;font-weight:700}
.af-summary-note i{flex:0 0 auto;margin-top:1px;color:var(--af-blue-dark);font-size:14px}
.af-summary-note.is-warning{background:#fff7ed;color:#9a3412}.af-summary-note.is-warning i{color:#c2410c}
.af-coupon-form{margin-top:15px;padding-top:15px;border-top:1px solid var(--af-line)}
.af-coupon-form label{display:block;margin-bottom:6px;color:#475569;font-size:10px;font-weight:900;text-transform:uppercase;letter-spacing:.35px}
.af-coupon-control{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:7px}
.af-coupon-control .form-control{min-width:0;min-height:42px;border-radius:13px;font-size:12px;text-transform:uppercase}
.af-coupon-control .btn{min-height:42px;border-radius:13px;font-size:11px}
.af-coupon-remove{margin-top:7px;padding:0;border:0;background:transparent;color:#b91c1c;font-size:10px;font-weight:800}
.af-summary-total{display:flex;align-items:baseline;justify-content:space-between;gap:14px;margin-top:15px;padding-top:17px;border-top:1px solid var(--af-line)}
.af-summary-total span{color:#0f172a;font-size:15px;font-weight:900}
.af-summary-total strong{color:var(--af-orange);font-size:25px;font-weight:900}
.af-commerce-primary-cta{width:100%;min-height:48px;margin-top:16px;border-radius:15px;font-size:13px;font-weight:900}
.af-commerce-secondary-cta{width:100%;min-height:44px;margin-top:8px;border-radius:14px;font-size:11px;font-weight:800}
.af-commerce-trust{display:grid;gap:7px;margin-top:16px;padding-top:15px;border-top:1px solid var(--af-line);color:#64748b;font-size:9.5px;font-weight:700}
.af-commerce-trust span{display:flex;align-items:center;gap:6px}.af-commerce-trust i{color:var(--af-blue-dark);font-size:13px}
.af-cart-upsell{margin-top:36px}
.af-cart-upsell-grid{grid-template-columns:repeat(4,minmax(0,1fr)) !important}
.af-cart-mobile-checkout{display:none}

/* Checkout */
.af-checkout-hero{align-items:center}
.af-checkout-steps{flex:0 0 auto;display:flex;align-items:center;gap:8px}
.af-checkout-steps span{min-height:34px;display:flex;align-items:center;gap:5px;padding:6px 10px;border-radius:999px;background:#f8fafc;color:#94a3b8;font-size:9.5px;font-weight:900}
.af-checkout-steps .is-done{background:#ecfdf5;color:#047857}.af-checkout-steps .is-active{background:var(--af-blue-soft);color:var(--af-blue-dark)}
.af-checkout-grid{grid-template-columns:minmax(0,1fr) 380px}
.af-checkout-form-card{min-width:0;border:1px solid var(--af-line);border-radius:var(--af-radius-large);background:#fff;box-shadow:var(--af-shadow-card);overflow:hidden}
.af-checkout-form{display:block}
.af-checkout-section{padding:26px 28px;border-bottom:1px solid var(--af-line)}
.af-checkout-section:last-of-type{border-bottom:0}
.af-checkout-section-head{display:flex;align-items:flex-start;gap:12px;margin-bottom:18px}
.af-checkout-section-head>span{flex:0 0 34px;width:34px;height:34px;display:flex;align-items:center;justify-content:center;border-radius:12px;background:var(--af-blue-soft);color:var(--af-blue-dark);font-size:12px;font-weight:900}
.af-checkout-section-head h2{margin:0;color:#0f172a;font-size:17px;font-weight:900}.af-checkout-section-head p{margin:3px 0 0;color:var(--af-muted);font-size:10.5px;line-height:1.5}
.af-checkout-fields{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.af-field{min-width:0;display:grid;gap:6px;margin-top:14px}.af-checkout-fields .af-field{margin-top:0}.af-field-wide{grid-column:1/-1}
.af-field label{color:#475569;font-size:10.5px;font-weight:900}.af-field label span{color:#94a3b8;font-weight:700}
.af-field .form-control,.af-field .form-select{min-height:46px;border-radius:14px;border-color:#dfe6ee;font-size:12px}
.af-field textarea.form-control{padding-top:11px;resize:vertical;line-height:1.6}
.af-field>small{color:#94a3b8;font-size:9.5px}
.af-choice-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.af-choice-card{position:relative;min-width:0;display:grid;grid-template-columns:42px minmax(0,1fr) 18px;gap:10px;align-items:center;min-height:78px;padding:12px;border:1px solid #dfe6ee;border-radius:17px;background:#fff;cursor:pointer;transition:border-color .15s ease,box-shadow .15s ease,background .15s ease}
.af-choice-card:hover{border-color:#b9d9ec}
.af-choice-card:has(input:checked){border-color:var(--af-blue-dark);background:#f8fcff;box-shadow:0 0 0 2px rgba(43,143,202,.09)}
.af-choice-card input{position:absolute;opacity:0;pointer-events:none}
.af-choice-card:has(input:focus-visible){outline:3px solid rgba(43,143,202,.25);outline-offset:2px}
.af-choice-icon{width:42px;height:42px;display:flex;align-items:center;justify-content:center;border-radius:14px;background:#f8fafc;color:#475569;font-size:18px}
.af-choice-card:has(input:checked) .af-choice-icon{background:var(--af-blue-soft);color:var(--af-blue-dark)}
.af-choice-copy{min-width:0}.af-choice-copy strong,.af-choice-copy small{display:block}.af-choice-copy strong{color:#0f172a;font-size:12px;font-weight:900}.af-choice-copy small{margin-top:2px;color:var(--af-muted);font-size:9px;line-height:1.35}
.af-choice-check{color:#cbd5e1;font-size:17px}.af-choice-card:has(input:checked) .af-choice-check{color:var(--af-blue-dark)}
.af-payment-grid{grid-template-columns:1fr}
.af-payment-card{min-height:72px}
.af-delivery-address[hidden]{display:none !important}
.af-checkout-submit-wrap{padding:22px 28px 26px}.af-checkout-submit-wrap .af-commerce-primary-cta{margin-top:0}.af-checkout-submit-wrap p{display:flex;align-items:flex-start;justify-content:center;gap:6px;margin:9px 0 0;color:#94a3b8;font-size:9px;text-align:center}
.af-checkout-summary-items{max-height:330px;overflow:auto;margin:14px -5px 0;padding:0 5px;scrollbar-width:thin}
.af-checkout-summary-item{display:grid;grid-template-columns:48px minmax(0,1fr) auto;gap:9px;align-items:center;padding:9px 0;border-bottom:1px solid #f1f5f9}
.af-checkout-summary-item img{width:48px;height:48px;object-fit:contain;border:1px solid #f1f5f9;border-radius:11px;background:#fff;padding:4px}
.af-checkout-summary-item>div{min-width:0}.af-checkout-summary-item>div strong{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;color:#0f172a;font-size:9.5px;line-height:1.3;font-weight:900}.af-checkout-summary-item>div span{display:block;margin-top:2px;color:var(--af-muted);font-size:8.5px}.af-checkout-summary-item>b{color:#0f172a;font-size:10px;font-weight:900}
.af-checkout-mobile-submit{display:none}

@media(max-width:1199px){
    .af-commerce-grid{grid-template-columns:minmax(0,1fr) 330px;gap:18px}
    .af-checkout-grid{grid-template-columns:minmax(0,1fr) 350px}
    .af-cart-upsell-grid{grid-template-columns:repeat(3,minmax(0,1fr)) !important}
}

@media(max-width:991px){
    .af-commerce-grid,.af-checkout-grid{grid-template-columns:1fr}
    .af-commerce-summary{position:static}
    .af-checkout-summary{order:-1}
    .af-checkout-summary-items{max-height:260px}
}

@media(max-width:767px){
    .af-cart-page,.af-checkout-page{width:100%;max-width:100%;overflow-x:clip}
    .af-cart-page{padding-bottom:166px !important}
    .af-checkout-page{padding-bottom:166px !important}
    .af-commerce-page{padding-top:14px !important;padding-bottom:28px !important}
    .af-commerce-hero{display:block;margin-bottom:14px;padding:20px 17px;border-radius:22px}
    .af-commerce-hero h1{font-size:26px;letter-spacing:-.6px}.af-commerce-hero p{font-size:11.5px;line-height:1.55}
    .af-commerce-hero-total{display:none}
    .af-free-delivery-card{padding:13px 14px;border-radius:17px}.af-free-delivery-copy strong{font-size:11.5px}.af-free-delivery-copy small{font-size:9.5px}
    .af-cart-item{grid-template-columns:82px minmax(0,1fr);gap:12px;padding:12px;border-radius:20px}
    .af-cart-item-image{width:82px;height:82px;padding:6px;border-radius:15px}
    .af-cart-item-heading{display:block}.af-cart-item-title{font-size:12px}.af-cart-item-meta{font-size:8.5px;gap:3px 8px}.af-cart-item-unit-price{margin-top:5px;text-align:left;font-size:12px}.af-cart-item-unit-price small{display:inline;margin-left:3px}
    .af-cart-rule,.af-cart-free{font-size:8.5px;padding:5px 7px}.af-cart-offers span{font-size:8.5px}
    .af-cart-item-footer{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;padding-top:11px}
    .af-cart-qty-form{min-width:0}.af-cart-qty-control{grid-template-columns:32px 48px 32px;min-height:40px}.af-cart-qty-control input{width:48px;font-size:10px}.af-cart-update-btn{min-height:40px;padding:6px 10px;font-size:9px}
    .af-cart-remove-form{grid-row:2}.af-cart-remove{min-height:32px;font-size:9px;padding-left:0}
    .af-cart-line-total{grid-row:1 / span 2;grid-column:2;align-self:center}.af-cart-line-total strong{font-size:15px}
    .af-commerce-summary{padding:18px;border-radius:21px}.af-summary-total strong{font-size:23px}
    .af-cart-upsell{margin-top:28px}.af-cart-upsell-grid{grid-template-columns:repeat(2,minmax(0,1fr)) !important;gap:11px !important}
    .af-cart-mobile-checkout,
    .af-checkout-mobile-submit{
        position:fixed;
        left:0;
        right:0;
        bottom:calc(78px + env(safe-area-inset-bottom));
        z-index:1060;
        min-height:68px;
        display:grid;
        grid-template-columns:minmax(0,1fr) auto;
        align-items:center;
        gap:10px;
        padding:9px 12px;
        border-top:1px solid #e5e7eb;
        background:rgba(255,255,255,.97);
        backdrop-filter:blur(14px);
        box-shadow:0 -9px 30px rgba(15,23,42,.12);
    }
    .af-cart-mobile-checkout span,.af-cart-mobile-checkout strong,.af-checkout-mobile-submit span,.af-checkout-mobile-submit strong{display:block}.af-cart-mobile-checkout span,.af-checkout-mobile-submit span{color:#64748b;font-size:9px;font-weight:800}.af-cart-mobile-checkout strong,.af-checkout-mobile-submit strong{margin-top:1px;color:var(--af-orange);font-size:15px;font-weight:900}
    .af-cart-mobile-checkout .btn,.af-checkout-mobile-submit .btn{min-height:44px;border-radius:13px;font-size:11px;font-weight:900}

    .af-checkout-hero .af-checkout-steps{margin-top:15px;overflow-x:auto;padding-bottom:2px;scrollbar-width:none}.af-checkout-steps::-webkit-scrollbar{display:none}.af-checkout-steps span{flex:0 0 auto}
    .af-checkout-summary{order:0}
    .af-checkout-form-card{border-radius:22px}
    .af-checkout-section{padding:20px 15px}.af-checkout-section-head{margin-bottom:15px}.af-checkout-section-head h2{font-size:15px}.af-checkout-section-head p{font-size:9.5px}
    .af-checkout-fields{grid-template-columns:1fr;gap:11px}.af-field-wide{grid-column:auto}
    .af-choice-grid{grid-template-columns:1fr}.af-choice-card{min-height:70px}
    .af-checkout-submit-wrap{padding:18px 15px 20px}
    .af-checkout-summary-items{max-height:220px}
}

@media(max-width:390px){
    .af-commerce-hero{padding:18px 14px}.af-commerce-hero h1{font-size:24px}
    .af-cart-item{grid-template-columns:72px minmax(0,1fr);gap:10px;padding:10px}.af-cart-item-image{width:72px;height:72px}
    .af-cart-qty-form{gap:5px}.af-cart-qty-control{grid-template-columns:29px 42px 29px}.af-cart-qty-control input{width:42px}.af-cart-update-btn{padding-left:8px;padding-right:8px}
    .af-commerce-summary{padding:16px}
    .af-cart-mobile-checkout,.af-checkout-mobile-submit{padding-left:10px;padding-right:10px}
}

/* Logical direction support */
[dir="rtl"] .af-commerce-hero-total,
[dir="rtl"] .af-cart-item-unit-price,
[dir="rtl"] .af-cart-line-total{text-align:left}
[dir="rtl"] .af-cart-line-total{margin-left:0;margin-right:auto}
[dir="rtl"] .af-commerce-primary-cta .bi-arrow-right{transform:rotate(180deg)}
