/* ============================================================
   COCO BROAST – STYLESHEET  V9
   RTL | Light & Dark | VIP System | Responsive Grid
   ============================================================ */

/* ---------- 1. DESIGN TOKENS ---------- */
:root {
    --primary:      #ff5722;
    --primary-dark: #e64a19;
    --gold:         #d4a017;
    --gold-light:   #f4c430;
    --vip-color:    #b8860b;
    --vip-bg:       #fffbea;
    --vip-border:   #e8c840;
    --green:        #25d366;
    --red:          #e53935;

    /* Light theme */
    --bg:           #f7f7f7;
    --surface:      #ffffff;
    --surface-2:    #f0f0f0;
    --text:         #1a1a1a;
    --text-muted:   #666666;
    --card-border:  #e5e5e5;
    --header-bg:    #ffffff;
    --nav-bg:       #ffffff;
    --shadow-sm:    0 2px 8px rgba(0,0,0,.08);
    --shadow-md:    0 4px 20px rgba(0,0,0,.12);
    --shadow-lg:    0 8px 40px rgba(0,0,0,.18);
    --radius-sm:    8px;
    --radius-md:    12px;
    --radius-lg:    18px;
}

[data-theme="dark"] {
    --bg:          #121212;
    --surface:     #1e1e1e;
    --surface-2:   #2a2a2a;
    --text:        #f0f0f0;
    --text-muted:  #999999;
    --card-border: #333333;
    --header-bg:   #1a1a1a;
    --nav-bg:      #1a1a1a;
    --vip-bg:      #251f08;
    --vip-border:  #7a6000;
    --shadow-sm:   0 2px 8px rgba(0,0,0,.3);
    --shadow-md:   0 4px 20px rgba(0,0,0,.4);
    --shadow-lg:   0 8px 40px rgba(0,0,0,.5);
}

/* ---------- 2. RESET ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html          { scroll-behavior: smooth; }
img           { display: block; }
ul            { list-style: none; }
button        { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; }

body {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    transition: background .3s, color .3s;
    min-height: 100vh;
    overflow-x: hidden;
}

.hidden { display: none !important; }

/* ---------- 3. SPLASH ---------- */
#splash-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* No transition here — exit is handled by shrink-fade-out animation */
}

/* ── Exit animation: cinematic scale-down + fade ── */
#splash-screen.shrink-fade-out {
    animation: shrinkFadeOut 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
}

@keyframes shrinkFadeOut {
    0%   { transform: scale(1);                       opacity: 1; }
    100% { transform: scale(0.6) translateY(20px);    opacity: 0; }
}

/* ── Splash logo — large, viewport-proportional ── */
#splash-logo {
    max-width: 90vw;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    opacity: 0;                     /* hidden until JS reveals it */
    transition: opacity .35s ease;  /* smooth reveal fallback */
}

/* JS adds this class after injecting the correct image src */
#splash-logo.splash-logo-visible {
    animation: splashPulse 1.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes splashPulse {
    0%   { transform: scale(.75);   opacity: 0; }
    65%  { transform: scale(1.04);  opacity: 1; }
    100% { transform: scale(1);     opacity: 1; }
}

/* ---------- 4. HEADER ---------- */
#main-header {
    position: sticky;
    top: 0;
    z-index: 500;
    background: var(--header-bg);
    border-bottom: 1px solid var(--card-border);
    box-shadow: var(--shadow-sm);
    transition: background .3s;
}

.header-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;      /* logo perfectly centred */
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
    height: 70px;
}

/* logo size lock */
.header-logo {
    height: 60px;
    max-width: 250px;
    width: auto;
    object-fit: contain;
}

/* theme toggle – absolutely positioned so it never shifts the centred logo */
.theme-toggle {
    position: absolute;
    left: 5%;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--card-border);
    background: var(--surface-2);
    color: var(--text);
    transition: background .2s, transform .2s;
}

.theme-toggle:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: translateY(-50%) rotate(20deg);
}

.theme-toggle svg { width: 20px; height: 20px; }

/* ---------- 5. HERO SLIDER ---------- */
.hero-slider {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #111;
    aspect-ratio: 21 / 9;
    max-height: 400px;
}

@media (max-width: 640px) {
    .hero-slider { aspect-ratio: 16 / 9; max-height: 240px; }
}

.carousel-track { display: flex; width: 100%; height: 100%; }

.carousel-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .6s ease;
    pointer-events: none;
}

.carousel-slide.active { opacity: 1; pointer-events: auto; }

.carousel-slide img {
    width: 100%; height: 100%;
    object-fit: cover;
    filter: brightness(.82);
}

.carousel-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px;
    background: linear-gradient(to top, rgba(0,0,0,.55) 0%, transparent 60%);
}

.carousel-content h2 {
    color: #fff;
    font-size: clamp(1.1rem, 3vw, 1.9rem);
    font-weight: 800;
    text-shadow: 0 2px 8px rgba(0,0,0,.6);
    margin-bottom: 6px;
}

.carousel-price { color: var(--gold-light); font-size: clamp(.9rem, 2.5vw, 1.4rem); font-weight: 700; }

