/* تحميل خط Expo-Arabic */
@font-face {
    font-family: 'Expo-Arabic';
    src: url('../fonts/Expo-Arabic-Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Expo-Arabic';
    src: url('../fonts/Expo-Arabic-Book.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Expo-Arabic';
    src: url('../fonts/Expo-Arabic-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Expo-Arabic';
    src: url('../fonts/Expo-Arabic-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* متغيرات الألوان والتصميم */
:root {
    --bg-color: #fcf9f2;
    --card-bg: #ffffff;
    --text-color: #2e251e;
    --text-muted: #736050;
    --primary: #e85a19;      /* برتقالي راقٍ ونشط */
    --primary-dark: #c14309; /* درجة أغمق للضغط والهوفر */
    --primary-light: #fdf5f0;/* درجة فاتحة جداً للخلفيات */
    --border-color: #ede5d5;
    --shadow: 0 4px 20px rgba(46, 37, 30, 0.06);
    --font-family: 'Expo-Arabic', sans-serif;
    --badge-bg: #ffebe0;
    --badge-text: #cc5410;
}

[data-theme="dark"] {
    --bg-color: #1a1410;
    --card-bg: #261f1a;
    --text-color: #f7f2ea;
    --text-muted: #bdaea0;
    --primary: #e85a19;      /* برتقالي راقٍ ونشط في الوضع المظلم */
    --primary-dark: #cc5410; /* درجة أغمق للهوفر */
    --primary-light: #38241a;/* درجة فاتحة جداً للخلفيات */
    --border-color: #382d25;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    --badge-bg: #3a2216;
    --badge-text: #f0a382;
}

/* شريط التمرير المخصص للهوية */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* إعادة تهيئة المتصفح */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg-color);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    direction: rtl;
    text-align: right;
    line-height: 1.6;
}

.theme-transitioning,
.theme-transitioning * {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease !important;
}

.app-container {
    width: 100%;
    margin: 0 auto;
    background-color: var(--card-bg);
    min-height: 100vh;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 60px; /* للفوتر */
}

@media (min-width: 768px) {
    .app-container {
        max-width: 980px;
        margin: 40px auto;
        border-radius: 24px;
        min-height: calc(100vh - 80px);
        overflow: visible; /* السماح للوجو بالتداخل للأعلى بدون قص */
    }
}

/* صورة الغلاف */
.cover-wrapper {
    position: relative;
    width: 100%;
    height: 180px;
    background-color: #eae3d5;
    overflow: clip;
}

@media (min-width: 768px) {
    .cover-wrapper, .cover-image, .cover-overlay {
        border-top-left-radius: 24px;
        border-top-right-radius: 24px;
    }
    .cover-wrapper {
        height: 280px;
    }
}

.cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.5));
}

/* هيدر المطعم المدمج الجديد */
.restaurant-header-main {
    display: flex;
    align-items: center;
    padding: 24px;
    gap: 20px;
    position: relative;
}

@media (max-width: 576px) {
    .restaurant-header-main {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 12px;
        padding-top: 16px;
    }
}

/* اللوجو المتداخل البارز */
.logo-wrapper {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background-color: var(--card-bg);
    border: 3px solid var(--primary); /* إطار برتقالي صريح لظهور الشعار بوضوح */
    box-shadow: 0 8px 24px rgba(46, 37, 30, 0.15);
    overflow: visible; /* تم التغيير لتمكين شارة الروابط من البروز */
    margin-top: -65px; /* تداخل أنيق مع الغلاف */
    z-index: 10;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

@media (min-width: 768px) {
    .logo-wrapper {
        width: 120px;
        height: 120px;
        margin-top: -85px;
        border-width: 4px;
    }
}



.logo-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* نصوص المطعم */
.restaurant-text-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

@media (max-width: 576px) {
    .restaurant-text-details {
        margin-top: 0;
    }
}

.restaurant-name {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-color);
}

.restaurant-tagline {
    font-size: 13.5px;
    color: var(--text-muted);
    font-weight: 300;
}

/* أزرار التواصل المضغوطة الدائرية */
.compact-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.compact-action-btn {
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.compact-action-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.compact-action-btn:hover {
    background-color: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
}


/* مفتاح تحديد المود (Light/Dark/Auto) */
.theme-switch-container {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 20;
    background: rgba(26, 20, 16, 0.65);
    border-radius: 20px;
    padding: 4px;
    display: flex;
    gap: 2px;
}

.theme-btn {
    border: none;
    background: transparent;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: all 0.2s;
    opacity: 0.6;
}

.theme-btn svg {
    width: 18px;
    height: 18px;
}

.theme-btn.active {
    background-color: var(--primary);
    color: #ffffff;
    opacity: 1;
}

/* قائمة التصنيفات العامة في index.php */
.menu-categories-list {
    padding: 8px 24px 24px;
}

.category-row {
    display: flex;
    align-items: center;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    margin-bottom: 16px;
    padding: 12px;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.25s ease;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.01);
}

.category-row:hover, .category-row:active {
    border-color: var(--primary);
}

.category-number {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    font-family: monospace, sans-serif;
    margin-left: 16px;
    opacity: 0.8;
    min-width: 28px;
}

.category-img {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    object-fit: cover;
    margin-left: 16px;
    background-color: var(--bg-color);
}

.category-details {
    flex-grow: 1;
}

.category-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 2px;
}

.category-desc {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 300;
}

.category-arrow {
    font-size: 18px;
    color: var(--primary);
    margin-right: 8px;
    transition: transform 0.2s;
}

.category-row:hover .category-arrow {
    color: var(--primary);
}

