/* ==========================================================================
   Kayan QR Menu Styling — Responsive Luxury Cafe Menu
   Mobile: full-screen app  |  Desktop: two-pane (brand sidebar + menu grid)
   ========================================================================== */

/* Design Tokens & Theme Variables */
:root {
    --bg-dark: #121214;
    --bg-card: #1c1c21;
    --bg-card-2: #232329;
    --border-dark: 1px solid rgba(212, 175, 55, 0.15);

    --gold: #d4af37;
    --gold-soft: #e7c869;
    --gold-glow: rgba(212, 175, 55, 0.2);

    --text-primary: #f4f4f7;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;

    --font-heading: 'Playfair Display', serif;
    --font-sans: 'Plus Jakarta Sans', sans-serif;

    --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Scrollbar */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

::-webkit-scrollbar {
    width: 0px; /* Hide scrollbars for slick app look */
    height: 0px;
}

html, body { height: 100%; }

body.menu-body {
    background-color: #0c0c0e;
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(0px, 4vw, 48px);
    position: relative;
    overflow: hidden;
}

/* ==========================================================================
   Ambient atmosphere (behind the framed shell on desktop)
   ========================================================================== */
.ambient-glow {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(55% 50% at 50% 0%, rgba(212, 175, 55, 0.10) 0%, transparent 70%),
        radial-gradient(45% 45% at 12% 100%, rgba(124, 45, 18, 0.18) 0%, transparent 70%),
        radial-gradient(45% 45% at 88% 90%, rgba(212, 175, 55, 0.06) 0%, transparent 70%);
}

.ambient-grain {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ==========================================================================
   Menu Shell
   ========================================================================== */
.menu-shell {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    height: 100dvh;
    max-height: 920px;
    background-color: var(--bg-dark);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==========================================================================
   Brand Pane — header on mobile, sidebar on desktop
   ========================================================================== */
.brand-pane {
    position: relative;
    flex-shrink: 0;
    border-bottom: var(--border-dark);
}

/* The rounded background image is clipped by the shell's overflow on desktop,
   so the brand pane itself stays overflow-visible — otherwise it would clip
   the table dropdown when it opens. */
.brand-pane__bg { border-radius: inherit; }

.brand-pane__bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background:
        linear-gradient(180deg, rgba(18,18,20,0.78) 0%, rgba(18,18,20,0.92) 100%),
        radial-gradient(120% 80% at 50% 0%, rgba(212,175,55,0.22) 0%, transparent 60%),
        url("https://images.unsplash.com/photo-1442512595331-e89e73853f31?w=700&q=80&auto=format&fit=crop") center/cover no-repeat;
    background-color: var(--bg-card);
}

.brand-pane__content {
    position: relative;
    z-index: 1;
    padding: 2.25rem 1.5rem 1.5rem;
    text-align: center;
}

.cafe-logo {
    font-family: var(--font-heading);
    font-size: 2rem;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: 6px;
    padding-left: 6px; /* balance the letter-spacing */
    background: linear-gradient(180deg, var(--gold-soft), var(--gold));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.4rem;
}

.cafe-tagline {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1.4rem;
}

.brand-note {
    display: none; /* desktop-only flourish */
    font-size: 0.66rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: 1.5rem;
}

.brand-note i { color: var(--gold); margin-right: 0.35rem; }

/* Table Selector + custom dropdown */
.table-selector-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: var(--border-dark);
    border-radius: 12px;
    padding: 0.55rem 0.6rem 0.55rem 0.85rem;
}

.ts-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--gold);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.custom-select { position: relative; }

