:root {
    --bg-dark: #090716;
    --card-bg: #130f2c;
    --card-border: #2b225c;
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --accent-gold: #facc15;
    --green-stock: #22c55e;
    --red-stock: #ef4444;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --font-family: 'Tajawal', sans-serif;
}

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

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: var(--font-family);
    min-height: 100vh;
}

/* ========================================================
   الشريط العلوي (مهيأ للهاتف سطرين وللحاسوب سطر واحد)
   ======================================================== */
.navbar {
    background: rgba(19, 15, 44, 0.96);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 10px 12px;
    width: 100%;
}

.nav-container {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.nav-brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.logo-text {
    font-size: 21px;
    font-weight: 900;
    letter-spacing: 0.5px;
}

.logo-text span {
    color: var(--primary);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

.nav-controls-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 5px !important;
}

.segmented-switch {
    background: #0d0a1d;
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 2px;
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center;
    flex-shrink: 0;
}

.switch-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.switch-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.4);
}

.auth-pill-btn {
    background: #1c1642;
    border: 1px solid var(--card-border);
    color: #fff;
    padding: 5px 10px;
    border-radius: 18px;
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.cart-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border: none;
    color: #fff;
    padding: 5px 11px;
    border-radius: 18px;
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-weight: 700;
    font-size: 11.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

#cart-count {
    background: #fff;
    color: var(--primary);
    border-radius: 50%;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: 900;
}

@media (min-width: 768px) {
    .navbar { padding: 10px 20px; }
    .nav-container {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0;
    }
    .nav-brand-row {
        width: auto;
        gap: 15px;
    }
    .nav-controls-row {
        width: auto !important;
        gap: 12px !important;
        justify-content: flex-end !important;
    }
}

/* ========================================================
   الواجهة الترحيبية Hero
   ======================================================== */
.hero-section {
    text-align: center;
    padding: 20px 14px 14px;
    background: radial-gradient(circle at center, rgba(139, 92, 246, 0.18) 0%, transparent 68%);
    width: 100%;
}

.hero-logo-box {
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
}

.hero-logo {
    width: 95px;
    height: 95px;
    border-radius: 20px;
    border: 2px solid var(--primary);
    box-shadow: 0 0 25px rgba(139, 92, 246, 0.45);
    object-fit: cover;
    background: #090716;
}

.hero-content h1 {
    font-size: 21px;
    font-weight: 800;
    margin-bottom: 4px;
    line-height: 1.3;
}

.hero-content p {
    color: var(--text-muted);
    font-size: 13px;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ========================================================
   شريط الثقة والمميزات والدرع المصفّح المطور
   ======================================================== */
.trust-bar {
    max-width: 1240px;
    margin: 8px auto 16px;
    padding: 0 12px;
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    width: 100%;
}

.trust-item {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 52px;
}

.trust-item > i {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", "FontAwesome" !important;
    font-weight: 900 !important;
    font-style: normal !important;
    font-size: 18px !important;
    color: var(--accent-gold) !important;
    min-width: 22px;
    text-align: center;
    flex-shrink: 0;
}

/* تنسيق الدرع المطور الفخم */
.badge-shield-icon {
    font-size: 21px !important;
    color: #fbbf24 !important;
    filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.45));
    transition: transform 0.25s ease;
}

.trust-item:hover .badge-shield-icon {
    transform: scale(1.12);
}

.trust-item strong {
    display: block;
    font-size: 12px;
    margin-bottom: 2px;
    line-height: 1.2;
}

.trust-item span {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.2;
    display: block;
}

@media (min-width: 768px) {
    .trust-bar {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 14px !important;
        margin: 10px auto 30px;
    }
    .trust-item { padding: 12px 14px; min-height: auto; }
    .trust-item > i { font-size: 22px !important; }
    .badge-shield-icon { font-size: 24px !important; }
    .trust-item strong { font-size: 13.5px; }
    .trust-item span { font-size: 11.5px; }
}

/* ========================================================
   منطقة التحكم والبحث وشبكة المنتجات
   ======================================================== */
.main-content {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 12px 50px;
    width: 100%;
}

.controls-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
    width: 100%;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box i {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

[dir="ltr"] .search-box i {
    right: auto;
    left: 14px;
}

.search-box input {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 25px;
    padding: 9px 40px 9px 14px;
    color: #fff;
    outline: none;
    font-size: 13px;
}

[dir="ltr"] .search-box input {
    padding: 9px 14px 9px 40px;
}

.categories-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

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

.cat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 18px;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 600;
    font-size: 12.5px;
    flex-shrink: 0;
}

.cat-card.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.sort-box select {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: #fff;
    padding: 8px 12px;
    border-radius: 12px;
    outline: none;
    font-size: 12.5px;
}