/* صفحة الأصناف menu.php */
.menu-header {
    display: flex;
    align-items: center;
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 16px;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.back-btn:hover, .back-btn:active {
    background-color: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.back-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.header-text {
    flex-grow: 1;
}

.current-category-name {
    font-size: 20px;
    font-weight: 700;
}

.current-category-desc {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 300;
}

/* قائمة الأصناف */
.menu-items-list {
    padding: 16px 24px;
}

.menu-item-row {
    display: flex;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 16px;
    transition: opacity 0.3s;
}

.menu-item-row:last-child {
    border-bottom: none;
}

.menu-item-img {
    width: 80px;
    height: 80px;
    border-radius: 14px;
    object-fit: cover;
    background-color: var(--bg-color);
}

.menu-item-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.menu-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.menu-item-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-color);
}

.menu-item-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-dark);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.menu-item-price svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.menu-item-description {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 300;
}

.menu-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.menu-item-note {
    font-size: 11px;
    color: var(--text-muted);
    background-color: var(--bg-color);
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px dashed var(--border-color);
}

.badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 10px;
    border-radius: 20px;
    background-color: var(--badge-bg);
    color: var(--badge-text);
}

/* تصميم غير المتوفر */
.menu-item-row.unavailable {
    opacity: 0.65;
}

.menu-item-row.unavailable .menu-item-name {
    text-decoration: line-through;
}

.menu-item-row.unavailable .menu-item-price {
    text-decoration: line-through;
}

.badge.unavailable-badge {
    background-color: #fde8e8;
    color: #e53e3e;
}

/* الفوتر */
.footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background-color: var(--card-bg);
    font-weight: 400;
}

/* زر المشاركة Toast أو تنبيه بسيط */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: rgba(46, 37, 30, 0.95);
    color: #ffffff;
    padding: 10px 24px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    z-index: 100;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* تأثير التناغم مع الوضع المظلم للتوست */
[data-theme="dark"] .toast {
    background-color: rgba(247, 242, 234, 0.95);
    color: #1a1410;
}

/* تأثيرات التحميل (Skeleton Loader) للتجربة الأفضل */
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.pulse {
    animation: pulse 1.5s infinite ease-in-out;
}

/* === تحسينات إضافية لعرض الديسكتوب والتابلت (الشاشات الكبيرة) === */
@media (min-width: 768px) {
    .menu-categories-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
        padding: 24px;
    }
    
    .category-row {
        margin-bottom: 0;
        transition: border-color 0.25s ease;
    }
    
    .category-row:hover {
        border-color: var(--primary);
    }
    
    .menu-items-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
        padding: 24px;
    }
    
    .menu-item-row {
        background-color: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 16px;
        padding: 16px;
        margin-bottom: 0;
        transition: border-color 0.25s ease;
    }
    
    .menu-item-row:hover {
        border-color: var(--primary);
    }
    
    .menu-item-row:last-child {
        border-bottom: 1px solid var(--border-color); /* إعادة إظهار الإطار السفلي لأنها أصبحت داخل شبكة */
    }
    
    .menu-item-row.unavailable {
        opacity: 0.55;
    }
    
    .footer {
        border-bottom-left-radius: 24px;
        border-bottom-right-radius: 24px;
    }
}

/* تصميم حالة القائمة الفارغة */
.menu-empty-state {
    grid-column: 1 / -1; /* الامتداد على كامل شبكة الأعمدة */
    width: 100%;
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
    font-weight: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* === Hardening: Text wrapping & Reduced Motion === */
.category-title, .menu-item-name, .current-category-name {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-delay: -1ms !important;
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        background-attachment: scroll !important;
        scroll-behavior: auto !important;
        transition-delay: 0s !important;
        transition-duration: 0s !important;
    }
}

/* === Lightbox / معاينة الصور في الموقع العام === */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(26, 20, 16, 0.95);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    opacity: 0;
}

.lightbox-overlay.active {
    display: flex;
    animation: lightboxFadeIn 0.25s ease forwards;
    pointer-events: auto;
}

@keyframes lightboxFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-img {
    max-width: 90%;
    max-height: 85vh;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 3px solid var(--primary);
}

.lightbox-overlay.active .lightbox-img {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    transition: background-color 0.2s;
    line-height: 1;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* شريط التواصل الموحد المؤدي لصفحة الروابط الكاملة */
.unified-social-pill {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 8px 18px 8px 12px;
    border-radius: 30px;
    text-decoration: none !important;
    color: var(--text-color) !important;
    font-weight: 700;
    font-size: 12.5px;
    transition: all 0.25s ease;
    margin: 16px auto 0 auto;
    width: fit-content;
}

.unified-social-pill:hover {
    border-color: var(--primary);
    color: var(--primary) !important;
}

.pill-icons {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pill-icon-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--bg-color);
    color: var(--text-muted);
    transition: all 0.25s ease;
}

.unified-social-pill:hover .pill-icon-item {
    background-color: var(--primary-light);
    color: var(--primary);
}

.pill-icon-item svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

.pill-text {
    letter-spacing: 0.3px;
    line-height: 1;
    font-weight: 800;
}

.pill-arrow {
    display: flex;
    align-items: center;
    transition: color 0.25s ease;
    color: var(--text-muted);
}

.unified-social-pill:hover .pill-arrow {
    color: var(--primary);
}

.pill-arrow svg {
    width: 12px;
    height: 12px;
}

/* مؤشر التركيز للوصولية (Keyboard Accessibility Focus Ring) */
.category-row:focus-visible,
.back-btn:focus-visible,
.theme-btn:focus-visible,
.unified-social-pill:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
}
