/* =====================================================
   Customer Menu Styles — Mobile First RTL (محسّن)
   ===================================================== */

:root {
    --primary:       #f59e0b;
    --primary-dark:  #d97706;
    --primary-light: #fef3c7;
    --bg:            #f1f5f9;
    --card-radius:   12px;
    --header-h:      106px; /* navbar + tabs */
    --content-max:   1200px;
}

/* ── Universal ─────────────────────────────────────── */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--bg);
    font-family: 'Segoe UI', Tahoma, sans-serif;
    padding-top: var(--header-h);
    overflow-x: hidden;
}

/* ── Container للـ Desktop ─────────────────────────── */
main {
    max-width: var(--content-max);
    margin: 0 auto;
}

/* ── Sticky Header ───────────────────────────────── */
.menu-header {
    position: fixed;
    top: 0; right: 0; left: 0;
    z-index: 1030;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .65rem 1rem;
    max-width: var(--content-max);
    margin: 0 auto;
}

.restaurant-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
}
.restaurant-name small {
    display: block;
    font-size: .7rem;
    font-weight: 400;
    color: #64748b;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.btn-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: none;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #475569;
    cursor: pointer;
    transition: background .15s;
    touch-action: manipulation;
}
.btn-icon:hover { background: var(--primary-light); color: var(--primary-dark); }

/* زر حجز طاولة في الهيدر */
.btn-reserve {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    height: 38px;
    padding: 0 .85rem;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: .85rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    border: 1.5px solid transparent;
    transition: background .15s, border-color .15s;
    touch-action: manipulation;
}
.btn-reserve:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary-dark);
}
.btn-reserve i { font-size: 1.05rem; }

/* Cart icon button */
.btn-cart {
    background: var(--primary);
    color: #fff;
    position: relative;
}
.btn-cart:hover { background: var(--primary-dark); color: #fff; }

.cart-badge {
    position: absolute;
    top: -4px; left: -4px;
    background: #ef4444;
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Table indicator */
.table-indicator {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: 8px;
    padding: .2rem .6rem;
    font-size: .75rem;
    color: #92400e;
    font-weight: 600;
}

/* ── Search Bar ──────────────────────────────────── */
.search-bar {
    padding: 0 1rem .5rem;
    display: none;
    max-width: var(--content-max);
    margin: 0 auto;
}
.search-bar.open { display: block; }
.search-input {
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    padding: .55rem .9rem;
    width: 100%;
    font-size: 16px; /* منع iOS zoom */
    outline: none;
    transition: border-color .15s;
}
.search-input:focus { border-color: var(--primary); }

/* ── Category Tabs ───────────────────────────────── */
.category-tabs-wrapper {
    overflow-x: auto;
    scrollbar-width: none;
    border-top: 1px solid #f1f5f9;
    -webkit-overflow-scrolling: touch;
}
.category-tabs-wrapper::-webkit-scrollbar { display: none; }

.category-tabs {
    display: flex;
    gap: .45rem;
    padding: .6rem 1rem;
    white-space: nowrap;
    max-width: var(--content-max);
    margin: 0 auto;
}

.cat-tab {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .85rem;
    border-radius: 20px;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    font-size: .82rem;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    flex-shrink: 0;
    touch-action: manipulation;
}
.cat-tab i { font-size: .85rem; }
.cat-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

/* ── Menu Sections ───────────────────────────────── */
.menu-section { padding: 0 .75rem 1rem; }

.section-title {
    font-size: .95rem;
    font-weight: 700;
    color: #1e293b;
    padding: 1rem 0 .6rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

/* ── Item Cards ──────────────────────────────────── */
.item-card {
    background: #fff;
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
    transition: transform .15s, box-shadow .15s;
    position: relative;
    height: 100%;
}
.item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,.1);
}

.item-img-wrap {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: #f8fafc;
}
.item-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.item-img.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #cbd5e1;
}

.badge-featured {
    position: absolute;
    top: 6px; right: 6px;
    background: var(--primary);
    color: #fff;
    font-size: .65rem;
    padding: .15rem .45rem;
    border-radius: 6px;
    font-weight: 600;
}

.item-body { padding: .6rem .7rem .7rem; }
.item-name {
    font-size: .85rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: .2rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.item-desc {
    font-size: .72rem;
    color: #94a3b8;
    margin-bottom: .35rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.item-price {
    font-size: .9rem;
    font-weight: 700;
    color: var(--primary);
}

.btn-add {
    width: 32px; height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background .15s, transform .1s;
    flex-shrink: 0;
    touch-action: manipulation;
}
.btn-add:hover { background: var(--primary-dark); transform: scale(1.1); }
.btn-add.added { background: #22c55e; }

/* ── Cart Offcanvas ──────────────────────────────── */
#cartOffcanvas {
    border-radius: 20px 20px 0 0;
    max-height: 92dvh;
}

.offcanvas-header {
    border-bottom: 1px solid #f1f5f9;
    padding: .9rem 1rem;
}

.cart-item-row {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .75rem 0;
    border-bottom: 1px solid #f8fafc;
}
.cart-item-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}
.cart-item-name {
    font-size: .85rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
}
.cart-item-price {
    font-size: .8rem;
    color: var(--primary);
    font-weight: 700;
}

.qty-controls {
    display: flex;
    align-items: center;
    gap: .3rem;
    flex-shrink: 0;
}
.qty-btn {
    width: 28px; height: 28px;
    border-radius: 7px;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    cursor: pointer;
    transition: all .1s;
    touch-action: manipulation;
}
.qty-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.qty-num {
    min-width: 22px;
    text-align: center;
    font-weight: 600;
    font-size: .85rem;
}
.btn-remove {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: .85rem;
    padding: .1rem;
    touch-action: manipulation;
}

/* Cart total bar */
.cart-total-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .75rem 0;
    border-top: 2px solid #f1f5f9;
    font-weight: 700;
}

