/* =========================================================
   Frontend Foundation — Design System
   FoodOrderingPlatform — Public Website
   RTL First • Tailwind CDN Friendly • Mobile Responsive
   ========================================================= */

/* ---------- Base: Prevent Horizontal Overflow on Mobile ---------- */
html, body {
    overflow-x: hidden;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background-color: #f8fafc;
    color: #0f172a;
    font-family: 'Vazirmatn', 'IRANSans', 'Tahoma', sans-serif;
}

/* ---------- Global Container (طبق Spec: Max Width + Responsive Padding) ---------- */
.public-container {
    width: 100%;
    max-width: 1536px; /* tailwind screen-2xl = 1536px */
    margin-inline: auto;
    padding-inline: 1rem; /* 16px — mobile base */
}

@media (min-width: 768px) {
    .public-container { padding-inline: 1.5rem; } /* 24px — tablet */
}
@media (min-width: 1280px) {
    .public-container { padding-inline: 2rem; }   /* 32px — desktop */
}

/* ---------- Section Padding (طبق Spec: Section Spacing) ---------- */
.public-section {
    padding-block: 2.5rem; /* 40px mobile */
}
@media (min-width: 768px) {
    .public-section { padding-block: 3.5rem; } /* 56px tablet */
}
@media (min-width: 1280px) {
    .public-section { padding-block: 5rem; }   /* 80px desktop */
}

/* ---------- Typography (طبق Spec H1/H2/H3/Body/Small/Caption) ---------- */
.fe-h1 {
    font-size: clamp(1.875rem, 5vw, 3rem);   /* 30px mobile → 48px desktop */
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: #0f172a;
    margin: 0;
}
.fe-h2 {
    font-size: clamp(1.5rem, 3.5vw, 2.25rem); /* 24px → 36px */
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: #0f172a;
    margin: 0;
}
.fe-h3 {
    font-size: clamp(1.25rem, 2.5vw, 1.5rem); /* 20px → 24px */
    font-weight: 700;
    line-height: 1.4;
    color: #1e293b;
    margin: 0;
}
.fe-body {
    font-size: 1rem;
    line-height: 1.75;
    color: #475569;
}
.fe-body--strong {
    font-weight: 600;
    color: #334155;
}
.fe-small {
    font-size: 0.875rem; /* 14px */
    line-height: 1.6;
    color: #64748b;
}
.fe-caption {
    font-size: 0.75rem; /* 12px */
    line-height: 1.5;
    color: #94a3b8;
    letter-spacing: 0.02em;
}

/* Gradient text for titles */
.fe-text-gradient {
    background: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 50%, #14b8a6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ---------- Buttons (طبق Spec: Primary / Secondary / Outline / Danger) ---------- */
.fe-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    border-radius: 0.875rem;
    border: 1.5px solid transparent;
    cursor: pointer;
    user-select: none;
    transition: all 200ms ease;
    text-decoration: none !important;
    white-space: nowrap;
}
.fe-btn--sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: 0.625rem;
}
.fe-btn--lg {
    padding: 0.95rem 1.9rem;
    font-size: 1rem;
    border-radius: 1rem;
}

/* Primary: سرمه‌ای Main */
.fe-btn--primary {
    background: linear-gradient(135deg, #6366f1 0%, #3b82f6 100%);
    color: #fff;
    box-shadow: 0 6px 20px -6px rgba(99, 102, 241, 0.55);
}
.fe-btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px -8px rgba(99, 102, 241, 0.7);
    color: #fff;
}

/* Secondary: فیروزه‌ای */
.fe-btn--secondary {
    background: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
    color: #fff;
    box-shadow: 0 6px 20px -6px rgba(20, 184, 166, 0.55);
}
.fe-btn--secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px -8px rgba(20, 184, 166, 0.7);
    color: #fff;
}

/* Outline: شیشه‌ای حاشیه سرمه‌ای */
.fe-btn--outline {
    background: #ffffff;
    color: #4f46e5;
    border-color: #c7d2fe;
}
.fe-btn--outline:hover {
    background: #eef2ff;
    border-color: #a5b4fc;
    transform: translateY(-2px);
}