@media (min-width: 768px) {
    .controls-bar {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    .search-box { flex: 1; min-width: 250px; }
    .sort-box select { width: auto; }
}

/* شبكة المنتجات */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    width: 100%;
}

.product-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.product-img-wrapper {
    width: 100%;
    height: 180px;
    background: #0d0a1d;
    overflow: hidden;
}

.product-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-info h3 {
    font-size: 14.5px;
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.4;
}

.stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    margin-bottom: 8px;
}

.stock-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.stock-dot.green { background: var(--green-stock); box-shadow: 0 0 6px var(--green-stock); }
.stock-dot.red { background: var(--red-stock); box-shadow: 0 0 6px var(--red-stock); }
.stock-badge.available { color: var(--green-stock); }
.stock-badge.out-of-stock { color: var(--red-stock); }

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.product-footer .price {
    font-size: 15px;
    font-weight: 800;
    color: var(--accent-gold);
}

/* الأزرار البنفسجية الموحدة */
.add-to-cart-btn,
#modal-action-wrapper button,
.checkout-btn {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35) !important;
}

.add-to-cart-btn {
    padding: 6px 12px !important;
    font-size: 12.5px !important;
}

#modal-action-wrapper button {
    padding: 11px 24px !important;
    font-size: 14px !important;
}

.checkout-btn {
    width: 100% !important;
    padding: 12px !important;
    font-size: 14px !important;
}

.out-of-stock-btn {
    background: #25d366;
    color: #fff;
    text-decoration: none;
    font-size: 11px;
    font-weight: bold;
    padding: 6px 10px;
    border-radius: 8px;
}

/* ========================================================
   القوائم الجانبية والنوافذ المنبثقة
   ======================================================== */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    display: none;
    z-index: 200;
}

.drawer-overlay.open { display: block; }

.cart-drawer, .side-menu-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 88%;
    max-width: 380px;
    background: #110d29;
    border-left: 1px solid var(--card-border);
    z-index: 300;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

[dir="ltr"] .side-menu-drawer { border-left: none; border-right: 1px solid var(--card-border); }

.cart-drawer { left: 0; transform: translateX(-100%); }
[dir="ltr"] .cart-drawer { right: 0; left: auto; transform: translateX(100%); }
.cart-drawer.open { transform: translateX(0); }

.side-menu-drawer { right: 0; transform: translateX(100%); }
[dir="ltr"] .side-menu-drawer { left: 0; right: auto; transform: translateX(-100%); }
.side-menu-drawer.open { transform: translateX(0); }

.drawer-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-header .close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
}

.menu-brand-header { display: flex; align-items: center; gap: 10px; }
.menu-logo { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--primary); }
.menu-brand-header h3 { font-size: 14.5px; margin: 0; }
.sub-brand-name { font-size: 10px; color: var(--primary); font-weight: 800; }

.menu-body {
    padding: 14px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.menu-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px;
}