.cs-trigger {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(212, 175, 55, 0.25);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 0.75rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.cs-trigger:hover { border-color: var(--gold); }

.cs-caret {
    font-size: 0.65rem;
    color: var(--gold);
    transition: transform 0.3s ease;
}

.custom-select.open .cs-caret { transform: rotate(180deg); }

.cs-options {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    list-style: none;
    background: var(--bg-card-2);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 14px;
    padding: 0.4rem;
    box-shadow: 0 18px 40px -10px rgba(0, 0, 0, 0.7);
    z-index: 60;
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.custom-select.open .cs-options {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.cs-option {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.55rem 0.75rem;
    border-radius: 9px;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}

.cs-option:hover {
    background: rgba(212, 175, 55, 0.10);
    color: var(--text-primary);
}

.cs-option.selected {
    background: linear-gradient(180deg, var(--gold-soft), var(--gold));
    color: #1a1505;
}

/* ==========================================================================
   Menu Pane — anchors the scroll area + bottom bar/drawer
   ========================================================================== */
.menu-pane {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Category Navigation Scroll Bar */
.category-nav {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    background-color: var(--bg-dark);
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.cat-pill {
    background-color: var(--bg-card);
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition-smooth);
}

.cat-pill:hover { color: var(--text-primary); }

.cat-pill.active {
    color: var(--gold);
    border-color: var(--gold);
    background-color: rgba(212, 175, 55, 0.05);
    box-shadow: 0 0 12px var(--gold-glow);
}

/* Menu List Container */
.menu-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 1.25rem;
    padding-bottom: 96px; /* room for the floating tray bar */
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Menu Item Card */
.menu-item {
    display: grid;
    grid-template-columns: 1fr 96px;
    gap: 1rem;
    background-color: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.04);
    padding: 1rem;
    border-radius: 18px;
    align-items: center;
    transition: var(--transition-smooth);
    animation: card-rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.menu-item:hover {
    border-color: rgba(212, 175, 55, 0.25);
    transform: translateY(-2px);
    background-color: var(--bg-card-2);
}

@keyframes card-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.item-details h3 {
    font-family: var(--font-heading);
    font-size: 1.18rem;
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.item-details p {
    font-size: 0.74rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.7rem;
}

.item-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gold);
}

.item-price::after {
    content: " EGP";
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* Media (image / gradient fallback + add button) */
.item-media {
    position: relative;
    width: 96px;
    height: 96px;
}

.item-image-mock {
    position: absolute;
    inset: 0;
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(255, 255, 255, 0.12);
    font-size: 1.6rem;
    overflow: hidden;
}

.item-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.item-media::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 14px;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
    background: linear-gradient(180deg, rgba(255,255,255,0.10) 0%, transparent 35%);
}

.add-item-btn {
    position: absolute;
    bottom: -7px;
    right: -7px;
    z-index: 2;
    background: linear-gradient(180deg, var(--gold-soft), var(--gold));
    color: var(--bg-dark);
    border: 2px solid var(--bg-card);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
    transition: var(--transition-smooth);
}

.add-item-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 6px 18px var(--gold-glow);
}

.add-item-btn:active { transform: scale(0.95); }

/* ==========================================================================
   Sticky Bottom Tray Bar
   ========================================================================== */
.bottom-tray-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    min-height: 74px;
    background: linear-gradient(180deg, var(--gold-soft), var(--gold));
    color: var(--bg-dark);
    padding: 0 1.5rem;
    display: none; /* shown via JS once tray has items */
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    cursor: pointer;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
    animation: bar-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes bar-in {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.tray-info { display: flex; flex-direction: column; }

.tray-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    opacity: 0.65;
}

.tray-total {
    font-size: 1.35rem;
    font-family: var(--font-heading);
    font-weight: 800;
}

.view-tray-btn {
    background: rgba(0, 0, 0, 0.12);
    border: none;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--bg-dark);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 1rem;
    border-radius: 9999px;
    cursor: pointer;
}

/* ==========================================================================
   Tray Slide-Up Drawer
   ========================================================================== */
.tray-drawer-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 20;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.tray-drawer-overlay.active { display: block; opacity: 1; }

.tray-drawer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 80%;
    background-color: var(--bg-card);
    border-top: var(--border-dark);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    z-index: 21;
    display: flex;
    flex-direction: column;
    transform: translateY(101%);
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.tray-drawer.active { transform: translateY(0); }

.drawer-grabber {
    width: 40px;
    height: 4px;
    border-radius: 9999px;
    background: var(--text-muted);
    margin: 0.7rem auto 0;
}

.drawer-header {
    padding: 0.9rem 1.5rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-header h3 { font-family: var(--font-heading); font-size: 1.25rem; }

.close-drawer {
    background: none;
    border: none;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
}

.drawer-items-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
}

/* Empty tray message */
.empty-tray-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 140px;
    color: var(--text-secondary);
    text-align: center;
}