/* Danger: قرمز */
.fe-btn--danger {
    background: linear-gradient(135deg, #ef4444 0%, #e11d48 100%);
    color: #fff;
    box-shadow: 0 6px 20px -6px rgba(239, 68, 68, 0.55);
}
.fe-btn--danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px -8px rgba(239, 68, 68, 0.7);
    color: #fff;
}

.fe-btn[disabled], .fe-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ---------- Cards (طبق Spec: Card پایه قابل توسعه برای Category/Product/Order) ---------- */
.fe-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1.25rem;
    box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.06);
    transition: transform 250ms ease, box-shadow 250ms ease, border-color 250ms ease;
    overflow: hidden;
    position: relative;
}
.fe-card:hover {
    transform: translateY(-4px);
    border-color: #c7d2fe;
    box-shadow: 0 20px 40px -15px rgba(79, 70, 229, 0.25);
}

.fe-card__media {
    width: 100%;
    background: linear-gradient(135deg, #eef2ff 0%, #ecfeff 50%, #f0fdfa 100%);
    overflow: hidden;
    position: relative;
}
.fe-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 400ms ease;
    display: block;
}
.fe-card:hover .fe-card__media img {
    transform: scale(1.05);
}

.fe-card__body {
    padding: 1rem 1.1rem 1.25rem;
}