.slide-countdown {
    position: absolute;
    top: 12px; left: 12px;
    background: rgba(255,87,34,.92);
    color: #fff;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: clamp(.7rem, 1.8vw, .85rem);
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(0,0,0,.35);
    backdrop-filter: blur(4px);
}

.carousel-btn {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    z-index: 10;
    background: rgba(0,0,0,.45);
    color: #fff; border: none;
    width: 36px; height: 36px;
    border-radius: 50%;
    font-size: 1.4rem;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}

.carousel-btn:hover { background: var(--primary); }
.carousel-btn.next  { left: 10px; }
.carousel-btn.prev  { right: 10px; }

.carousel-indicators {
    position: absolute;
    bottom: 10px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 6px; z-index: 10;
}

.carousel-indicators .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,.5);
    cursor: pointer;
    transition: background .2s, transform .2s;
}

.carousel-indicators .dot.active { background: var(--primary); transform: scale(1.35); }

/* ---------- 6. CATEGORY NAV ---------- */
.category-nav {
    position: sticky;
    top: 70px;
    z-index: 400;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--card-border);
    box-shadow: var(--shadow-sm);
    transition: background .3s;
}

.category-list {
    display: flex;
    overflow-x: auto;
    padding: 0 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    white-space: nowrap;
}

.category-list::-webkit-scrollbar { display: none; }

/* centre on desktop */
@media (min-width: 768px) {
    .category-list {
        justify-content: center;
        flex-wrap: wrap;
        overflow-x: visible;
    }
}

.category-item {
    display: inline-flex;
    align-items: center;
    padding: 14px 18px;
    font-size: .9rem;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
    transition: color .2s, border-color .2s;
}

.category-item:hover  { color: var(--primary); }
.category-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- 7. MAIN MENU ---------- */
#menu-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 16px 120px;
}

.loading-msg { text-align: center; color: var(--text-muted); padding: 60px 20px; font-size: 1.1rem; }

.menu-section { margin-bottom: 40px; scroll-margin-top: 140px; }

.section-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    padding: 8px 0 12px;
    border-bottom: 2px solid var(--primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    width: 6px; height: 22px;
    background: var(--primary);
    border-radius: 3px;
}

/* Grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

@media (min-width: 640px)  { .items-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .items-grid { grid-template-columns: repeat(4, 1fr); } }

/* ---------- 8. ITEM CARD ---------- */
.menu-item {
    background: var(--surface);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: transform .2s, box-shadow .2s;
}

.menu-item:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.item-image-wrapper {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--surface-2);
}

.item-image { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.menu-item:hover .item-image { transform: scale(1.07); }

.item-badge {
    position: absolute;
    top: 8px; right: 8px;
    background: var(--primary);
    color: #fff;
    font-size: .72rem; font-weight: 800;
    padding: 3px 9px;
    border-radius: 20px;
    z-index: 2;
}

.item-content {
    padding: 10px 10px 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 5px;
}

.item-title { font-size: .95rem; font-weight: 800; color: var(--text); line-height: 1.3; }

.item-desc  { font-size: .78rem; color: var(--text-muted); line-height: 1.4; flex: 1; }

.countdown-timer {
    display: block;
    background: rgba(255,51,51,.1);
    color: #e53935;
    border: 1px dashed #e53935;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: .75rem; font-weight: 700;
    text-align: center;
}

.variant-select {
    width: 100%;
    padding: 7px 10px 7px 28px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    color: var(--text);
    font-size: .82rem; font-weight: 600;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 8px center;
    background-size: 1em;
    cursor: pointer;
    transition: border-color .2s;
}

.variant-select:focus { outline: none; border-color: var(--primary); }

.item-price-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; }

.price-container { display: flex; flex-direction: column; gap: 2px; }

.original-price { 
    font-size: .85rem; /* Increased from .72rem */
    font-weight: 700; /* Bolder to survive the strikethrough */
    color: var(--text-muted); 
    text-decoration: line-through; 
    text-decoration-color: var(--red); /* Emphasize the discount */
    text-decoration-thickness: 2px; /* Make the strike more deliberate */
    margin-bottom: 2px;
}

.current-price { font-size: 1rem; font-weight: 800; color: var(--primary); line-height: 1.2; }
.current-price .currency { font-size: .72rem; font-weight: 600; }

/* VIP price tag on card */
.vip-price-tag {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 3px;
    font-weight: 700;
    color: var(--vip-color);
    line-height: 1.4;
}

.vip-label-text {
    color: var(--vip-color);
    font-weight: 700;
    font-size: 0.72rem;
    display: inline-block;
    margin-left: 3px;
}

.vip-price-value {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--vip-color);
    white-space: nowrap;
}

/* Qty stepper */
.cart-controls { display: flex; align-items: center; gap: 4px; }

.btn-qty {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 1.5px solid var(--primary);
    background: transparent;
    color: var(--primary);
    font-size: 1rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}

