/*
   FILE: static/css/header-final.css
   UPDATED: Mobile Tools Toggle Fix
*/

:root {
    --w360-header-bg: #ffffff;
    --w360-header-text: #334155;
    --w360-header-primary: #0F172A;
    --w360-header-accent: #3B82F6;
    --w360-header-height: 80px;
}

/* =========================================
   1. BASE LAYOUT & CENTERING LOGIC
   ========================================= */
.w360-header {
    width: 100%;
    height: var(--w360-header-height);
    background-color: var(--w360-header-bg);
    border-bottom: 1px solid #e2e8f0;
    position: relative;
    z-index: 1000;
}

.w360-header .container-fluid {
    width: 100%;
    height: 100%;
    padding-left: 2rem;
    padding-right: 2rem;
}

.w360-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
}

@media (min-width: 992px) {
    .w360-header-inner {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
    }
}

/* =========================================
   2. LOGO
   ========================================= */
.w360-header-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    height: 100%;
    justify-self: start;
}

.w360-logo-icon {
    display: block;
    max-height: 40px !important;
    width: auto !important;
    object-fit: contain;
    border-radius: 6px;
}

/* =========================================
   3. NAVIGATION (Centered)
   ========================================= */
.w360-header-nav { display: none; }

@media (min-width: 992px) {
    .w360-header-nav {
        display: flex;
        align-items: center;
        gap: 32px;
        justify-self: center;
    }
}

.w360-nav-link {
    color: var(--w360-header-text);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
    padding: 8px 0;
    white-space: nowrap;
}
.w360-nav-link:hover { color: var(--w360-header-accent); }

/* =========================================
   4. ACTIONS (Right)
   ========================================= */
.w360-header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-content: flex-end;
    justify-self: end;
}

.w360-login-link {
    color: var(--w360-header-primary);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    white-space: nowrap;
}

.w360-btn-primary {
    background-color: var(--w360-header-primary);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.w360-btn-primary:hover { background-color: #1e293b; color: #fff; }

.w360-action-icon {
    font-size: 1.2rem;
    color: var(--w360-header-text);
    position: relative;
    padding: 5px;
    display: flex;
    align-items: center;
}

.w360-avatar-btn {
    width: 40px; height: 40px; min-width: 40px;
    border-radius: 50%; overflow: hidden;
    cursor: pointer; border: 1px solid #e2e8f0;
}
.w360-avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

/* =========================================
   5. MOBILE MENU & TOGGLES
   ========================================= */
.w360-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none; border: none;
    font-size: 1.5rem;
    color: var(--w360-header-primary);
    cursor: pointer; padding: 0;
    min-width: 44px; min-height: 44px;
}

.vs-menu-close-btn {
    background: #f1f5f9;
    border: none;
    color: #334155;
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; cursor: pointer;
    transition: background 0.2s;
}
.vs-menu-close-btn:hover { background: #e2e8f0; color: #ef4444; }

@media (min-width: 992px) {
    .w360-mobile-toggle { display: none !important; }
}
@media (max-width: 991px) {
    .w360-header-actions .w360-login-link,
    .w360-header-actions .w360-btn-primary,
    .w360-avatar-btn,
    .w360-action-icon {
        display: none;
    }
}

/* DRAWER STYLES */
.vs-menu-wrapper {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 9999;
    opacity: 0; visibility: hidden; transition: all 0.3s;
}
.vs-menu-wrapper.vs-body-visible { opacity: 1; visibility: visible; }

.vs-menu-area {
    width: 280px; height: 100%; background: #fff;
    position: absolute; left: -280px; top: 0;
    transition: all 0.3s; padding: 25px;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    overflow-y: auto;
}
.vs-menu-wrapper.vs-body-visible .vs-menu-area { left: 0; }

.vs-mobile-menu ul { list-style: none; padding: 0; margin-top: 10px; }
.vs-mobile-menu ul li a {
    display: block; padding: 12px 0; border-bottom: 1px solid #f1f5f9;
    color: #334155; text-decoration: none; font-weight: 500;
}

/* =========================================
   6. USER PLAN LAYOUT (Fixed Stacking)
   ========================================= */
.w360-drawer-avatar {
    width:60px; height:60px; border-radius:50%; object-fit:cover;
    border:3px solid #fff; box-shadow:0 2px 5px rgba(0,0,0,0.1);
}
.w360-drawer-avatar-lg {
    width:70px; height:70px; border-radius:50%; object-fit:cover;
    border:3px solid #fff; box-shadow:0 2px 5px rgba(0,0,0,0.1);
}

.plan-info-container {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100%;
    margin-top: 10px;
}

.plan-badge-wrapper {
    display: block !important;
    position: relative !important;
    margin-bottom: 15px !important;
    width: auto;
}

.plan-badge-wrapper .badge {
    font-size: 0.85rem;
    padding: 8px 16px;
    display: inline-block;
}

.plan-time-box {
    display: block !important;
    position: relative !important;
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #64748b;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    width: auto;
    max-width: 220px;
}

/* =========================================
   7. MEGA MENU (Desktop)
   ========================================= */
.w360-nav-item-dropdown {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
}

.w360-nav-link.has-dropdown {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.w360-mega-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-85%);
    width: 1000px;
    max-width: 90vw;
    background: #ffffff;
    box-shadow: 0 15px 40px rgba(0,0,0,0.1);
    border-top: 3px solid #0d6efd;
    border-radius: 0 0 8px 8px;
    padding: 30px;
    z-index: 9999;
    cursor: default;
}

.w360-nav-item-dropdown:hover .w360-mega-menu {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; margin-top: 10px; }
    to { opacity: 1; margin-top: 0; }
}

