/* ═══════════════════════════════════════════════════════════════════
   ملك الطابون - Smart Menu - تصميم فاتح أنيق مع أنيميشن احترافية
   ═══════════════════════════════════════════════════════════════════ */

:root {
    /* الألوان الأساسية - تدرجات دافئة هادئة */
    --primary: #d97706;
    --primary-dark: #b45309;
    --primary-light: #f59e0b;
    --primary-soft: #fef3c7;
    --primary-glow: rgba(217, 119, 6, 0.15);

    /* خلفيات فاتحة أنيقة */
    --bg-main: #fafaf9;
    --bg-card: #ffffff;
    --bg-soft: #f5f5f4;

    /* نصوص - محسّنة للتباين (WCAG AA) */
    --text-primary: #1c1917;
    --text-secondary: #57534e;
    --text-muted: #78716c;

    /* ألوان إضافية */
    --success: #10b981;
    --success-soft: #d1fae5;
    --danger: #ef4444;
    --white: #ffffff;
    --modal-bg: #ffffff;

    /* ظلال ناعمة */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 4px 20px rgba(217, 119, 6, 0.15);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);

    /* حواف */
    --radius: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;

    /* تدرجات */
    --gradient: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    --gradient-soft: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);

    /* Easing و Transitions */
    --easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --easing-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --easing-out: cubic-bezier(0, 0, 0.2, 1);
    --transition-fast: 0.15s;
    --transition-normal: 0.3s;
    --transition-slow: 0.5s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 100px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    opacity: 1;
    transition: opacity 0.15s;
}

body:not(.settings-loaded) {
    opacity: 0.99;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ═══════════════════════════════════════════════════════════════════
   HEADER - الشريط العلوي
   ═══════════════════════════════════════════════════════════════════ */

.main-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 20px var(--primary-glow, rgba(217, 119, 6, 0.2));
}

.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--white);
}

.logo i {
    font-size: 1.8rem;
    animation: flame 2s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

@keyframes flame {

    0%,
    100% {
        transform: scale(1) rotate(0deg);
    }

    25% {
        transform: scale(1.05) rotate(-3deg);
    }

    50% {
        transform: scale(1.1) rotate(0deg);
    }

    75% {
        transform: scale(1.05) rotate(3deg);
    }
}

.logo h1 {
    font-size: 1.4rem;
    font-weight: 800;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    letter-spacing: -0.5px;
}

.cart-icon {
    position: relative;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--white);
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 14px;
    border-radius: 50%;
    transition: all var(--transition-normal) var(--easing-smooth);
    border: 2px solid rgba(255, 255, 255, 0.25);
    will-change: transform;
}

.cart-icon:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.08);
    border-color: rgba(255, 255, 255, 0.4);
}

.cart-icon:active {
    transform: scale(0.95);
}

.cart-icon.bounce {
    animation: cartBounce 0.5s var(--easing-bounce);
}

@keyframes cartBounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.25);
    }
}

.cart-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--success);
    color: white;
    font-size: 0.7rem;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 2px solid var(--white);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
    transition: transform var(--transition-fast) var(--easing-bounce);
}

.cart-count.pulse {
    animation: countPulse 0.3s var(--easing-bounce);
}

@keyframes countPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.4);
    }

    100% {
        transform: scale(1);
    }
}

/* ═══════════════════════════════════════════════════════════════════
   WELCOME MESSAGE - رسالة الترحيب
   ═══════════════════════════════════════════════════════════════════ */

.welcome-message {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    padding: 14px 0;
    text-align: center;
    transition: all var(--transition-normal) var(--easing-smooth);
}