/* ---------- Badge (تخفیف / جدید / محبوب) ---------- */
.fe-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 999px;
    line-height: 1;
    letter-spacing: 0.01em;
}
.fe-badge--discount {
    background: linear-gradient(135deg, #fee2e2 0%, #fecdd3 100%);
    color: #b91c1c;
    box-shadow: inset 0 0 0 1px rgba(225,29,72,0.15);
}
.fe-badge--new {
    background: linear-gradient(135deg, #dbeafe 0%, #c7d2fe 100%);
    color: #1e40af;
}
.fe-badge--hot {
    background: linear-gradient(135deg, #fed7aa 0%, #fde68a 100%);
    color: #b45309;
}

/* ---------- Price Display (Product Card) ---------- */
.fe-price {
    font-size: 1.1rem;
    font-weight: 800;
    color: #0f172a;
    direction: ltr;
    unicode-bidi: plaintext;
}
.fe-price--old {
    font-size: 0.9rem;
    font-weight: 600;
    color: #94a3b8;
    text-decoration: line-through;
    direction: ltr;
    unicode-bidi: plaintext;
}
.fe-price--discount {
    color: #dc2626;
}
.fe-price__toman {
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    margin-inline-start: 0.25rem;
}

/* ---------- Header (JS-driven Fixed — چون overflow-x:hidden CSS sticky را می‌شکند) ---------- */
.public-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid transparent;
    transition: all 250ms ease;
    width: 100%;
}
.public-header--scrolled {
    background: rgba(255, 255, 255, 0.95);
    border-bottom-color: #e2e8f0;
    box-shadow: 0 8px 24px -12px rgba(15, 23, 42, 0.1);
}
.public-header--fixed { /* marker for JS state */ }

/* Mobile Drawer Navigation — فقط در موبایل (sm و پایین‌تر) نمایش داده می‌شود */
.public-drawer {
    position: fixed;
    inset: 0 0 0 auto; /* RTL: به سمت راست viewport می‌چسبد (برای LTR باید 0 auto 0 0 باشد) */
    top: 0;
    bottom: 0;
    width: min(86vw, 320px);
    max-width: 100vw;
    background: #ffffff;
    border-inline-start: 1px solid #e2e8f0;
    z-index: 60;
    padding: 1.25rem;
    box-shadow: -10px 0 30px -8px rgba(15, 23, 42, 0.18);
    transform: translateX(100%); /* شروع خارج از صفحه از سمت راست (چون به راست چسبیده +X = بیرون رفتن به راست) */
    will-change: transform;
    transition: transform 300ms cubic-bezier(0.33, 1, 0.68, 1);
}
.public-drawer--open {
    transform: translateX(0);
}
.public-drawer__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 55;
    opacity: 0;
    visibility: hidden;
    transition: opacity 250ms ease, visibility 250ms ease;
}
.public-drawer__backdrop--open {
    opacity: 1;
    visibility: visible;
}

/* ---------- Responsive: Drawer و Backdrop فقط در Mobile فعال هستند ---------- */
/* در Tablet (md) و دسکتاپ (lg/xl) منوی Desktop فعال است و Drawer کاملاً حذف می‌شود */
@media (min-width: 768px) {
    .public-drawer,
    .public-drawer--open,
    .public-drawer__backdrop,
    .public-drawer__backdrop--open {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
}

/* ---------- Hero Background Pattern (نقاط درشت شیشه‌ای) ---------- */
.fe-hero-pattern {
    background-image:
        radial-gradient(circle at 20% 20%, rgba(99,102,241,0.10) 0, transparent 40%),
        radial-gradient(circle at 85% 10%, rgba(20,184,166,0.12) 0, transparent 45%),
        radial-gradient(circle at 60% 90%, rgba(59,130,246,0.10) 0, transparent 50%);
}

/* ---------- Category Card Image Placeholder (Gradient Background Placeholder) ---------- */
.fe-cat-ph {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fe-cat-ph--1 { background: linear-gradient(135deg,#fef3c7 0%, #fde68a 100%); } /* کبابی ایرانی */
.fe-cat-ph--2 { background: linear-gradient(135deg,#fee2e2 0%, #fecdd3 100%); } /* فست فود */
.fe-cat-ph--3 { background: linear-gradient(135deg,#dcfce7 0%, #bbf7d0 100%); } /* سالاد */
.fe-cat-ph--4 { background: linear-gradient(135deg,#dbeafe 0%, #bfdbfe 100%); } /* نوشیدنی */
.fe-cat-ph--5 { background: linear-gradient(135deg,#fce7f3 0%, #fbcfe8 100%); } /* دسر */
.fe-cat-ph--6 { background: linear-gradient(135deg,#ede9fe 0%, #ddd6fe 100%); } /* پیش غذا */

/* ---------- Utility: Aspect Ratios (Product / Category Card) ---------- */
.fe-aspect-1 { aspect-ratio: 1 / 1; }
.fe-aspect-4-3 { aspect-ratio: 4 / 3; }
.fe-aspect-16-9 { aspect-ratio: 16 / 9; }

/* ---------- Utility: Hide Scrollbar on Horizontal Mobile Navs ---------- */
.fe-scrollbar-hide::-webkit-scrollbar { display: none; }
.fe-scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* ---------- TempData Toast Notifications ---------- */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
}

.public-toast--closing {
    animation: slideOut 0.25s ease-in forwards !important;
}

/* ======================================================
   Sprint 2 — Landing / Food Modal / Shopping Cart Panel
   ====================================================== */

/* -------- Smooth Scroll Offsets for sticky header + sticky category nav (تقریباً 80+64 = 144px) -------- */
:root {
    --fe-sticky-header-offset: 152px;
}
@media (max-width: 767.98px) {
    :root { --fe-sticky-header-offset: 136px; }
}
html { scroll-padding-top: var(--fe-sticky-header-offset); }

/* -------- General Keyframes for Modal/Drawer/Backdrop -------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes slideInRightDrawer {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}
@keyframes slideInModal {
    from { opacity: 0; transform: translateY(24px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* -------- Body scroll lock (for open modal / drawer) -------- */
body.fe-scroll-lock { overflow: hidden !important; }
body.fe-scroll-lock .public-header,
body.fe-scroll-lock #public-main { padding-inline-end: 0; }

/* -------- Landing Horizontal Pill Nav Scrollbars hidden -------- */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* -------- Landing Category Pill (Active state injected via ScrollSpy) -------- */
.fe-landing-cat-pill.is-active {
    background: #FDC430;
    border-color: #FDC430;
    color: #0f172a;
    box-shadow: 0 8px 22px -8px rgba(253, 196, 48, 0.65);
}
.fe-landing-cat-pill.is-active > span:first-child {
    color: #0f172a;
}
.fe-landing-cat-pill.is-active > span:last-child,
.fe-landing-cat-pill.is-active > span:nth-child(3) {
    background: rgba(15, 23, 42, 0.06) !important;
    color: #0f172a !important;
}

/* -------- Food Card Placeholder gradient variants inside card/modal/panel when img fails -------- */
div.show-gradient.fe-cat-ph--1, div[data-placeholder-variant="1"].show-gradient { background: linear-gradient(135deg,#fef3c7 0%, #fde68a 100%); }
div.show-gradient.fe-cat-ph--2, div[data-placeholder-variant="2"].show-gradient { background: linear-gradient(135deg,#fee2e2 0%, #fecdd3 100%); }
div.show-gradient.fe-cat-ph--3, div[data-placeholder-variant="3"].show-gradient { background: linear-gradient(135deg,#dcfce7 0%, #bbf7d0 100%); }
div.show-gradient.fe-cat-ph--4, div[data-placeholder-variant="4"].show-gradient { background: linear-gradient(135deg,#dbeafe 0%, #bfdbfe 100%); }
div.show-gradient.fe-cat-ph--5, div[data-placeholder-variant="5"].show-gradient { background: linear-gradient(135deg,#fce7f3 0%, #fbcfe8 100%); }
div.show-gradient.fe-cat-ph--6, div[data-placeholder-variant="6"].show-gradient { background: linear-gradient(135deg,#ede9fe 0%, #ddd6fe 100%); }

/* On data-placeholder-variant if image missing → default gradient overlay (before JS injects show-gradient) */
div[data-food-modal-image].show-gradient::before,
div[data-cart-line-thumbnail].show-gradient::before,
div[data-placeholder-variant].show-gradient::before { display:none; }

/* Food Modal image area (when show-gradient applied via .fe-cat-ph--N on the wrapper) */
#public-food-modal .show-gradient[data-food-modal-image] {
    background-position: center;
    background-size: cover;
}
#public-food-modal .show-gradient[data-food-modal-image] > div[data-food-modal-image-ph] { opacity: 1 !important; }

/* Shopping cart line thumb show gradient placeholder background */
.show-gradient[data-cart-line-thumbnail] {
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
}

/* -------- Food Modal Badges -------- */
.fe-badge--prep {
    background: rgba(14,165,233,0.12);
    color: #0369a1;
}
.fe-badge--options {
    background: rgba(99,102,241,0.1);
    color: #3730a3;
}

/* -------- Price Payable highlighted -------- */
.fe-price--payable {
    color: #1e1b4b;
    text-shadow: 0 1px 0 rgba(255,255,255,0.8);
}
.fe-price--discount { color: #047857; }
.fe-price--shipping { color: #0f172a; }
.fe-price-badge {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 2px 8px;
    font-size: 10px; font-weight: 800; border-radius: 9999px;
}
.fe-price-badge--disc {
    background: linear-gradient(135deg,#fff1f2 0%, #ffe4e6 100%);
    color: #be123c;
    margin-inline-start: 4px;
}

/* -------- Food Modal: options list card style -------- */
.fe-option-card {
    border: 1.5px solid #e2e8f0;
    background: #ffffff;
    border-radius: 1rem;
    padding: 0.75rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    transition: all .2s ease;
    user-select: none;
}
.fe-option-card:hover {
    border-color: #c7d2fe;
    background: #f5f3ff;
}
.fe-option-card.is-selected {
    border-color: #6366f1;
    background: linear-gradient(135deg, #eef2ff 0%, #ecfeff 50%, #f0fdfa 100%);
    box-shadow: 0 10px 24px -16px rgba(79,70,229,0.45);
}
.fe-option-card__name {
    font-weight: 800;
    color: #0f172a;
    font-size: 13px;
    line-height: 1.5;
}
.fe-option-card__delta {
    font-size: 11px;
    font-weight: 700;
    direction: ltr;
    unicode-bidi: plaintext;
    color: #047857;
    flex-shrink: 0;
    margin-inline-start: auto;
}
.fe-option-card__delta.is-zero { color: #64748b; opacity: .85; }
.fe-option-card__check {
    width: 20px; height: 20px;
    border-radius: 999px;
    border: 1.5px solid #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #ffffff;
    transition: all .15s ease;
}
.fe-option-card.is-selected .fe-option-card__check {
    background: #4f46e5;
    border-color: #4f46e5;
    box-shadow: 0 4px 10px -2px rgba(79,70,229,0.45);
}
.fe-option-card.is-selected .fe-option-card__check svg { display: inline-block !important; }
.fe-option-card__check svg { display: none; }

/* -------- Avatar Dropdown overlay outside clicks handled in JS -------- */
[data-user-menu].is-open { display: block !important; }

/* -------- Cart Line Item Option Badge Chip -------- */
.fe-cart-opt-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 9999px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.2;
    margin: 2px 2px;
}
.fe-cart-opt-badge__delta {
    direction: ltr;
    unicode-bidi: plaintext;
    color: #047857;
    font-weight: 800;
    margin-inline-start: 2px;
}

/* -------- Under MinOrderAmount Highlight Row -------- */
.fe-totals-row--warn {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%) !important;
    border-color: #fdba74 !important;
}

/* -------- Public buttons override to match inline Tailwind consistency -------- */
.fe-btn--ghost {
    background: transparent;
    color: #0f172a;
    border-color: #e2e8f0;
}

/* -------- Line clamp utility fallback (Tailwind line-clamp may not be in CDN by default) -------- */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.line-clamp-5 {
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* =========================================================
   Card Qty Stepper (Three-State: IDLE / QTY-1 / QTY-N)
   Palette: Yellow Primary #FDC430 (user request)
   ========================================================= */
.fe-qty-stepper {
    --step-color: #FDC430;
    --step-color-hover: #e9b020;
    --step-text: #0f172a;
    --step-border: #fcd34d;
    min-width: 136px;
    justify-content: flex-end;
}
/* State idle: فقط دکمه + تنها */
.fe-qty-stepper[data-stepper-state="idle"] { min-width: 44px; }
/* State active: Stepper سه‌تایی کشیده */
.fe-qty-stepper[data-stepper-state="active"] { min-width: 136px; }

/* دکمه + دور سفید در حالت IDLE و ACTIVE */
.fe-qty-btn {
    -webkit-user-select: none;
       -moz-user-select: none;
            user-select: none;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}
.fe-qty-btn--plus {
    color: var(--step-text);
    background-color: var(--step-color);
    border-color: var(--step-color);
    box-shadow: 0 5px 14px -6px rgba(253, 196, 48, 0.65);
    transition: transform .15s ease, background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.fe-qty-btn--plus:hover {
    background-color: var(--step-color-hover);
    border-color: var(--step-color-hover);
    box-shadow: 0 10px 22px -10px rgba(253, 196, 48, 0.85);
    transform: translateY(-0.5px);
}
.fe-qty-btn--only-plus {
    height: 40px !important;
    width: 40px !important;
    min-width: 40px !important;
}
.fe-qty-btn--only-plus svg { width: 20px; height: 20px; }

/* Container سه‌تایی Active */
.fe-qty-stepper--active {
    min-width: 136px;
    max-width: 160px;
    display: none; /* به صورت پیش‌فرض؛ JS در صورت نیاز display:flex می‌گذارد */
}
.fe-qty-stepper--active.flex { display: flex !important; }

/* عدد وسط Stepper */
.fe-qty-stepper--value {
    direction: ltr;
    unicode-bidi: plaintext;
    text-align: center;
    padding-inline: 0.5rem;
    min-width: 28px;
    font-size: 15px;
    letter-spacing: 0.01em;
    color: #0f172a;
    font-weight: 900;
    line-height: 1;
}

/* حالت هاور کلی کارت روی Stepper تاثیر ندارد (جلوگیری از تداخل group-hover قبلی) */
.fe-qty-stepper * { pointer-events: auto; }

/* Mobile Responsive: کوچک‌تر شدن اندکی Stepper زیر 480px */
@media (max-width: 479px) {
    .fe-qty-stepper--active { min-width: 124px; }
    .fe-qty-stepper[data-stepper-state="active"] { min-width: 124px; }
    .fe-qty-btn--only-plus { width: 38px !important; height: 38px !important; min-width: 38px !important; }
}
