/* /css/menu.css */

body.no-scroll {
    overflow: hidden !important;
}

#dropdown-menu {
    position: fixed;
    top: var(--header-height, 65px);
    right: -400px;
    width: 380px;
    height: calc(100vh - var(--header-height, 65px));
    max-width: 100vw;
    background: var(--color-bg-card);
    z-index: 1030;
    box-shadow: -2px 0 40px rgba(0,0,0,0.12), -1px 0 10px rgba(0,0,0,0.08);
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s, visibility 0.3s;
    overflow-y: auto;
    overflow-x: hidden;
    border-left: 1px solid var(--color-border-default);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: block;
}

#dropdown-menu.active {
    right: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto;
    box-shadow: -2px 0 50px rgba(0,0,0,0.15), -1px 0 15px rgba(0,0,0,0.1);
}

@media (max-width: 1024px) {
    .dropdown-menu {
        width: 90vw;
        max-width: 400px;
        right: -90vw;
        top: var(--header-height, 60px);
        height: calc(100vh - var(--header-height, 60px));
        box-shadow: none;
    }
    .dropdown-menu.active {
        right: 0;
    }
}

@media (max-width: 600px) {
    .dropdown-menu {
        width: 100vw;
        max-width: 100vw;
        right: -100vw;
    }
    .dropdown-menu.active {
        right: 0;
    }
}

@media (max-width: 768px) {
    .dropdown-menu {
        width: 100vw;
        right: -100vw; /* Ensure it slides from right */
        left: auto; /* Reset left */
        top: 60px;
        height: calc(100vh - 60px);
        max-height: calc(100vh - 60px);
        box-shadow: none;
    }
    .dropdown-menu.active {
        right: 0;
    }
}

@media (max-width: 480px) {
    .dropdown-menu {
        width: 100vw;
        right: -100vw;
    }
    .dropdown-menu.active {
        right: 0;
    }
}

@media (max-width: 768px) {
    .dropdown-menu {
        width: min(380px, calc(100vw - 20px));
        top: 60px;
        height: calc(100vh - 60px);
        left: auto;
    }
}

.menu-overlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100vw;
    height: calc(100vh - var(--header-height));
    background: rgba(0,0,0,0.15);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s, visibility 0.3s;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .menu-overlay {
        top: 60px;
        height: calc(100vh - 60px);
    }
}

/* Hamburger Menu */
.hamburger-menu {
    z-index: 1021 !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 8px !important;
    margin: 0 !important;
    cursor: pointer;
    position: relative;
    width: 35px !important;
    height: 30px !important;
    transition: all 0.3s ease;
    border-radius: 6px;
}

.hamburger-menu:hover {
    background: transparent !important;
    transform: translateY(-1px);
}

.hamburger-menu:hover .line {
    background-color: var(--color-brand-accent) !important;
}

.hamburger-menu:focus {
    outline: none !important;
    box-shadow: none !important;
}

header .hamburger-menu,
.site-header .hamburger-menu,
#header .hamburger-menu {
    width: 35px !important;
    height: 30px !important;
}

html body header .hamburger-menu,
html body .site-header .hamburger-menu,
html body #header .hamburger-menu,
body header .hamburger-menu,
body .site-header .hamburger-menu,
body #header .hamburger-menu {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.hamburger-menu .line {
    display: block !important;
    height: 2px !important;
    background-color: var(--color-text-primary) !important;
    border: none !important;
    border-radius: 2px !important;
    position: absolute !important;
    right: 0 !important;
    transition: all 0.3s ease-in-out !important;
    box-shadow: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 99999 !important;
}

.hamburger-menu .line-1 { top: 6px !important; width: 22px !important; }
.hamburger-menu .line-2 { top: 14px !important; width: 16px !important; }
.hamburger-menu .line-3 { top: 22px !important; width: 22px !important; }

.hamburger-menu.active .line-1,
.hamburger-menu.open .line-1 {
    transform: translateY(8px) rotate(45deg) !important;
    width: 22px !important;
    top: 6px !important;
    transform-origin: center !important;
}

.hamburger-menu.active .line-2,
.hamburger-menu.open .line-2 {
    opacity: 0 !important;
    transform: scale(0) !important;
}

.hamburger-menu.active .line-3,
.hamburger-menu.open .line-3 {
    transform: translateY(-6px) rotate(-45deg) !important;
    width: 22px !important;
    top: 22px !important;
}


/* User Section */
.user-section {
    padding: 24px 20px;
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    position: relative;
}

.user-section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20px;
    right: 20px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.08), transparent);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.user-avatar {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #0A74DA, #005AA7);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(10, 116, 218, 0.25);
    border: 3px solid rgba(255, 255, 255, 0.9);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.user-avatar:hover::before {
    opacity: 1;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-details h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: #1a1a1a;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-details span {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.6px;
    background: linear-gradient(135deg, rgba(107, 114, 128, 0.12), rgba(107, 114, 128, 0.06));
    padding: 4px 10px;
    border-radius: 8px;
    margin-top: 2px;
    display: inline-block;
    border: 1px solid rgba(107, 114, 128, 0.15);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.user-details span::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.6s ease;
}

.user-details span:hover::before {
    left: 100%;
}

@media (max-width: 480px) {
    .user-section { padding: 24px 16px; }
    .user-avatar { width: 44px; height: 44px; font-size: 16px; }
}
@media (max-width: 768px) {
    .user-section { padding: 22px 18px; }
    .user-avatar { width: 48px; height: 48px; font-size: 17px; }
}


/* Menu Links */
.menu-links {
    padding: 20px 0 60px 0;
}

.menu-section {
    border-bottom: 1px solid rgba(0,0,0,0.03);
    position: relative;
    margin-bottom: 6px;
}

.menu-section:first-child {
    margin-top: 8px;
}

.menu-section:last-child {
    border-bottom: none;
    margin-bottom: 20px;
}

.menu-section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20px;
    right: 20px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.05), transparent);
}