.mega-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 300px;
    gap: 30px;
}

.mega-col-header {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    color: #0d6efd;
    margin-bottom: 20px;
    letter-spacing: 0.5px;
}

.mega-link-item {
    display: flex;
    align-items: flex-start;
    text-decoration: none;
    margin-bottom: 20px;
    group: hover;
}

.mega-link-item:hover .mega-icon { color: #0d6efd; }
.mega-link-item:hover .mega-text h4 { color: #0d6efd; }

.mega-icon {
    font-size: 18px;
    color: #64748b;
    margin-right: 12px;
    margin-top: 2px;
    width: 20px;
    text-align: center;
    transition: color 0.2s;
}

.mega-text h4 {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 3px 0;
    transition: color 0.2s;
}

.mega-text p {
    font-size: 13px;
    color: #64748b;
    margin: 0;
    line-height: 1.3;
}

.mega-featured-card {
    background-color: #f8fafc;
    border-radius: 8px;
    padding: 25px;
    text-align: left;
}

.mega-featured-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 10px;
    display: block;
}

.mega-featured-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 10px;
}

.mega-featured-desc {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 20px;
    line-height: 1.5;
}

.mega-btn-blue {
    display: inline-block;
    background-color: #2563eb;
    color: white !important;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    width: 100%;
    text-align: center;
    transition: background 0.2s;
}

.mega-btn-blue:hover { background-color: #1d4ed8; }

/* =========================================
   8. MOBILE TOOLS TOGGLE LOGIC (CRITICAL FIX)
   ========================================= */

/* 1. Hide submenu by default - This was missing */
.mobile-sub-menu {
    display: none;
    padding-left: 20px;
    border-left: 2px solid #e2e8f0;
    margin-top: 10px;
    margin-bottom: 10px;
}

/* 2. Show submenu only when 'open' class is added by JS */
.mobile-sub-menu.open {
    display: block !important; /* Force display */
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.mobile-sub-header {
    font-size: 12px;
    text-transform: uppercase;
    color: #94a3b8;
    margin-top: 15px;
    margin-bottom: 5px;
    font-weight: 700;
}

/* Chevron Rotation when active */
.mobile-dropdown-toggle .fa-chevron-down {
    transition: transform 0.3s ease;
}
.mobile-dropdown-toggle.active .fa-chevron-down {
    transform: rotate(180deg);
}
