/* ============================================================
   MOBILE APP DRAWER NAVIGATION
   Full-screen panel with back/forward stack for mega-menus
   ============================================================ */

/* ── Hamburger toggle (only visible on mobile) ────────────── */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background: var(--bg-alt);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    gap: 5px;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1100;
    flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--primary-light); border-color: var(--primary-color); }
.mobile-menu-btn .bar {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-color);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}
.mobile-menu-btn.is-open .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-menu-btn.is-open .bar:nth-child(2) { opacity: 0; transform: scaleX(0); }
.mobile-menu-btn.is-open .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Drawer Overlay ──────────────────────────────────────── */
#drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
#drawer-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* ── Main Drawer Panel ───────────────────────────────────── */
#mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: min(360px, 88vw);
    height: 100dvh;
    height: 100vh; /* fallback */
    background: var(--card-bg);
    z-index: 1060;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.25);
}
#mobile-drawer.is-open {
    transform: translateX(0);
}
[data-theme="dark"] #mobile-drawer {
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.7);
    background: #111111;
}

/* ── Drawer Top Bar ──────────────────────────────────────── */
.drawer-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--card-bg);
    position: relative;
    z-index: 1;
}
[data-theme="dark"] .drawer-topbar { background: #111111; }

.drawer-brand {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-color);
    text-decoration: none;
    letter-spacing: -0.5px;
}
.drawer-brand span { color: var(--primary-color); }

.drawer-close-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    background: var(--bg-alt);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    transition: all 0.2s;
    flex-shrink: 0;
}
.drawer-close-btn:hover { background: var(--primary-light); border-color: var(--primary-color); color: var(--primary-color); }
.drawer-close-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; }

/* ── Nav/Back bar (shown on sub-panels) ──────────────────── */
.drawer-nav-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    min-height: 50px;
    background: var(--bg-alt);
    overflow: hidden;
}

.drawer-back-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.drawer-back-btn:hover { background: var(--primary-light); color: var(--primary-color); border-color: var(--primary-color); }
.drawer-back-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.drawer-breadcrumb {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* ── Sliding Panels Container ───────────────────────────── */
.drawer-panels {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Each panel */
.drawer-panel {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: var(--card-bg);
    transform: translateX(0);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
[data-theme="dark"] .drawer-panel { background: #111111; }

/* Root panel: slides LEFT when a sub-panel is active */
.drawer-panel.slide-left {
    transform: translateX(-100%);
}

/* Sub panel: starts offscreen right, slides in */
.drawer-panel.sub-panel {
    transform: translateX(100%);
    z-index: 2;
}
.drawer-panel.sub-panel.slide-in {
    transform: translateX(0);
}

/* ── Root Panel Items (categories) ──────────────────────── */
.drawer-list {
    list-style: none;
    padding: 0.5rem 0;
}

.drawer-list-item {
    border-bottom: 1px solid var(--border-color);
}
.drawer-list-item:last-child { border-bottom: none; }

.drawer-list-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.9rem 1.25rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.97rem;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
}
.drawer-list-link:hover,
.drawer-list-link:active {
    background: var(--primary-light);
    color: var(--primary-color);
}

.drawer-list-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--bg-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    transition: background 0.15s;
}
.drawer-list-link:hover .drawer-list-icon { background: rgba(229, 9, 20, 0.12); }

.drawer-list-label { flex: 1; }
.drawer-list-desc { font-size: 0.78rem; color: var(--text-muted); display: block; margin-top: 0.1rem; font-weight: 400; }

.drawer-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.4;
}
.drawer-chevron svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* Section divider */
.drawer-divider {
    padding: 0.5rem 1.25rem 0.2rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border-color);
}

/* ── Sub-Panel (Category Tools List) ────────────────────── */
.drawer-sub-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--primary-color) 0%, #b9090b 100%);
}
.drawer-sub-header-icon {
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.drawer-sub-header-title { font-size: 1rem; font-weight: 800; color: white; line-height: 1.2; }
.drawer-sub-header-desc { font-size: 0.78rem; color: rgba(255,255,255,0.8); }

.drawer-view-all-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 1.25rem;
    padding: 0.65rem 1rem;
    background: var(--primary-light);
    color: var(--primary-color) !important;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.87rem;
    font-weight: 700;
    border: 1px solid rgba(229, 9, 20, 0.2);
    transition: all 0.2s;
}
.drawer-view-all-link:hover { background: var(--primary-color); color: white !important; }
.drawer-view-all-link svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.drawer-group-title {
    padding: 0.6rem 1.25rem 0.3rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--primary-color);
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.drawer-tool-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.15s;
    position: relative;
}
.drawer-tool-link:hover, .drawer-tool-link:active {
    background: var(--primary-light);
    color: var(--primary-color);
    padding-left: 1.5rem;
}
.drawer-tool-icon {
    font-size: 1.1rem;
    width: 34px;
    height: 34px;
    background: var(--bg-alt);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.drawer-tool-link:hover .drawer-tool-icon { background: rgba(229,9,20,0.12); }

.drawer-tool-badge {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--primary-color);
    color: #fff;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    letter-spacing: 0.5px;
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Static links at bottom of root panel ───────────────── */
.drawer-footer-links {
    padding: 0.5rem 0;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}
.drawer-footer-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
}
.drawer-footer-link:hover { color: var(--primary-color); background: var(--primary-light); }

/* ── Bottom action bar ───────────────────────────────────── */
.drawer-bottom-bar {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    background: var(--bg-alt);
}
[data-theme="dark"] .drawer-bottom-bar { background: #0a0a0a; }

.drawer-login-btn {
    flex: 1;
    padding: 0.7rem 1rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    transition: all 0.2s;
}
.drawer-login-btn:hover { background: var(--primary-hover); }

.drawer-theme-btn {
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
    flex-shrink: 0;
}
.drawer-theme-btn:hover { border-color: var(--primary-color); background: var(--primary-light); }

/* ── Only show mobile elements on small screens ─────────── */
@media (min-width: 769px) {
    .mobile-menu-btn { display: none !important; }
    #mobile-drawer { display: none !important; }
    #drawer-overlay { display: none !important; }
}

@media (max-width: 768px) {
    .mobile-menu-btn { display: flex; }
    .nav-links { display: none !important; }  /* Hide desktop nav on mobile */
}