.welcome-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.welcome-icon {
    font-size: 1.4rem;
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

.welcome-message h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.welcome-message p {
    font-size: 0.85rem;
    opacity: 0.9;
    margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   CATEGORIES - قائمة الفئات
   ═══════════════════════════════════════════════════════════════════ */

.categories-nav {
    background: var(--bg-card);
    padding: 14px 0;
    position: sticky;
    top: 68px;
    z-index: 90;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
    scroll-padding: 16px;
}

.categories-nav::-webkit-scrollbar {
    display: none;
}

.categories-nav .container {
    display: flex;
    gap: 10px;
    padding-bottom: 4px;
}

.category-item {
    padding: 10px 20px;
    background: var(--bg-soft);
    border-radius: 25px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-normal) var(--easing-smooth);
    font-weight: 600;
    border: 2px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
    color: var(--text-secondary);
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
    will-change: transform;
}

.category-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--x, 50%) var(--y, 50%),
            rgba(217, 119, 6, 0.2) 0%,
            transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
}

.category-item:active::after {
    opacity: 1;
}

.category-item:hover {
    border-color: var(--primary-light);
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.category-item.active {
    background: var(--gradient);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-glow);
    transform: scale(1.02);
}

.category-item.active::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ═══════════════════════════════════════════════════════════════════
   PRODUCTS SECTION - قسم المنتجات
   ═══════════════════════════════════════════════════════════════════ */

.products-section {
    padding: 24px 0;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 20px;
    position: relative;
    padding-right: 16px;
}

.section-title::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: var(--gradient);
    border-radius: 2px;
}


/* ═══════════════════════════════════════════════════════════════════
   SKELETON LOADING - تحميل الهيكل
   ═══════════════════════════════════════════════════════════════════ */

.skeleton {
    position: relative;
    overflow: hidden;
    background: linear-gradient(90deg,
            var(--bg-soft) 0%,
            #e7e5e4 20%,
            var(--bg-soft) 40%,
            var(--bg-soft) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.product-card.skeleton {
    opacity: 1;
    transform: none;
}

.product-card.skeleton .product-img-wrapper {
    background: var(--bg-soft);
}

.skeleton-title {
    height: 16px;
    width: 70%;
    border-radius: 6px;
    margin-bottom: 6px;
}

.skeleton-desc {
    height: 14px;
    width: 90%;
    border-radius: 6px;
    margin-bottom: 8px;
}

.skeleton-price {
    height: 18px;
    width: 50px;
    border-radius: 6px;
}

.skeleton-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* حالات التحميل والخطأ */
.loading,
.error,
.no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 1rem;
}

.loading::before {
    content: '';
    display: block;
    width: 36px;
    height: 36px;
    border: 3px solid var(--bg-soft);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ═══════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS - الإشعارات المنبثقة
   ═══════════════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    pointer-events: none;
    width: 90%;
    max-width: 320px;
}

.toast {
    background: var(--text-primary);
    color: white;
    padding: 12px 18px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    animation: toastIn 0.3s var(--easing-smooth);
    pointer-events: auto;
    font-size: 0.9rem;
    font-weight: 600;
}

.toast.success {
    background: linear-gradient(135deg, #1c1917 0%, #292524 100%);
    border-right: 3px solid var(--success);
}

.toast.error {
    background: linear-gradient(135deg, #1c1917 0%, #292524 100%);
    border-right: 3px solid var(--danger);
}

.toast i {
    font-size: 1rem;
    flex-shrink: 0;
}

.toast.success i {
    color: var(--success);
}

.toast.error i {
    color: var(--danger);
}

.toast.hiding {
    animation: toastOut 0.3s var(--easing-smooth) forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
}


/* ═══════════════════════════════════════════════════════════════════════════
   PWA INSTALL BUTTON (HEADER) - زر تحميل التطبيق في الشريط العلوي
   ═══════════════════════════════════════════════════════════════════════════ */

.header-install-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.25);
    color: var(--white);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--transition-normal) var(--easing-smooth);
    animation: headerInstallFadeIn 0.4s var(--easing-smooth),
        headerInstallPulse 2s ease 1s 2;
    will-change: transform;
}

@keyframes headerInstallFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes headerInstallPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(255, 255, 255, 0);
    }
}

.header-install-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.08);
    border-color: rgba(255, 255, 255, 0.4);
}

.header-install-btn:active {
    transform: scale(0.95);
}