.btn-qty:hover  { background: var(--primary); color: #fff; }
.btn-qty.qty-zero { border-color: var(--card-border); color: var(--text-muted); }

.item-qty {
    width: 32px;
    text-align: center;
    border: none; background: transparent;
    color: var(--text);
    font-size: .9rem; font-weight: 700;
}

.item-qty:focus           { outline: none; }
.item-qty.qty-zero        { color: var(--text-muted); }
.cart-controls.empty .btn-minus { opacity: .35; pointer-events: none; }

/* ---------- 9. FLOATING CART ---------- */
.floating-cart-btn {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 9999;
    width: 60px; height: 60px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff; border: none;
    box-shadow: 0 6px 24px rgba(255,87,34,.5);
    display: flex; align-items: center; justify-content: center;
    transition: transform .2s, box-shadow .2s;
}

.floating-cart-btn:hover { transform: scale(1.08); box-shadow: 0 8px 30px rgba(255,87,34,.65); }
.floating-cart-btn svg   { width: 26px; height: 26px; }

.cart-badge {
    position: absolute;
    top: -4px; left: -4px;
    background: #fff; color: var(--primary);
    font-size: .75rem; font-weight: 800;
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

/* ---------- 10. CART MODAL ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 8000;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.modal-overlay.hidden { display: none; }

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%; max-width: 520px;
    max-height: 93vh;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: slideUp .3s ease;
    overflow: hidden;
}

@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--card-border);
    flex-shrink: 0;
}

.modal-header h2 { font-size: 1.1rem; font-weight: 800; }

.modal-header-actions { display: flex; align-items: center; gap: 12px; }

.btn-text-danger {
    background: none; border: none;
    color: var(--red);
    font-size: .82rem; font-weight: 600;
    text-decoration: underline;
}

.close-btn {
    background: none; border: none;
    font-size: 1.8rem; color: var(--text-muted);
    line-height: 1; padding: 0;
    display: flex; align-items: center;
}

.close-btn:hover { color: var(--primary); }

.cart-items-list {
    flex: 1; overflow-y: auto;
    padding: 12px 20px;
    display: flex; flex-direction: column; gap: 10px;
    min-height: 60px;
}

.modal-cart-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--card-border);
}

.modal-item-info { flex: 1; min-width: 0; }

.modal-item-title {
    font-size: .88rem; font-weight: 700;
    color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.modal-item-price { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

.modal-item-total { font-size: .88rem; font-weight: 800; color: var(--primary); min-width: 60px; text-align: left; }

.cart-empty-msg { text-align: center; color: var(--text-muted); padding: 30px; font-size: .95rem; }

/* Modal footer */
.modal-footer {
    padding: 14px 20px 20px;
    border-top: 1px solid var(--card-border);
    display: flex; flex-direction: column; gap: 10px;
    overflow-y: auto;
    flex-shrink: 0;
    max-height: 55vh;
}

.modal-inputs { display: flex; flex-direction: column; gap: 8px; }

.modal-inputs input {
    width: 100%; padding: 11px 14px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text);
    font-size: .9rem;
    transition: border-color .2s;
}

.modal-inputs input:focus { outline: none; border-color: var(--primary); }

.delivery-note { font-size: .8rem; color: var(--primary); font-weight: 600; }

.modal-total-row {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 1rem; font-weight: 700;
}

.modal-total-row strong { font-size: 1.1rem; color: var(--primary); }

/* ---------- 11. VIP SECTION ---------- */
.vip-section {
    background: var(--vip-bg);
    border: 1px solid var(--vip-border);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
}

.vip-section-title {
    display: flex; align-items: center; gap: 8px;
    font-size: .88rem; font-weight: 700;
    color: var(--vip-color);
}

.btn-vip-verify {
    width: 100%; padding: 10px;
    background: linear-gradient(135deg, #b8860b, #d4a017);
    color: #fff; border: none;
    border-radius: var(--radius-sm);
    font-size: .9rem; font-weight: 800;
    transition: opacity .2s, transform .15s;
}

.btn-vip-verify:hover { opacity: .9; transform: translateY(-1px); }

.vip-result {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: .88rem; font-weight: 700;
    text-align: center; line-height: 1.5;
}

.vip-result.success {
    background: rgba(37,211,102,.15);
    color: #1a7a3a;
    border: 1px solid rgba(37,211,102,.4);
}

.vip-result.failure {
    background: rgba(229,57,53,.1);
    color: var(--red);
    border: 1px solid rgba(229,57,53,.3);
}

/* Savings row */
.vip-savings-row {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--vip-bg);
    border: 1px solid var(--vip-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: .9rem; font-weight: 700;
}

.vip-savings-row .savings-val { font-size: 1rem; color: var(--vip-color); }

/* Checkout button */
.btn-checkout {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 14px;
    background: var(--green);
    color: #fff; border: none;
    border-radius: var(--radius-md);
    font-size: 1rem; font-weight: 800;
    transition: background .2s, transform .15s;
}

.btn-checkout:hover { background: #1ebe59; transform: translateY(-1px); }

/* ---------- 12. SCROLLBAR ---------- */
::-webkit-scrollbar              { width: 5px; height: 5px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: var(--card-border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover  { background: var(--primary); }