/* ── Order Type Selector ─────────────────────────── */
.order-types {
    display: flex;
    gap: .5rem;
}
.order-type-btn {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: .6rem .5rem;
    text-align: center;
    cursor: pointer;
    transition: all .15s;
    background: #fff;
    user-select: none;
    touch-action: manipulation;
}
.order-type-btn i {
    font-size: 1.35rem;
    display: block;
    margin-bottom: .2rem;
}
.order-type-btn span {
    font-size: .75rem;
    font-weight: 500;
}
.order-type-btn.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* ── Form Inputs - منع iOS zoom ──────────────────── */
.form-control,
.form-select,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="search"],
textarea {
    font-size: 16px !important;
}

@media (min-width: 768px) {
    .form-control,
    .form-select,
    input,
    textarea {
        font-size: .95rem !important;
    }
}

/* ── Success Screen ──────────────────────────────── */
.success-icon {
    width: 68px; height: 68px;
    border-radius: 50%;
    background: #dcfce7;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #22c55e;
}
.order-num-display {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: .04em;
}

/* ── Empty state ─────────────────────────────────── */
.empty-menu {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}
.empty-menu i {
    font-size: 3rem;
    display: block;
    margin-bottom: .5rem;
}

/* ── Hidden by search ────────────────────────────── */
.item-hidden { display: none !important; }
.section-hidden { display: none !important; }

/* ── Responsive Tweaks ───────────────────────────── */

/* Tablets (768px - 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .menu-section { padding: 0 1rem 1rem; }
    .restaurant-name { font-size: 1.15rem; }
}

/* Desktop (992px+) */
@media (min-width: 992px) {
    body { padding-top: 110px; }
    .menu-section { padding: 0 1rem 1rem; }
    .restaurant-name { font-size: 1.25rem; }
    .header-top { padding: .85rem 1.5rem; }
    .category-tabs { padding: .75rem 1.5rem; }
    
    /* Hover effect أوضح على Desktop */
    .item-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 10px 30px rgba(0,0,0,.12);
    }
}

/* ── Date input Arabic display ───────────────────── */
.date-input-ar::-webkit-datetime-edit { direction: ltr; }
.date-input-ar::-webkit-calendar-picker-indicator { opacity: 0.7; }

/* Small Phones (< 575px) */
@media (max-width: 575.98px) {
    .item-body { padding: .5rem .55rem .6rem; }
    .item-name { font-size: .8rem; }
    .item-price { font-size: .85rem; }
    .restaurant-name { font-size: .95rem; }
    .restaurant-name small { font-size: .65rem; }
    .header-top { padding: .55rem .75rem; }
    .btn-icon { width: 36px; height: 36px; font-size: 1rem; }
    /* على الشاشات الصغيرة: أيقونة الحجز بس بدون نص */
    .btn-reserve { width: 36px; height: 36px; padding: 0; justify-content: center; }
    .btn-reserve-text { display: none; }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
    #cartOffcanvas { max-height: 85dvh; }
}