.menu-section:last-child::after {
    display: none;
}

.menu-section-title {
    padding: 20px 20px 12px;
    font-size: 10px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: transparent;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-section-title::before {
    content: '';
    width: 12px;
    height: 1px;
    background: linear-gradient(90deg, #6b7280, transparent);
    flex-shrink: 0;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: var(--primary-700); /* Primary 700 */
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid rgba(0,0,0,0.02);
    font-size: 14px;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    letter-spacing: -0.1px;
    margin: 0 8px;
    border-radius: 8px;
}

.menu-link:last-child {
    border-bottom: none;
}

.menu-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(135deg, var(--primary-700), var(--primary-500));
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-link::after {
    content: '';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #007cba;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-link:hover {
    background: linear-gradient(135deg, rgba(27,130,138,0.08), rgba(27,130,138,0.04));
    color: var(--accent-500); /* Accent 500 */
    transform: translateX(6px);
    padding-left: 26px;
    box-shadow: inset 0 0 0 1px rgba(27,130,138,0.12);
}

.menu-link:hover::before {
    width: 3px;
    background: linear-gradient(135deg, var(--accent-500), var(--accent-300));
}

.menu-link:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
    background: #1B828A;
}

.menu-link.active {
    background: linear-gradient(135deg, rgba(0,124,186,0.08), rgba(0,86,179,0.04));
    color: #007cba;
    font-weight: 600;
    border-left: 3px solid #007cba;
    padding-left: 17px;
    box-shadow: inset 0 0 0 1px rgba(0,124,186,0.12);
}

.menu-link.active::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
    background: #007cba;
}

.menu-link i {
    width: 18px;
    margin-right: 16px;
    font-size: 13px;
    opacity: 0.6;
    transition: all 0.25s ease;
    text-align: center;
}

.menu-link:hover i,
.menu-link.active i {
    opacity: 1;
    transform: scale(1.05);
}

/* Admin & Special Links */
.menu-link.admin { color: #dc2626; }
.menu-link.admin::before { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.menu-link.admin:hover {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.03), rgba(185, 28, 28, 0.02));
    color: #dc2626;
    box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.08);
}
.menu-link.admin:hover::after { background: #dc2626; }
.menu-link.admin.active {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.08), rgba(185, 28, 28, 0.04));
    border-left-color: #dc2626;
    box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.12);
}

/* Logout Link */
.menu-link.logout {
    color: #6b7280;
    border-top: 1px solid rgba(0,0,0,0.06);
    margin-top: 12px;
    font-weight: 500;
}
.menu-link.logout::before { background: linear-gradient(135deg, #6b7280, #4b5563); }
.menu-link.logout:hover {
    background: linear-gradient(135deg, rgba(107, 114, 128, 0.03), rgba(75, 85, 99, 0.02));
    color: #374151;
    box-shadow: inset 0 0 0 1px rgba(107, 114, 128, 0.08);
}
.menu-link.logout:hover::after { background: #6b7280; }


@media (max-width: 480px) {
    .menu-links { padding: 16px 0 80px 0; }
    .menu-link { padding: 14px 16px; margin: 0 4px; }
}
@media (max-width: 768px) {
    .menu-links { padding: 18px 0 70px 0; }
    .menu-link { padding: 14px 18px; margin: 0 6px; }
}

/* Menu Animations */
.menu-link {
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
    transform: translateY(10px);
}

#dropdown-menu.active .menu-link {
    animation-delay: calc(var(--i) * 0.05s);
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dark Mode Overrides */
html[data-theme="dark"] .hamburger-menu .line {
    background: var(--color-text-primary) !important;
}

html[data-theme="dark"] .menu-link i {
    color: var(--color-text-secondary);
    opacity: 0.8;
    margin-right: 20px;
}

/* PortWatcher Modal Styles */
.portwatcher-modal {
    display: none !important;
    position: fixed;
    z-index: 1030;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}
.portwatcher-modal.active {
    display: flex;
    opacity: 1;
}
.portwatcher-modal-content {
    position: relative;
    background-color: #fefefe;
    margin: auto;
    padding: 0;
    border: 1px solid #888;
    width: 90%;
    height: 90%;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
    animation-name: animatetop;
    animation-duration: 0.4s;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
}
@keyframes animatetop {
    from {top:-300px; opacity:0}
    to {top:0; opacity:1}
}
.portwatcher-close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 15px;
    z-index: 1040;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    transition: color 0.3s ease;
}
.portwatcher-close-btn:hover,
.portwatcher-close-btn:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}
.portwatcher-modal-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}
@media (max-width: 768px) {
    .portwatcher-modal-content {
        width: 95%;
        height: 95%;
    }
}

/* TEMP DIAGNOSTIC OVERRIDE: Force menu visible to diagnose hiding issue.
   Remove this block after confirming whether the menu renders. */