.empty-tray-message i {
    font-size: 2.2rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.empty-tray-message p { font-size: 0.85rem; }

/* Cart item */
.tray-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.9rem;
    margin-bottom: 1.1rem;
    align-items: center;
}

.tray-item-details h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.15rem; }
.tray-item-details span { font-size: 0.78rem; color: var(--gold); font-weight: 700; }

.qty-controls {
    display: flex;
    align-items: center;
    border: 1px solid var(--text-muted);
    border-radius: 8px;
    overflow: hidden;
}

.qty-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-weight: 700;
    transition: background 0.2s;
}

.qty-btn:hover { background: rgba(255, 255, 255, 0.06); }

.qty-val { font-size: 0.8rem; width: 24px; text-align: center; }

.remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.2s;
}

.remove-btn:hover { color: #ef4444; }

/* Drawer footer */
.drawer-footer {
    flex-shrink: 0;
    padding: 1.25rem 1.5rem calc(1.25rem + env(safe-area-inset-bottom));
    background-color: var(--bg-dark);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.total-row strong { font-size: 1.3rem; color: var(--gold); font-family: var(--font-heading); }

.order-instructions {
    font-size: 0.66rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.send-order-btn {
    width: 100%;
    background-color: #25d366;
    color: white;
    border: none;
    padding: 1rem 0;
    border-radius: 12px;
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    box-shadow: 0 8px 20px rgba(37, 211, 102, 0.25);
}

.send-order-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 26px rgba(37, 211, 102, 0.35);
}

.send-order-btn i { font-size: 1.15rem; }

/* Toast */
.toast {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(180deg, var(--gold-soft), var(--gold));
    color: var(--bg-dark);
    padding: 0.65rem 1.5rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    z-index: 500;
    border-radius: 9999px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: bottom 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

.toast i { font-size: 0.95rem; }
.toast.active { bottom: 96px; }

/* ==========================================================================
   DESKTOP — two-pane layout (brand sidebar + menu grid)
   ========================================================================== */
@media (min-width: 820px) {
    .menu-shell {
        max-width: 1080px;
        height: min(760px, 88dvh);
        max-height: none;
        flex-direction: row;
        border-radius: 28px;
        border: 1px solid rgba(212, 175, 55, 0.18);
        box-shadow:
            0 40px 90px -20px rgba(0, 0, 0, 0.65),
            0 1px 0 0 rgba(255, 255, 255, 0.04) inset;
    }

    /* Brand pane becomes a full-height left sidebar */
    .brand-pane {
        width: 320px;
        flex-shrink: 0;
        border-bottom: none;
        border-right: var(--border-dark);
        display: flex;
    }

    .brand-pane__content {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        padding: 2.75rem 1.75rem;
        text-align: left;
    }

    .cafe-logo { font-size: 2.4rem; padding-left: 0; }
    .cafe-tagline { margin-bottom: 0; }
    .table-selector-wrap { flex-direction: column; align-items: stretch; gap: 0.7rem; }
    .ts-label { justify-content: flex-start; }
    .custom-select { width: 100%; }
    .cs-trigger { width: 100%; justify-content: space-between; }

    /* Selector sits low in the sidebar → open the list UPWARD so it stays
       inside the shell instead of overflowing past the bottom edge. */
    .cs-options {
        left: 0;
        right: 0;
        min-width: 0;
        top: auto;
        bottom: calc(100% + 8px);
        transform-origin: bottom center;
        transform: translateY(6px) scale(0.98);
    }

    .brand-note { display: block; }

    /* Menu pane fills the rest */
    .menu-pane { flex: 1; }

    /* Menu becomes a responsive grid of cards */
    .menu-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        align-content: start;
        gap: 1rem;
        padding: 1.5rem;
        padding-bottom: 100px;
    }

    .category-nav { padding: 1.25rem 1.5rem; }
}

@media (min-width: 1180px) {
    .menu-list { grid-template-columns: repeat(3, 1fr); }
}

/* ==========================================================================
   MOBILE — true full-screen app
   ========================================================================== */
@media (max-width: 819px) {
    body.menu-body {
        padding: 0;
        background-color: var(--bg-dark);
        align-items: stretch;
    }

    .menu-shell {
        max-width: 100%;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        border: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}
