/* ===================================================================== */
/* =                              Dropdown                             = */
/* ===================================================================== */

.dropdown {
    position: fixed;
    right: 0.5rem;
    top: 6.5em;
    width: 280px;
    max-width: calc(100vw - 1rem);
    max-height: calc(100vh - 7em);
    overflow-y: auto;
    background: var(--colour-dark);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    box-shadow: 0px 6px 8px rgba(0,0,0,0.5);
    transform-origin: right top;
    opacity: 0;
    transform: translateY(-15px) scale(0.92);
    transition: 
    opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), 
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1999;
    padding: 0.75rem;
    display: none;
    pointer-events: none;
}

.dropdown.open {
    display: block;
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: 
    opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1), 
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* === Layout === */

.dropdown-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* === Section Headers === */

.dropdown-section {
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
    padding: 0 0.5rem;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0;
}

.dropdown-section:first-child {
    margin-top: 0.25rem;
}

.dropdown.open .dropdown-section {
    animation: fadeIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes fadeIn {
    to {
        opacity: 0.7;
    }
}

/* === Dropdown Items === */

.dropdown a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.9rem;
    text-decoration: none;
    color: var(--text-main);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    border: 1px solid rgba(255,255,255,0.02);
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    opacity: 0;
    transform: translateX(10px);
}

.dropdown.open a {
    animation: slideInItem 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.dropdown.open a:nth-child(1) { animation-delay: 0.06s; }
.dropdown.open a:nth-child(2) { animation-delay: 0.10s; }
.dropdown.open a:nth-child(3) { animation-delay: 0.14s; }
.dropdown.open a:nth-child(4) { animation-delay: 0.18s; }
.dropdown.open a:nth-child(5) { animation-delay: 0.22s; }
.dropdown.open a:nth-child(6) { animation-delay: 0.26s; }
.dropdown.open a:nth-child(7) { animation-delay: 0.30s; }
.dropdown.open a:nth-child(8) { animation-delay: 0.34s; }
.dropdown.open a:nth-child(9) { animation-delay: 0.38s; }
.dropdown.open a:nth-child(10) { animation-delay: 0.42s; }

@keyframes slideInItem {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.dropdown a:hover {
    background: var(--colour-accent);
    border-color: var(--colour-accent);
    color: #ffffff;
    transform: translateX(-2px);
}

.dropdown a:active {
    transform: scale(0.98);
}

.dropdown a i {
    font-size: 1rem;
    opacity: 0.8;
}

/* === Logout === */

.dropdown a.danger {
    color: #ff6b6b;
}

.dropdown a.danger:hover {
    color: #ffffff;
    background: #991F1F;
    border-color: #991F1F;
}

/* === Light Theme Overrides === */

body[data-theme="light"] .dropdown {
    background: var(--colour-dark);
}

body[data-theme="light"] .dropdown-section {
    color: var(--text-muted);
}

body[data-theme="light"] .dropdown a {
    color: var(--text-main);
}

body[data-theme="light"] .dropdown a:hover {
    background: var(--colour-accent);
    color: #ffffff;
}

body[data-theme="light"] .dropdown a.danger {
    color: #ff6b6b;
}

body[data-theme="light"] .dropdown a.danger:hover {
    color: #ffffff;
    background: #991F1F;
}

/* === Scrollbar Styling === */

.dropdown::-webkit-scrollbar {
    width: 6px;
}

.dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.dropdown::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

/* === Mobile === */

@media (max-width: 400px) {
    .dropdown {
        width: calc(100vw - 1rem);
        max-width: none;
        left: 0.5rem;
        right: auto;
        top: 5em;
        max-height: calc(100vh - 6em);
    }
}

/* === Desktop - Align with centered navbar === */

@media (min-width: 801px) {
    .dropdown {
        right: calc(50% - 400px + 0.5rem);
    }
}
