/**
 * FlexiDelivery Cart Drawer v3.3.0
 * Production-ready · Industry Standard
 */

/* ─── CSS Variables (overridden by inline :root from settings) ─── */
:root {
    --jefd-drawer-bg: #F5F5F0;
    --jefd-text: #2D2D2D;
    --jefd-border: #E5E5E5;
    --jefd-btn-bg: #2D2D2D;
    --jefd-btn-text: #FFFFFF;
    --jefd-success: #2E7D32;
    --jefd-error: #C62828;
    --jefd-warning: #F9A825;
    --jefd-radius: 8px;
}

/* ─────────────────────────────────────────────
   OVERLAY
   ───────────────────────────────────────────── */
.jefd-overlay {
    position: fixed; inset: 0; z-index: 99998;
    background: rgba(0,0,0,.45); opacity: 0;
    pointer-events: none; transition: opacity .3s ease;
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.jefd-overlay.is-open { opacity: 1; pointer-events: auto; }

/* ─────────────────────────────────────────────
   DRAWER (fixed slide-out panel)
   ───────────────────────────────────────────── */
.jefd-drawer {
    position: fixed; top: 0; right: 0; z-index: 99999;
    width: 440px; max-width: 100vw; height: 100vh; height: 100dvh;
    background: var(--jefd-drawer-bg); color: var(--jefd-text);
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform .35s cubic-bezier(.4,0,.2,1);
    box-shadow: -4px 0 24px rgba(0,0,0,.08);
}
.jefd-drawer.is-open { transform: translateX(0); }
body.jefd-drawer-open { overflow: hidden; }

/* ─────────────────────────────────────────────
   HEADER — fixed at top
   ───────────────────────────────────────────── */
.jefd-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 24px; border-bottom: 1px solid var(--jefd-border);
    flex-shrink: 0; min-height: 56px;
}
.jefd-title {
    font-size: 13px; font-weight: 700; letter-spacing: 1.5px;
    text-transform: uppercase; margin: 0; line-height: 1;
}
.jefd-item-count {
    font-weight: 400; font-size: 11px; color: #888; margin-left: 8px;
}
.jefd-close-btn {
    background: none; border: none; font-size: 11px;
    letter-spacing: 2px; font-weight: 600;
    color: var(--jefd-text); cursor: pointer; padding: 6px 0;
    transition: opacity .15s;
}
.jefd-close-btn:hover { opacity: .6; }

/* ─────────────────────────────────────────────
   BODY — scrollable middle section
   ───────────────────────────────────────────── */