.header-with-icon { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.accent-icon { color: var(--primary); font-size: 14px; }
.menu-card h4 { font-size: 13px; color: #fff; margin: 0; }
.menu-text { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.policy-list { padding-right: 14px; font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }
[dir="ltr"] .policy-list { padding-right: 0; padding-left: 14px; }

.menu-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.clear-history-btn {
    background: none;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
    font-size: 10.5px;
    padding: 2px 6px;
    border-radius: 5px;
    cursor: pointer;
}

.orders-history-list {
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.empty-orders-note { font-size: 11.5px; color: var(--text-muted); text-align: center; }

.history-order-item {
    background: #0d0a1d;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 8px;
    font-size: 11px;
}

.history-order-top { display: flex; justify-content: space-between; margin-bottom: 4px; }
.history-order-id { color: var(--primary); font-weight: bold; }

.history-code-box {
    background: #14102c;
    border: 1px dashed var(--card-border);
    padding: 5px;
    border-radius: 6px;
    font-family: monospace;
    color: var(--accent-gold);
    display: flex;
    justify-content: space-between;
    align-items: center;
    word-break: break-all;
}

.history-copy-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 9.5px;
    cursor: pointer;
}

.social-buttons-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 8px;
}

.social-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px;
    border-radius: 8px;
    text-decoration: none;
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
}

.social-btn i { font-size: 17px; }
.instagram-btn { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.telegram-btn { background: #229ed9; }
.whatsapp-btn { background: #25d366; }

/* نوافذ إتمام الطلب والتفاصيل */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 12px;
}

.modal-overlay.open { display: flex; }

.modal-card {
    position: relative;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: 10px;
    left: 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
}

[dir="ltr"] .modal-close { left: auto; right: 10px; }

.checkout-card {
    max-width: 420px;
    background: #14102c !important;
    border: 1px solid #302663 !important;
    border-radius: 16px !important;
    padding: 18px !important;
}

.checkout-header { text-align: center; margin-bottom: 14px; }

.checkout-badge-icon {
    width: 42px;
    height: 42px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 6px;
    font-size: 17px;
}

.checkout-header h3 { font-size: 16.5px; margin-bottom: 2px; }
.checkout-subtitle { font-size: 11.5px; color: var(--text-muted); }

.guest-notice {
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.35);
    color: #e9d5ff;
    border-radius: 10px;
    padding: 8px 10px;
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 11.5px;
    line-height: 1.4;
}

.guest-notice i { font-size: 15px; color: var(--primary); margin-top: 2px; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.required-star { color: var(--red-stock); }

.input-with-icon { position: relative; }
.input-with-icon i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

[dir="ltr"] .input-with-icon i { right: auto; left: 12px; }

.input-with-icon input, .form-group input {
    width: 100%;
    background: #0d0a1d;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: #fff;
    padding: 10px 36px 10px 12px;
    outline: none;
    font-size: 13px;
}

[dir="ltr"] .input-with-icon input, [dir="ltr"] .form-group input {
    padding: 10px 12px 10px 36px;
}

.payment-method-badge {
    background: #0d0a1d;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
}

.payment-method-badge i { font-size: 19px; color: #ff5f00; }

.order-summary-box {
    background: #0d0a1d;
    border: 1px dashed var(--card-border);
    border-radius: 10px;
    padding: 9px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 12px 0;
    font-size: 12.5px;
}

.total-amount { color: var(--green-stock); font-weight: bold; font-size: 15px; }

.inline-error-box {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    padding: 8px;
    border-radius: 8px;
    font-size: 11.5px;
    margin-bottom: 10px;
    text-align: center;
}

.toast-box {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e1844;
    color: #fff;
    border: 1px solid var(--primary);
    padding: 9px 18px;
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.6);
    font-size: 12.5px;
    font-weight: bold;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

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

.cart-body { padding: 14px; overflow-y: auto; flex: 1; }
.cart-footer { padding: 14px; border-top: 1px solid var(--card-border); }
.cart-total { display: flex; justify-content: space-between; font-size: 14.5px; font-weight: bold; margin-bottom: 10px; }

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0d0a1d;
    padding: 9px;
    border-radius: 10px;
    margin-bottom: 8px;
}

.cart-item-controls button {
    background: #281f57;
    border: none;
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
}

.details-card {
    max-width: 600px;
    background: #14102c;
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 18px;
}

.details-content { display: flex; flex-direction: column; gap: 14px; }
.details-img-col { width: 100%; }
.details-img-col img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; }
.details-info-col { width: 100%; }
.cat-pill { background: rgba(139, 92, 246, 0.15); color: var(--primary); padding: 4px 8px; border-radius: 10px; font-size: 11px; }
.details-price { font-size: 17px; font-weight: 800; color: var(--accent-gold); margin: 6px 0; }
.details-desc-wrapper { margin: 10px 0; font-size: 12.5px; color: #cbd5e1; line-height: 1.5; }

.auth-card {
    max-width: 380px;
    background: #14102c;
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 18px;
    text-align: center;
}

.auth-tabs { display: flex; border-bottom: 1px solid var(--card-border); margin-bottom: 14px; }
.tab-btn { flex: 1; background: none; border: none; color: var(--text-muted); padding: 7px; cursor: pointer; font-weight: bold; font-size: 12.5px; }
.tab-btn.active { color: var(--primary); border-bottom: 2px solid var(--primary); }
.google-auth-box { margin: 10px 0; display: flex; justify-content: center; }
.auth-divider { position: relative; margin: 14px 0; border-top: 1px solid var(--card-border); }
.auth-divider span { position: absolute; top: -9px; right: 50%; transform: translateX(50%); background: #14102c; padding: 0 8px; font-size: 11px; color: var(--text-muted); }
.auth-error { background: rgba(239, 68, 68, 0.15); color: var(--red-stock); padding: 6px; border-radius: 6px; font-size: 11.5px; margin-bottom: 10px; }

.side-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #0d0a1d;
    padding: 9px;
    border-radius: 8px;
    margin-bottom: 6px;
}

.avatar-icon { font-size: 26px; color: var(--primary); }
.profile-meta { flex: 1; display: flex; flex-direction: column; text-align: right; }
[dir="ltr"] .profile-meta { text-align: left; }
.logout-btn { background: none; border: none; color: var(--red-stock); font-size: 15px; cursor: pointer; }