/* ── Print Styles ────────────────────────────────── */
@media print {
    .menu-header,
    .btn-cart,
    .btn-icon,
    .btn-add,
    #cartOffcanvas,
    .badge-featured {
        display: none !important;
    }
    body {
        padding-top: 0 !important;
        background: #fff !important;
    }
    .item-card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* ═════════════════════════════════════════════════
   ITEM DETAIL MODAL — Hero Image + Sticky Footer
   ═════════════════════════════════════════════════ */
.item-detail-modal .modal-dialog {
    max-width: 480px;
    margin: 0 auto;
}

.item-detail-modal .modal-content {
    border-radius: 18px;
    overflow: hidden;
    border: none;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
    position: relative;
}

/* Hero image (full width بأعلى الـ modal) */
.item-detail-hero {
    width: 100%;
    height: 280px;
    overflow: hidden;
    background: linear-gradient(135deg, #fef3c7 0%, #fef9e7 100%);
    position: relative;
}

.item-detail-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Mobile: hero أصغر شوية */
@media (max-width: 575px) {
    .item-detail-hero { height: 240px; }
}

/* زر الإغلاق الدائري فوق الصورة */
.item-detail-close {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.95);
    border: none;
    color: #1e293b;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    cursor: pointer;
    transition: transform .15s ease;
}

.item-detail-close:hover,
.item-detail-close:active {
    transform: scale(1.1);
}

/* جسم الـ modal */
.item-detail-body {
    padding: 1.25rem 1.25rem 1rem;
    max-height: calc(85vh - 280px - 80px); /* المتبقي بعد الصورة والـ footer */
    overflow-y: auto;
}

@media (max-width: 575px) {
    .item-detail-body {
        max-height: calc(85vh - 240px - 80px);
    }
}

.item-detail-name {
    font-size: 1.35rem;
    color: #1e293b;
    margin-bottom: .4rem;
}

.item-detail-desc {
    line-height: 1.5;
    color: #64748b;
}

/* Footer ثابت بالأسفل */
.item-detail-footer {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1rem;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    position: sticky;
    bottom: 0;
}

.item-detail-footer .item-detail-total {
    min-width: 90px;
    text-align: center;
}

.item-detail-footer .btn {
    min-height: 48px;
    font-size: 1rem;
    border-radius: 12px;
}

/* تحسين شكل الـ options selects داخل الـ modal */
.item-detail-body .form-select,
.item-detail-body .form-control {
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    padding: .55rem .85rem;
    font-size: .95rem;
}

.item-detail-body .form-select:focus,
.item-detail-body .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .15rem rgba(245,158,11,.15);
}

.item-detail-body .input-group .btn {
    border-radius: 10px;
    min-width: 42px;
}

.item-detail-body label {
    font-weight: 600;
    color: #334155;
    font-size: .9rem;
    margin-bottom: .35rem;
}

/* ═════════════════════════════════════════════════
   ITEM DETAIL MODAL — Override Bootstrap (قوي)
   ═════════════════════════════════════════════════ */
.modal.item-detail-modal .modal-dialog {
    max-width: 480px !important;
    margin: 1.75rem auto !important;
}

.modal.item-detail-modal .modal-content {
    border-radius: 18px !important;
    overflow: hidden !important;
    border: none !important;
    box-shadow: 0 10px 40px rgba(0,0,0,.2) !important;
    position: relative !important;
}

.modal.item-detail-modal .item-detail-hero {
    width: 100% !important;
    height: 280px !important;
    overflow: hidden !important;
    flex-shrink: 0 !important;
    background: linear-gradient(135deg, #fef3c7 0%, #fef9e7 100%);
}

.modal.item-detail-modal .item-detail-hero img {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

@media (max-width: 575px) {
    .modal.item-detail-modal .item-detail-hero {
        height: 240px !important;
    }
    .modal.item-detail-modal .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }
}

/* ═════════════════════════════════════════════════
   CART OFFCANVAS — حجم أكبر + responsive
   ═════════════════════════════════════════════════ */
.offcanvas.offcanvas-bottom#cartOffcanvas {
    /* Mobile: تقريباً كامل الشاشة */
    height: 90vh !important;
    max-height: 90vh !important;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    box-shadow: 0 -8px 30px rgba(0,0,0,.15);
}

/* تكبير الـ body عشان يستخدم المساحة الكاملة */
#cartOffcanvas .offcanvas-body {
    max-height: calc(90vh - 60px) !important;
    padding-bottom: 1rem !important;
}

/* Header أكتر بروزاً */
#cartOffcanvas .offcanvas-header {
    padding: 1rem 1.25rem !important;
    border-bottom: 1px solid #f1f5f9;
    background: linear-gradient(135deg, #fef3c7 0%, #fef9e7 100%);
}

#cartOffcanvas .offcanvas-title {
    font-size: 1.1rem;
}

/* ── Tablet (768px+): centered card-like ── */
@media (min-width: 768px) {
    .offcanvas.offcanvas-bottom#cartOffcanvas {
        height: 85vh !important;
        max-height: 85vh !important;
        max-width: 560px !important;
        margin: 0 auto !important;
        border-radius: 18px 18px 0 0 !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }

    #cartOffcanvas.show {
        transform: translateX(-50%) !important;
    }

    /* لما الـ offcanvas مش ظاهر */
    #cartOffcanvas:not(.show) {
        transform: translate(-50%, 100%) !important;
    }
}

/* ── Desktop (1200px+): أكبر وأنيق ── */
@media (min-width: 1200px) {
    .offcanvas.offcanvas-bottom#cartOffcanvas {
        height: 88vh !important;
        max-height: 88vh !important;
        max-width: 640px !important;
    }
}

/* ── الـ Backdrop (الخلفية الداكنة) ── */
.offcanvas-backdrop.show {
    opacity: 0.65 !important;
}

/* تحسين الـ cart items list */
#cart-items-list {
    padding-top: .5rem;
}

#cartOffcanvas .cart-item-row {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    padding: .75rem;
    margin-bottom: .6rem;
    transition: box-shadow .15s ease;
}

#cartOffcanvas .cart-item-row:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.05);
}

/* footer الـ cart ثابت في الأسفل */
#cart-step-footer {
    background: #fff;
    padding-top: .75rem;
    border-top: 1px solid #f1f5f9;
    position: sticky;
    bottom: 0;
}
