/* =============================================
   مستر اير - Layout CSS (Header, Nav, Footer)
   ============================================= */

/* ---- TOPBAR (Premium) ---- */
.topbar { background: var(--gradient-primary-dark); color: rgba(255,255,255,0.85); font-size: var(--font-size-sm); padding: 0.5rem 0; }
.topbar-message { display: flex; align-items: center; gap: 0.5rem; }
.topbar-message i { color: var(--accent); }
.topbar-contact { display: flex; align-items: center; gap: 1.25rem; }
.topbar-link { color: rgba(255,255,255,0.85); display: flex; align-items: center; gap: 0.35rem; }
.topbar-link:hover { color: #fff; }
.topbar-social { display: flex; gap: 0.75rem; }
.topbar-social a { color: rgba(255,255,255,0.7); }
.topbar-social a:hover { color: #fff; }

/* ---- MAIN HEADER (Premium) ---- */
.main-header { background: var(--bg-white); padding: 0.75rem 0; border-bottom: 1px solid rgba(0,0,0,0.06); position: relative; z-index: var(--z-sticky); }
.main-header:focus-within { z-index: 9000; }
.header-logo { display: flex; align-items: center; flex-shrink: 0; }
.logo-text { display: flex; align-items: center; gap: 0.5rem; }
.logo-icon { font-size: 1.75rem; color: var(--primary); }
.logo-name { display: block; font-size: 1.4rem; font-weight: 800; color: var(--primary-dark); line-height: 1.2; }
.logo-tagline { display: block; font-size: 0.7rem; color: var(--text-muted); }

/* Search */
.header-search { flex: 1; max-width: 580px; margin: 0 2rem; position: relative; z-index: 9999; }
.search-form { display: flex; border: 2px solid #e0e5ec; border-radius: 50px; transition: border-color 0.2s ease; background: #fff; position: relative; }
.search-form:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,119,200,0.08); }
.search-category { position: relative; }
.search-category select { border: none; border-left: 1px solid #e5e8ed; border-radius: 0; padding: 0.65rem 0.75rem; background: #f7f8fa; min-width: 130px; font-family: inherit; font-size: 0.88rem; color: #555; cursor: pointer; outline: none; -webkit-appearance: none; appearance: none; }
.search-category select:focus { background: #eef3f8; }

/* Custom Category Dropdown — Premium */
.sc-trigger {
    display: flex; align-items: center; gap: 0.5rem;
    border: none; border-left: 1px solid #e5e8ed; border-radius: 0;
    padding: 0.65rem 0.85rem; background: #f7f8fa;
    min-width: 135px; font-family: inherit; font-size: 0.88rem;
    color: #444; cursor: pointer; outline: none;
    transition: all 0.2s; white-space: nowrap;
}
.sc-trigger:hover { background: #eef3f8; }
.sc-trigger.open { background: #eef3f8; }
.sc-arrow { font-size: 0.65rem; color: #999; transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); margin-right: auto; }
.sc-trigger.open .sc-arrow { transform: rotate(180deg); }

.sc-dropdown {
    position: absolute; top: calc(100% + 6px); right: 0;
    width: 220px; max-height: 380px; overflow-y: auto;
    background: #fff; border-radius: 10px;
    box-shadow: 0 10px 35px rgba(0,0,0,0.15);
    border: 1px solid #e5e8ed;
    z-index: 1000; display: none;
    scrollbar-width: thin; scrollbar-color: #ddd transparent;
}
.sc-dropdown.open { display: block; animation: scFadeIn 0.2s ease; }
@keyframes scFadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.sc-group-label {
    padding: 0.55rem 0.85rem 0.35rem;
    font-size: 0.82rem; font-weight: 700;
    color: var(--primary); background: #fafbfd;
    border-bottom: 1px solid #f0f2f5;
    position: sticky; top: 0;
}
.sc-option {
    padding: 0.55rem 0.85rem; font-size: 0.85rem;
    color: #444; cursor: pointer;
    transition: all 0.15s; border-bottom: 1px solid #f8f8f8;
}
.sc-option:hover { background: #f0f7ff; color: var(--primary); }
.sc-option.selected { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sc-option-sub { padding-right: 1.5rem; font-size: 0.83rem; color: #555; }
.sc-option-special { color: var(--accent); font-weight: 600; }
.sc-option-special i { font-size: 0.75rem; }
.sc-divider { height: 1px; background: #eee; margin: 0.25rem 0; }

.search-form input[type="search"] { border: none; border-radius: 0; flex: 1; padding: 0.65rem 1rem; font-size: 0.92rem; outline: none; }
.search-form input:focus { box-shadow: none; }
.search-btn { background: var(--gradient-primary); color: #fff; border: none; padding: 0 1.35rem; cursor: pointer; font-size: 1.15rem; transition: all 0.2s; border-radius: 50px 0 0 50px; }
.search-btn:hover { opacity: 0.9; }
.search-results { position: absolute; top: calc(100% + 4px); right: 0; left: 0; background: #fff; border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,0.18); z-index: 9999; display: none; max-height: 480px; overflow-y: auto; border: 1px solid #e5e8ed; }
.search-results.active { display: block; }

/* 2-column search results grid */
.sr-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
}
.sr-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    border-left: 1px solid #f0f0f0;
    transition: background 0.15s;
}
.sr-item:nth-child(2n) { border-left: none; }
.sr-item:hover { background: #f8f9fc; }
.sr-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 4px;
}
.sr-info { flex: 1; min-width: 0; text-align: right; }
.sr-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
    margin-bottom: 0.2rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.sr-meta {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.2rem;
}
.sr-brand {
    font-size: 0.72rem;
    color: var(--primary);
    font-weight: 600;
}
.sr-hp {
    font-size: 0.72rem;
    color: #888;
    font-weight: 500;
}
.sr-sku {
    font-size: 0.7rem;
    color: #aaa;
    margin-bottom: 0.25rem;
    direction: ltr;
    text-align: right;
}
.sr-price {
    font-size: 0.82rem;
    line-height: 1.3;
}
.sr-price del {
    color: #bbb;
    font-size: 0.75rem;
    margin-left: 0.4rem;
    text-decoration: line-through;
}
.sr-price strong {
    color: var(--primary);
    font-weight: 800;
}
.sr-viewall {
    display: block;
    text-align: center;
    padding: 0.7rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    border-top: 1px solid #eee;
    transition: background 0.15s;
}
.sr-viewall:hover { background: #f0f7ff; }
.sr-viewall i { margin-left: 0.3rem; }
.sr-empty {
    padding: 1.5rem;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}
.sr-empty i { margin-left: 0.4rem; color: #ccc; }

/* Mobile: single column */
@media (max-width: 768px) {
    .sr-grid { grid-template-columns: 1fr; }
    .sr-item { border-left: none; }
}

/* Header Actions */
.header-actions { display: flex; align-items: center; gap: 1.25rem; }
.header-action { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; color: var(--text-body); font-size: 0.7rem; position: relative; }
.header-action:hover { color: var(--primary); }
.header-action i { font-size: 1.3rem; }
.action-count { position: absolute; top: -6px; right: -6px; background: var(--accent); color: #fff; font-size: 0.65rem; font-weight: 700; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.header-cart { display: flex; align-items: center; gap: 0.5rem; }
.cart-total { font-weight: 700; color: var(--primary-dark); font-size: var(--font-size-sm); white-space: nowrap; }

/* ---- NAVIGATION (Premium) ---- */
.main-nav { background: var(--bg-white); border-bottom: 2px solid var(--primary); position: relative; z-index: var(--z-sticky); }
.mega-menu-btn { display: flex; align-items: center; gap: 0.5rem; background: var(--gradient-primary); color: #fff; border: none; padding: 0.85rem 1.5rem; font-family: var(--font-family); font-size: 1rem; font-weight: 600; cursor: pointer; border-radius: 8px 8px 0 0; text-decoration: none; box-shadow: 0 2px 8px rgba(0,119,200,0.2); }
.mega-menu-btn:hover { background: var(--primary-hover); color: #fff; }
.mega-menu { position: absolute; top: 100%; right: 0; background: #fff; min-width: 700px; border-radius: 0 0 12px 12px; box-shadow: 0 12px 40px rgba(0,0,0,0.12); padding: 1.5rem; z-index: var(--z-dropdown); opacity: 0; visibility: hidden; transform: translateY(10px); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.mega-menu.active { opacity: 1; visibility: visible; transform: translateY(0); }
.mega-menu-inner { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
.mega-menu-title { display: block; font-weight: 700; color: var(--primary-dark); margin-bottom: 0.5rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--primary-light); }
.mega-menu-list li a { display: block; padding: 0.35rem 0; color: var(--text-body); font-size: var(--font-size-sm); transition: all 0.2s; }
.mega-menu-list li a:hover { color: var(--primary); padding-right: 0.5rem; }
.nav-links { display: flex; align-items: center; list-style: none; }
.nav-links a { display: block; padding: 0.85rem 1rem; color: var(--text-dark); font-weight: 500; position: relative; transition: color 0.2s; }
.nav-links a::after { content: ''; position: absolute; bottom: 0; right: 0; left: 0; height: 2px; background: var(--primary); transform: scaleX(0); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); transform-origin: center; }
.nav-links a:hover, .nav-links a.active { color: var(--primary); }
.nav-links a:hover::after, .nav-links a.active::after { transform: scaleX(1); }
.daily-offers-link { display: flex; align-items: center; gap: 0.4rem; color: var(--accent); font-weight: 700; font-size: var(--font-size-sm); animation: pulse-glow 2s infinite; }
@keyframes pulse-glow { 0%,100% { opacity: 1; } 50% { opacity: 0.7; } }

/* ---- MOBILE HEADER ---- */
.mobile-header { display: none; background: var(--bg-white); border-bottom: 2px solid var(--primary); position: sticky; top: 0; z-index: var(--z-sticky); }
.mobile-header-inner { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 1rem; height: 60px; }
.mobile-menu-btn, .mobile-cart-btn { background: none; border: none; font-size: 1.3rem; color: var(--primary-dark); cursor: pointer; position: relative; padding: 0.5rem; }
.mobile-logo { display: flex; align-items: center; gap: 0.4rem; color: var(--primary-dark); font-size: 1.1rem; font-weight: 800; }
.mobile-logo .logo-icon { font-size: 1.4rem; color: var(--primary); }

/* ---- MOBILE DRAWER ---- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: var(--z-drawer); opacity: 0; visibility: hidden; transition: all 0.3s; }
.drawer-overlay.active { opacity: 1; visibility: visible; }
.mobile-drawer { position: fixed; top: 0; right: -300px; width: 300px; height: 100%; background: #fff; z-index: calc(var(--z-drawer) + 1); transition: right 0.3s; overflow-y: auto; box-shadow: var(--shadow-lg); }
.mobile-drawer.active { right: 0; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem; border-bottom: 1px solid var(--border); }
.drawer-tabs { display: flex; }
.drawer-tab { padding: 0.5rem 1rem; border: none; background: none; font-family: var(--font-family); font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.drawer-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.drawer-close { background: none; border: none; font-size: 1.2rem; color: var(--text-muted); cursor: pointer; }
.drawer-search { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.drawer-search form { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.drawer-search input { flex: 1; border: none; padding: 0.5rem; font-size: var(--font-size-sm); }
.drawer-search button { background: var(--primary); color: #fff; border: none; padding: 0.5rem 0.75rem; cursor: pointer; }
.drawer-tab-content { display: none; padding: 0.5rem 0; }
.drawer-tab-content.active { display: block; }
.drawer-menu li a { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; color: var(--text-dark); border-bottom: 1px solid var(--border); }
.drawer-menu li a i:first-child { margin-left: 0.5rem; width: 20px; color: var(--primary); }
.drawer-menu li a:hover { background: var(--bg-light); }
.drawer-submenu { display: none; background: var(--bg-light); }
.has-submenu.open .drawer-submenu { display: block; }
.drawer-submenu a { padding-right: 2.5rem !important; font-size: var(--font-size-sm) !important; }

/* ---- BOTTOM NAV ---- */
.bottom-nav { display: none; position: fixed; bottom: 0; right: 0; left: 0; background: #fff; height: 60px; border-top: 1px solid var(--border); z-index: var(--z-fixed); box-shadow: 0 -2px 10px rgba(0,0,0,0.05); }
.bottom-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15rem; color: var(--text-muted); font-size: 0.65rem; font-weight: 500; position: relative; }
.bottom-nav-item i { font-size: 1.2rem; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-badge { position: absolute; top: 2px; right: calc(50% - 18px); background: var(--accent); color: #fff; font-size: 0.6rem; font-weight: 700; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* ---- FOOTER (Premium) ---- */
.site-footer { background: var(--gradient-primary-dark); color: rgba(255,255,255,0.8); margin-top: 3rem; }
.footer-main { padding: 3rem 0; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2rem; }
.footer-logo { margin-bottom: 1rem; }
.logo-text-light .logo-name { color: #fff; }
.logo-text-light .logo-tagline { color: rgba(255,255,255,0.6); }
.footer-desc { font-size: var(--font-size-sm); line-height: 1.8; color: rgba(255,255,255,0.65); margin-bottom: 1rem; }
.footer-contact-list { display: flex; flex-direction: column; gap: 0.5rem; }
.footer-contact-item { display: flex; align-items: flex-start; gap: 0.5rem; font-size: var(--font-size-sm); }
.footer-contact-item i { color: #4db8ff; margin-top: 0.2rem; }
.footer-contact-item a { color: rgba(255,255,255,0.8); }
.footer-contact-item a:hover { color: #fff; }
.footer-title { color: #fff; font-size: var(--font-size-lg); margin-bottom: 1.5rem; padding-bottom: 0.5rem; border-bottom: 2px solid rgba(0,119,200,0.5); display: inline-block; }
.footer-links { display: flex; flex-direction: column; gap: 0.5rem; }
.footer-links a { color: rgba(255,255,255,0.7); font-size: var(--font-size-sm); display: flex; align-items: center; gap: 0.5rem; transition: all 0.2s; }
.footer-links a:hover { color: #fff; padding-right: 0.25rem; }
.footer-article-thumb { width: 50px; height: 40px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.footer-social { display: flex; gap: 0.75rem; }
.social-link { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,0.08); color: #fff; display: flex; align-items: center; justify-content: center; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.social-link:hover { background: var(--primary); transform: translateY(-3px); box-shadow: 0 4px 15px rgba(0,119,200,0.4); }
.footer-bottom { background: rgba(0,0,0,0.25); padding: 1rem 0; font-size: var(--font-size-sm); }
.footer-bottom a { color: #4db8ff; }

/* Sticky (Premium) */
.main-header.sticky { position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-sticky); box-shadow: 0 2px 20px rgba(0,0,0,0.08); animation: slideDown 0.35s cubic-bezier(0.4, 0, 0.2, 1); background: rgba(255,255,255,0.98); backdrop-filter: blur(8px); }
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }
body.has-sticky-header { padding-top: calc(70px + 50px); }

/* =============================================
   CART DRAWER (Slide-in Sidebar)
   ============================================= */
.cart-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9990;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.cart-drawer-overlay.active {
    display: block;
    opacity: 1;
}

.cart-drawer {
    position: fixed;
    top: 0;
    left: -420px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: #fff;
    z-index: 9991;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 30px rgba(0,0,0,0.15);
    transition: left 0.35s cubic-bezier(0.19, 1, 0.22, 1);
}
.cart-drawer.active {
    left: 0;
}

/* Drawer Header */
.cart-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #eee;
    background: #FAFBFC;
    flex-shrink: 0;
}
.cart-drawer__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.cart-drawer__title i { color: var(--primary); }
.cart-drawer__close {
    background: none;
    border: none;
    font-size: 0.88rem;
    color: #666;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}
.cart-drawer__close:hover { background: #f0f0f0; color: var(--danger); }

/* Drawer Body */
.cart-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
}
.cart-drawer__body::-webkit-scrollbar { width: 4px; }
.cart-drawer__body::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.cart-drawer__loading {
    text-align: center;
    padding: 3rem 1rem;
    color: #999;
    font-size: 0.95rem;
}

/* Empty Cart */
.cart-drawer__empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #999;
}
.cart-drawer__empty i {
    font-size: 3rem;
    color: #ddd;
    margin-bottom: 1rem;
    display: block;
}
.cart-drawer__empty p {
    font-size: 0.95rem;
    margin-bottom: 1rem;
}
.cart-drawer__empty a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* Cart Item */
.cd-item {
    display: flex;
    gap: 0.85rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f5f5f5;
    align-items: flex-start;
    position: relative;
}
.cd-item:last-child { border-bottom: none; }

.cd-item__remove {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.2rem;
    transition: color 0.15s ease;
    line-height: 1;
}
.cd-item__remove:hover { color: var(--danger); }

.cd-item__img {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    border: 1px solid #eee;
    object-fit: contain;
    background: #fff;
    flex-shrink: 0;
}

.cd-item__info {
    flex: 1;
    min-width: 0;
}
.cd-item__name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.5;
    margin-bottom: 0.4rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cd-item__name a { color: inherit; text-decoration: none; }

/* Qty in Drawer — rounded professional like alalamiaa */
.cd-item__qty {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 0.4rem;
}
.cd-qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.cd-qty-btn:first-child { border-radius: 0 4px 4px 0; }
.cd-qty-btn:last-child { border-radius: 4px 0 0 4px; }
.cd-qty-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.cd-qty-val {
    width: 32px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dark);
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    height: 28px;
    line-height: 28px;
    background: #fff;
}

.cd-item__price {
    font-size: 0.82rem;
    color: var(--primary);
    font-weight: 700;
}

/* Drawer Footer */
.cart-drawer__footer {
    border-top: 2px solid #eee;
    padding: 1rem 1.25rem;
    background: #FAFBFC;
    flex-shrink: 0;
}
.cart-drawer__total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
    font-size: 1rem;
}
.cart-drawer__total span { color: #666; font-weight: 500; }
.cart-drawer__total strong { color: var(--primary); font-size: 1.15rem; font-weight: 800; }

.cart-drawer__btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    font-family: inherit;
    border: none;
    cursor: pointer;
}
.cart-drawer__btn:last-child { margin-bottom: 0; }

.cart-drawer__btn--view {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary);
}
.cart-drawer__btn--view:hover { background: var(--primary); color: #fff; }

.cart-drawer__btn--checkout {
    background: var(--accent);
    color: #fff;
}
.cart-drawer__btn--checkout:hover { background: var(--accent-hover); }

/* Mobile adjustments */
@media (max-width: 767px) {
    .cart-drawer { width: 100%; max-width: 100vw; left: -100%; }
    .cart-drawer.active { left: 0; }
}

/* =============================================
   BRAND RAIL (Desktop) + BRAND DRAWER (Mobile)
   ============================================= */

/* ---- Body offset for desktop rail ---- */
@media (min-width: 1025px) {
    body { padding-right: 72px; }
    /* Ensure sticky header also respects rail width */
    .main-header.sticky { right: 72px; }
}

/* ---- Desktop Brand Rail ---- */
.brand-rail {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: 72px;
    background: #fff;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e5e9ef;
    transition: width 0.35s cubic-bezier(0.19, 1, 0.22, 1),
                box-shadow 0.35s ease;
    overflow: hidden;
}
.brand-rail:hover {
    width: 300px;
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.12);
    z-index: 1300;
}

/* Rail Header — circular icon like alalamiaa */
.brand-rail__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: #fff;
    cursor: default;
    white-space: nowrap;
    min-height: 56px;
    flex-shrink: 0;
    border-bottom: 1px solid #e5e9ef;
}
.brand-rail__icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}
.brand-rail__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-dark);
    opacity: 0;
    transform: translateX(10px);
    transition: opacity 0.25s ease 0.05s, transform 0.25s ease 0.05s;
    font-family: var(--font-family);
}
.brand-rail:hover .brand-rail__title {
    opacity: 1;
    transform: translateX(0);
}

/* Rail List - hidden scrollbar */
.brand-rail__list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.brand-rail__list::-webkit-scrollbar { display: none; }

/* Rail Item */
.brand-rail__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    text-decoration: none;
    color: var(--text-body);
    border-bottom: 1px solid #F1F5F9;
    transition: background 0.2s ease;
    white-space: nowrap;
    min-height: 44px;
}
.brand-rail__item:hover {
    background: linear-gradient(90deg, transparent, #EAF7FF 30%);
}
.brand-rail__item:last-child {
    border-bottom: none;
}

/* Logo Wrap */
.brand-rail__logo-wrap {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #F8FAFB;
    border-radius: 8px;
    border: 1px solid #EEF2F6;
    overflow: hidden;
    transition: border-color 0.2s ease, transform 0.2s ease;
}
.brand-rail__item:hover .brand-rail__logo-wrap {
    border-color: #0077C8;
    transform: scale(1.05);
}
.brand-rail__logo {
    width: 26px;
    height: 26px;
    object-fit: contain;
}
.brand-rail__logo-fallback {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--primary-dark);
    text-align: center;
    line-height: 1;
}

/* Brand Name */
.brand-rail__name {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark);
    opacity: 0;
    transform: translateX(8px);
    transition: opacity 0.2s ease 0.08s, transform 0.2s ease 0.08s, color 0.2s ease;
}
.brand-rail:hover .brand-rail__name {
    opacity: 1;
    transform: translateX(0);
}
.brand-rail__item:hover .brand-rail__name {
    color: var(--primary);
}

/* Arrow */
.brand-rail__arrow {
    font-size: 0.7rem;
    color: #B0BEC5;
    opacity: 0;
    transition: opacity 0.2s ease 0.1s, color 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}
.brand-rail:hover .brand-rail__arrow {
    opacity: 0.5;
}
.brand-rail__item:hover .brand-rail__arrow {
    color: var(--primary);
    opacity: 1;
    transform: translateX(-4px);
}

/* Hide rail on mobile */
@media (max-width: 1024px) {
    .brand-rail, .brand-flyout { display: none !important; }
}

/* ---- Desktop Brand Flyout ---- */
.brand-flyout {
    position: fixed;
    z-index: 251;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #EEF2F6;
    padding: 8px 0;
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(8px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
    pointer-events: none;
}
.brand-flyout.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
}
.brand-flyout__item {
    display: block;
    padding: 10px 24px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: var(--font-family);
    transition: background 0.15s ease, color 0.15s ease, padding-right 0.15s ease;
    white-space: nowrap;
    text-align: right;
    border-bottom: 1px solid #F5F7FA;
}
.brand-flyout__item:last-child {
    border-bottom: none;
}
.brand-flyout__item:hover {
    background: #EAF7FF;
    color: var(--primary);
    padding-right: 28px;
}

/* ---- Mobile Brand Trigger ---- */
.brand-trigger {
    display: none;
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 149;
    background: linear-gradient(135deg, #0077C8, #005FA3);
    color: #fff;
    border: none;
    padding: 12px 6px;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    writing-mode: vertical-rl;
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 600;
    gap: 6px;
    align-items: center;
    box-shadow: -2px 0 12px rgba(0, 119, 200, 0.25);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}
.brand-trigger:hover {
    background: linear-gradient(135deg, #005FA3, #004A80);
    box-shadow: -3px 0 18px rgba(0, 119, 200, 0.35);
}
.brand-trigger i {
    writing-mode: horizontal-tb;
    font-size: 1rem;
    margin-bottom: 4px;
}
.brand-trigger span {
    letter-spacing: 1px;
}

@media (max-width: 1024px) {
    .brand-trigger { display: flex; }
}

/* ---- Mobile Brand Drawer ---- */
.brand-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-drawer);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.brand-drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.brand-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85vw;
    max-width: 340px;
    height: 100vh;
    background: #fff;
    z-index: calc(var(--z-drawer) + 1);
    transition: right 0.35s cubic-bezier(0.19, 1, 0.22, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
}
.brand-drawer.active {
    right: 0;
}

.brand-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #0077C8, #005FA3);
    color: #fff;
    flex-shrink: 0;
}
.brand-drawer__title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.brand-drawer__title-wrap i {
    font-size: 1.1rem;
}
.brand-drawer__title-wrap h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    font-family: var(--font-family);
}
.brand-drawer__close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}
.brand-drawer__close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.brand-drawer__list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Drawer Group & Item */
.brand-drawer__group {
    border-bottom: 1px solid #F1F5F9;
}
.brand-drawer__group:last-child { border-bottom: none; }

.brand-drawer__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-dark);
    transition: background 0.2s ease;
}
.brand-drawer__item:hover,
.brand-drawer__item:active {
    background: #EAF7FF;
}

.brand-drawer__link {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.brand-drawer__logo-wrap {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #F8FAFB;
    border-radius: 10px;
    border: 1px solid #EEF2F6;
    overflow: hidden;
    transition: border-color 0.2s ease;
}
.brand-drawer__item:hover .brand-drawer__logo-wrap,
.brand-drawer__item:active .brand-drawer__logo-wrap {
    border-color: #0077C8;
}
.brand-drawer__logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
}
.brand-drawer__logo-fallback {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--primary-dark);
}
.brand-drawer__name {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    transition: color 0.2s ease;
}
.brand-drawer__item:hover .brand-drawer__name,
.brand-drawer__item:active .brand-drawer__name {
    color: var(--primary);
}

/* Toggle button for accordion */
.brand-drawer__toggle {
    background: none;
    border: none;
    color: #B0BEC5;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s ease, color 0.2s ease, transform 0.3s ease;
    flex-shrink: 0;
    font-size: 0.8rem;
}
.brand-drawer__toggle:hover {
    background: #EAF7FF;
    color: var(--primary);
}
.brand-drawer__group.open .brand-drawer__toggle {
    transform: rotate(180deg);
    color: var(--primary);
}

.brand-drawer__arrow-static {
    font-size: 0.7rem;
    color: #B0BEC5;
    flex-shrink: 0;
    margin-left: 8px;
}

/* Accordion Submenu */
.brand-drawer__submenu {
    max-height: 0;
    overflow: hidden;
    background: #F8FAFB;
    transition: max-height 0.3s ease;
}
.brand-drawer__group.open .brand-drawer__submenu {
    max-height: 400px;
}
.brand-drawer__sub-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px 10px 20px;
    padding-right: 76px;
    text-decoration: none;
    color: var(--text-body);
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 1px solid #EEF2F6;
    transition: background 0.15s ease, color 0.15s ease;
}
.brand-drawer__sub-item:last-child { border-bottom: none; }
.brand-drawer__sub-item:hover,
.brand-drawer__sub-item:active {
    background: #E0F0FF;
    color: var(--primary);
}
.brand-drawer__sub-item i {
    font-size: 0.7rem;
    color: var(--primary);
    opacity: 0.5;
}

/* Hide drawer on desktop */
@media (min-width: 1025px) {
    .brand-drawer,
    .brand-drawer-overlay { display: none !important; }
}

/* =============================================
   ADMIN FRONT BAR
   ============================================= */
.admin-front-bar {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: rgba(255,255,255,0.85);
    font-size: 0.75rem;
    padding: 0;
    z-index: 9995;
    position: relative;
}
.admin-front-bar .container { padding: 0.35rem 1rem; }
.afb-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.afb-links a {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
}
.afb-links a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.afb-links a i { font-size: 0.65rem; }
.afb-edit {
    color: #4db8ff !important;
    font-weight: 600;
    background: rgba(77,184,255,0.1);
}
.afb-edit:hover { background: rgba(77,184,255,0.2) !important; }
.afb-logout {
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}
.afb-logout:hover { color: #ff6b6b; background: rgba(255,107,107,0.1); }
.afb-logout i { font-size: 0.65rem; }

@media (max-width: 768px) {
    .admin-front-bar { display: none; }
}

/* =============================================
   USER DROPDOWN
   ============================================= */
.user-dropdown-wrap {
    position: relative;
}
.user-dropdown-trigger {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    color: var(--text-body);
    font-size: 0.7rem;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
}
.user-dropdown-trigger:hover { color: var(--primary); background: rgba(0,119,200,0.05); }
.user-dropdown-trigger i:first-child { font-size: 1.3rem; }

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.06);
    z-index: 1000;
    display: none;
    animation: udFadeIn 0.2s ease;
}
.user-dropdown.open { display: block; }
@keyframes udFadeIn { from { opacity: 0; transform: translateX(-50%) translateY(-6px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.ud-header {
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
}
.ud-header i { font-size: 1.2rem; opacity: 0.8; }

.ud-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    color: #444;
    text-decoration: none;
    font-size: 0.82rem;
    transition: all 0.15s;
    border-bottom: 1px solid #f5f5f5;
}
.ud-item:hover { background: #f8f9fc; color: var(--primary); }
.ud-item i { font-size: 0.78rem; width: 18px; text-align: center; color: #999; }
.ud-item:hover i { color: var(--primary); }

.ud-admin { color: var(--accent); font-weight: 600; }
.ud-admin i { color: var(--accent); }
.ud-admin:hover { background: rgba(255,138,0,0.05); }

.ud-logout { color: #e53935; }
.ud-logout i { color: #e53935; }
.ud-logout:hover { background: rgba(229,57,53,0.05); }

.ud-divider { height: 1px; background: #eee; margin: 0; }

/* =============================================
   MOBILE DRAWER AUTH SECTION
   ============================================= */
.drawer-auth {
    padding: 1rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.drawer-user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--primary-dark);
    font-size: 0.9rem;
}
.drawer-user-info i { font-size: 1.5rem; color: var(--primary); }
.drawer-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    background: var(--gradient-primary);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.drawer-login-btn:hover { opacity: 0.9; color: #fff; }
.drawer-auth .logout-link { color: #e53935 !important; }