.jefd-body {
    flex: 1 1 auto; overflow-y: auto; padding: 0 24px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.jefd-empty { text-align: center; padding: 48px 0; }
.jefd-empty p { margin-bottom: 20px; color: #999; font-size: 13px; }

/* ─── Cart Items ─── */
.jefd-item {
    display: grid; grid-template-columns: 68px 1fr auto;
    gap: 14px; padding: 16px 0;
    border-bottom: 1px solid var(--jefd-border);
    transition: opacity .2s ease;
}
.jefd-item:last-child { border-bottom: none; }
.jefd-item.jefd-loading { opacity: .45; pointer-events: none; }
.jefd-item.jefd-removing { opacity: .2; pointer-events: none; }

.jefd-item-image {
    width: 68px; height: 68px; border-radius: 6px;
    overflow: hidden; background: #eee; flex-shrink: 0;
}
.jefd-item-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.jefd-item-details { min-width: 0; align-self: center; }
.jefd-item-name {
    font-size: 11px; font-weight: 700; letter-spacing: .5px;
    margin: 0 0 4px; text-transform: uppercase;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.jefd-item-var {
    display: block; font-size: 10px; color: #888;
    letter-spacing: .5px; text-transform: uppercase;
}
.jefd-item-actions {
    display: flex; flex-direction: column;
    align-items: flex-end; justify-content: space-between;
    flex-shrink: 0;
}
.jefd-item-price { font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ─── Qty Controls ─── */
.jefd-qty-control { display: flex; align-items: center; gap: 8px; }
.jefd-qty-btn {
    width: 28px; height: 28px; border-radius: 50%;
    border: 1px solid var(--jefd-border); background: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 15px; line-height: 1; padding: 0;
    transition: background .12s, border-color .12s;
    -webkit-appearance: none; appearance: none;
}
.jefd-qty-btn:hover:not(:disabled) { background: var(--jefd-border); }
.jefd-qty-btn:disabled { opacity: .35; cursor: not-allowed; }
.jefd-qty-btn svg { width: 13px; height: 13px; }
.jefd-qty-value { font-size: 13px; font-weight: 600; min-width: 14px; text-align: center; }
.jefd-qty-delete { color: #999; }
.jefd-qty-delete:hover:not(:disabled) { color: var(--jefd-error); border-color: var(--jefd-error); }

/* ─────────────────────────────────────────────
   FOOTER — fixed at bottom, scrolls internally
   ───────────────────────────────────────────── */
.jefd-footer {
    flex-shrink: 0;
    max-height: 55vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 16px 24px 24px;
    border-top: 1px solid var(--jefd-border);
    background: var(--jefd-drawer-bg);
}

/* ─── Order Note Button ─── */
.jefd-order-note-btn {
    width: 100%; background: none; border: 1px dashed var(--jefd-border); border-radius: 8px;
    display: flex; align-items: center; gap: 6px;
    font-size: 10px; letter-spacing: 1.2px; font-weight: 600;
    text-transform: uppercase; color: var(--jefd-text);
    cursor: pointer; padding: 10px 12px; margin-bottom: 10px;
    transition: opacity .15s;
}
.jefd-order-note-btn:hover { opacity: .6; }
.jefd-note-check { display: none; margin-left: auto; font-size: 12px; color: var(--jefd-success, #22c55e); }
.jefd-order-note-btn.has-note { border-color: var(--jefd-success, #22c55e); color: var(--jefd-success, #22c55e); }
.jefd-order-note-btn.has-note .jefd-note-check { display: inline; }

/* ─── Order Note Slide-Up Panel ─── */
.jefd-order-note-panel {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: var(--jefd-drawer-bg); padding: 20px 24px 24px;
    border-top: 1px solid var(--jefd-border); z-index: 15;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,.1);
    transform: translateY(100%); transition: transform .3s ease;
}
.jefd-order-note-panel.is-active { transform: translateY(0); }
.jefd-order-note-panel-header {
    font-size: 11px; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase; color: #888; margin-bottom: 10px;
}
.jefd-order-note-textarea {
    width: 100% !important; box-sizing: border-box;
    min-height: 100px; resize: vertical; font-family: inherit;
    font-size: 14px; padding: 12px; border-radius: 8px;
    border: 1px solid var(--jefd-border); background: #fff;
}
.jefd-order-note-textarea:focus {
    outline: none; border-color: var(--jefd-btn-bg);
}
.jefd-order-note-error {
    display: none; color: #dc2626; font-size: 12px;
    margin-top: 6px; font-weight: 500;
}
.jefd-order-note-error.is-visible { display: block; }
.jefd-order-note-actions { display: flex; gap: 10px; margin-top: 12px; }
.jefd-order-note-actions .jefd-btn { flex: 1; }

/* ─── Free Delivery Progress ─── */
.jefd-free-delivery { margin-bottom: 12px; }
.jefd-free-msg { font-size: 11px; margin: 0 0 6px; color: #777; }
.jefd-free-msg.jefd-free-achieved { color: var(--jefd-success); font-weight: 600; }
.jefd-free-bar {
    height: 3px; background: var(--jefd-border);
    border-radius: 2px; overflow: hidden;
}
.jefd-free-fill {
    height: 100%; background: var(--jefd-success);
    border-radius: 2px; transition: width .5s ease;
}

/* ─── Min Order / Status Messages ─── */
.jefd-min-order-msg { margin-bottom: 10px; }

/* ─── Store Hours Badge ─── */
.jefd-store-hours-badge {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 0; margin-bottom: 8px;
    font-size: 11px; color: #666; font-weight: 500;
}
.jefd-hours-dot {
    width: 7px; height: 7px; border-radius: 50%;
    display: inline-block; flex-shrink: 0;
}
.jefd-hours-dot.jefd-hours-open  { background: var(--jefd-success); }
.jefd-hours-dot.jefd-hours-closed { background: var(--jefd-error); }

.jefd-status {
    padding: 10px 14px; border-radius: var(--jefd-radius);
    font-size: 12px; font-weight: 500; line-height: 1.4;
}
.jefd-status--success { background: #E8F5E9; color: #1B5E20; }
.jefd-status--error   { background: #FFEBEE; color: #B71C1C; }
.jefd-status--loading { background: #E3F2FD; color: #0D47A1; }

/* ─── Subtotal ─── */
.jefd-subtotal {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0 2px; font-size: 13px; font-weight: 700;
    letter-spacing: .5px; text-transform: uppercase;
}
.jefd-tax-note { font-size: 10px; color: #999; margin: 0 0 14px; }
.jefd-tax-note strong { color: #777; }

/* ─── Tip Section ─── */
.jefd-tip-section {
    padding: 12px 0; margin-bottom: 10px;
    border-top: 1px solid var(--jefd-border);
}
.jefd-tip-label {
    font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
    text-transform: uppercase; margin-bottom: 10px;
}
.jefd-tip-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.jefd-tip-btn {
    padding: 7px 12px; border: 1px solid var(--jefd-border);
    border-radius: 6px; background: #fff; cursor: pointer;
    font-size: 12px; font-weight: 500; transition: all .12s;
}
.jefd-tip-btn:hover { border-color: var(--jefd-btn-bg); }
.jefd-tip-btn.selected {
    background: var(--jefd-btn-bg); color: var(--jefd-btn-text);
    border-color: var(--jefd-btn-bg);
}
.jefd-tip-custom { display: flex; gap: 8px; margin-top: 8px; }
.jefd-tip-custom input {
    flex: 1; padding: 8px 12px; border: 1px solid var(--jefd-border);
    border-radius: 6px; font-size: 13px;
}
.jefd-tip-display {
    font-size: 12px; font-weight: 600; color: var(--jefd-success); padding: 4px 0;
}

/* ─────────────────────────────────────────────
   FULFILLMENT — 50/50 Two Columns
   ───────────────────────────────────────────── */
.jefd-fulfillment { margin-bottom: 14px; }
.jefd-choice-buttons {
    display: flex; gap: 12px;
}
.jefd-choice-btn {
    flex: 1 1 0;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 8px;
    padding: 18px 10px; min-height: 90px;
    border: 2px solid var(--jefd-border);
    border-radius: var(--jefd-radius); background: #fff;
    cursor: pointer; transition: all .2s; text-align: center;
}
.jefd-choice-btn span {
    font-size: 11px; font-weight: 600; letter-spacing: .6px;
    text-transform: uppercase; line-height: 1.2;
}
.jefd-choice-btn:hover { border-color: var(--jefd-btn-bg); }
.jefd-choice-btn.selected {
    border-color: var(--jefd-btn-bg); background: var(--jefd-btn-bg);
    color: var(--jefd-btn-text);
}
.jefd-choice-btn.selected svg { stroke: var(--jefd-btn-text); }
.jefd-choice-icon { flex-shrink: 0; }

/* ─── Fulfillment Summary ─── */
.jefd-summary {
    background: #fff; border: 1px solid var(--jefd-border);
    border-radius: var(--jefd-radius); padding: 12px 16px; margin-bottom: 14px;
}
.jefd-summary-row {
    display: flex; justify-content: space-between;
    font-size: 11px; padding: 3px 0;
}
.jefd-summary-row span { color: #888; }
.jefd-summary-row strong { font-weight: 600; text-align: right; max-width: 60%; }
.jefd-edit-btn {
    display: block; width: 100%; background: none; border: none;
    font-size: 10px; font-weight: 600; letter-spacing: 1.2px;
    text-transform: uppercase; text-align: center;
    padding: 8px 0 0; cursor: pointer; color: var(--jefd-text);
    transition: opacity .15s;
}
.jefd-edit-btn:hover { opacity: .6; }

/* ─── Checkout Warning ─── */
.jefd-checkout-warning {
    background: #FFF8E1; color: #E65100; border: 1px solid var(--jefd-warning);
    border-radius: var(--jefd-radius); padding: 10px 14px; margin-bottom: 10px;
    font-size: 12px; text-align: center; font-weight: 500;
}

/* ─── Checkout Button ─── */
.jefd-checkout-btn {
    display: block; width: 100%; padding: 15px; text-align: center;
    background: var(--jefd-btn-bg); color: var(--jefd-btn-text);
    text-decoration: none; font-size: 13px; font-weight: 700;
    letter-spacing: 2px; text-transform: uppercase;
    border-radius: var(--jefd-radius); transition: opacity .15s;
    border: none; cursor: pointer;
}
.jefd-checkout-btn:hover { opacity: .88; color: var(--jefd-btn-text); }
.jefd-checkout-btn.jefd-checkout-disabled {
    opacity: .3; cursor: not-allowed; pointer-events: none;
}

/* ─────────────────────────────────────────────
   STEP PANELS — slide-in sub-screens
   ───────────────────────────────────────────── */
.jefd-step-panel {
    position: absolute; inset: 0;
    background: var(--jefd-drawer-bg); z-index: 10;
    display: flex; flex-direction: column;
    transform: translateX(100%); transition: transform .3s ease;
}
.jefd-step-panel.is-active { transform: translateX(0); }
.jefd-step-header {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 24px; border-bottom: 1px solid var(--jefd-border);
    flex-shrink: 0;
}
.jefd-step-header h3 {
    margin: 0; font-size: 13px; font-weight: 700;
    letter-spacing: .5px; text-transform: uppercase;
}
.jefd-back-btn {
    background: none; border: none; cursor: pointer;
    padding: 4px; color: var(--jefd-text); display: flex;
    transition: opacity .15s;
}
.jefd-back-btn:hover { opacity: .6; }
.jefd-step-body {
    flex: 1 1 auto; overflow-y: auto; padding: 24px;
    -webkit-overflow-scrolling: touch;
}
.jefd-step-error { margin-top: 12px; }

/* ─── Inputs ─── */
.jefd-btn {
    display: inline-block; padding: 12px 24px; font-size: 12px;
    font-weight: 600; letter-spacing: 1px; text-transform: uppercase;
    border: none; border-radius: var(--jefd-radius); cursor: pointer;
    text-align: center; transition: opacity .15s;
}
.jefd-btn:hover { opacity: .85; }
.jefd-btn-primary { width: 100%; background: var(--jefd-btn-bg); color: var(--jefd-btn-text); }
.jefd-btn-outline { background: transparent; border: 1px solid var(--jefd-border); color: var(--jefd-text); }
.jefd-input, .jefd-textarea {
    width: 100%; padding: 12px 14px; border: 1px solid var(--jefd-border);
    border-radius: 6px; font-size: 13px; background: #fff;
    box-sizing: border-box; color: var(--jefd-text);
    transition: border-color .15s;
}
.jefd-input:focus, .jefd-textarea:focus {
    outline: none; border-color: var(--jefd-btn-bg);
}
.jefd-textarea { min-height: 100px; resize: vertical; font-family: inherit; }
.jefd-field { margin-bottom: 14px; }
.jefd-field label {
    display: block; font-size: 10px; font-weight: 700;
    letter-spacing: 1px; text-transform: uppercase;
    margin-bottom: 6px; color: #888;
}

/* ─── Location Cards ─── */
.jefd-locations { display: flex; flex-direction: column; gap: 10px; }
.jefd-location-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; background: #fff; border: 2px solid var(--jefd-border);
    border-radius: var(--jefd-radius); cursor: pointer; transition: border-color .15s;
}
.jefd-location-card:hover { border-color: var(--jefd-btn-bg); }
.jefd-location-card.selected { border-color: var(--jefd-btn-bg); background: rgba(0,0,0,.02); }
.jefd-location-card input { display: none; }
.jefd-location-info { flex: 1; min-width: 0; }
.jefd-location-info strong {
    display: block; font-size: 12px; font-weight: 700; margin-bottom: 2px;
}
.jefd-location-info span { display: block; font-size: 11px; color: #888; }
.jefd-location-check { opacity: 0; transition: opacity .15s; flex-shrink: 0; }
.jefd-location-card.selected .jefd-location-check { opacity: 1; }

/* ─────────────────────────────────────────────
   TRIGGER BUTTON — inline (static) by default
   User places via Elementor widget / shortcode
   ───────────────────────────────────────────── */
.jefd-trigger {
    position: relative; display: inline-flex; align-items: center;
    justify-content: center; background: none; border: none;
    cursor: pointer; padding: 8px; color: inherit;
}
.jefd-trigger-icon { display: flex; align-items: center; }
.jefd-trigger-icon svg { width: 24px; height: 24px; }
.jefd-trigger-count {
    position: absolute; top: 0; right: -4px;
    background: var(--jefd-btn-bg); color: var(--jefd-btn-text);
    font-size: 9px; font-weight: 700; min-width: 17px; height: 17px;
    border-radius: 9px; display: flex; align-items: center;
    justify-content: center; padding: 0 4px;
}
.jefd-trigger-count[data-count="0"] { display: none; }

/* ─────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────── */
@media (max-width: 480px) {
    .jefd-drawer { width: 100vw; }
    .jefd-header { padding: 16px 18px; }
    .jefd-body { padding: 0 18px; }
    .jefd-footer { padding: 14px 18px 20px; }
    .jefd-step-body { padding: 20px 18px; }
    .jefd-item { grid-template-columns: 56px 1fr auto; gap: 10px; }
    .jefd-item-image { width: 56px; height: 56px; }
    .jefd-choice-buttons { gap: 8px; }
    .jefd-choice-btn { padding: 14px 8px; min-height: 78px; }
}
