/**
 * Mobile Navigation Drawer Styles
 * Unified drawer component for Unregistry ecosystem
 */

/* ===== Drawer Container ===== */
.nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    pointer-events: none;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overscroll-behavior: contain;
}

.nav-drawer.active {
    pointer-events: auto;
}

/* ===== Drawer Overlay ===== */
.nav-drawer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.nav-drawer.active .nav-drawer-overlay {
    opacity: 1;
}

/* ===== Drawer Content ===== */
.nav-drawer-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    background: var(--bg-2, #0d0d0d);
    border-radius: 0;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.3);
    will-change: transform;
    -webkit-transform: translateY(100%);
    -webkit-transition: -webkit-transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

/* Glassmorphism effect */
@supports (backdrop-filter: blur(20px)) {
    .nav-drawer-content {
        background: rgba(26, 26, 26, 0.85);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        backdrop-filter: blur(20px) saturate(180%);
    }
}

.nav-drawer.active .nav-drawer-content {
    transform: translateY(0);
    -webkit-transform: translateY(0);
}

/* ===== Drag Handle ===== */
.nav-drawer-handle {
    width: 100%;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    flex-shrink: 0;
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
}

.nav-drawer-handle:active {
    cursor: grabbing;
}

.nav-drawer-handle-bar {
    width: 48px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0;
    transition: background 0.2s ease;
}

.nav-drawer-handle:hover .nav-drawer-handle-bar {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== Drawer Header ===== */
.nav-drawer-header {
    padding: 8px 24px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.nav-drawer-logo {
    display: inline-block;
}

.nav-drawer-logo img {
    height: 28px;
    width: auto;
}

/* Logo theme switching moved to logo-rules.css */

/* ===== Drawer Body ===== */
.nav-drawer-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    overscroll-behavior-x: none;
    padding: 8px 0 env(safe-area-inset-bottom);
    will-change: scroll-position;
}

/* Custom scrollbar */
.nav-drawer-body::-webkit-scrollbar {
    width: 6px;
}

.nav-drawer-body::-webkit-scrollbar-track {
    background: transparent;
}

.nav-drawer-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0;
}

.nav-drawer-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== User Section ===== */
.drawer-user-section {
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.drawer-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.drawer-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    color: var(--color-black);
    flex-shrink: 0;
}

.drawer-user-details {
    flex: 1;
    min-width: 0;
}

.drawer-user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawer-user-email {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Navigation Sections ===== */
.drawer-nav {
    padding: 8px 0;
}

.drawer-section {
    margin-bottom: 8px;
}

.drawer-section-title {
    padding: 12px 24px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.4);
}

/* ===== Drawer Items ===== */
.drawer-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 24px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    font-size: 15px;
    font-family: inherit;
    position: relative;
}

.drawer-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-white);
}

.drawer-item:active {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(0.98);
}

.drawer-item.active {
    color: var(--color-gold);
    background: rgba(204, 153, 51, 0.1);
}

.drawer-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--color-gold);
    border-radius: 0;
}

/* Item components */
.drawer-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.8;
}

.drawer-item:hover .drawer-item-icon {
    opacity: 1;
}

.drawer-item-text {
    flex: 1;
    font-weight: 500;
}

.drawer-item-external {
    opacity: 0.5;
    flex-shrink: 0;
}

/* Primary action button */
.drawer-item-primary {
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-light));
    color: var(--color-black);
    margin: 8px 16px;
    border-radius: 0;
    font-weight: 600;
}

.drawer-item-primary:hover {
    background: linear-gradient(135deg, var(--color-gold-dark), var(--color-gold));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(204, 153, 51, 0.3);
}

/* Theme toggle */
.drawer-theme-toggle .theme-icon-light {
    display: block;
}

.drawer-theme-toggle .theme-icon-dark {
    display: none;
}

[data-theme="light"] .drawer-theme-toggle .theme-icon-light {
    display: none;
}

[data-theme="light"] .drawer-theme-toggle .theme-icon-dark {
    display: block;
}

/* ===== Light Theme ===== */
[data-theme="light"] .nav-drawer-overlay {
    background: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .nav-drawer-content {
    background: rgba(248, 250, 252, 0.98);
}

@supports (backdrop-filter: blur(20px)) {
    [data-theme="light"] .nav-drawer-content {
        background: rgba(248, 250, 252, 0.92);
    }
}

[data-theme="light"] .nav-drawer-handle-bar {
    background: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .nav-drawer-handle:hover .nav-drawer-handle-bar {
    background: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .nav-drawer-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .drawer-section-title {
    color: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .drawer-item {
    color: rgba(0, 0, 0, 0.8);
}

[data-theme="light"] .drawer-item:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--color-black);
}

[data-theme="light"] .drawer-item:active {
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .drawer-item.active {
    background: rgba(204, 153, 51, 0.08);
}

[data-theme="light"] .drawer-user-section {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

/* ===== Body State ===== */
body.drawer-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ===== Responsive ===== */
@media (min-width: 781px) {
    .nav-drawer {
        display: none !important;
    }
}

/* Tablet adjustments */
@media (min-width: 500px) {
    .nav-drawer-content {
        max-width: 480px;
        margin: 0 auto;
    }
}

/* Safe area support for modern devices */
@supports (padding: env(safe-area-inset-bottom)) {
    .nav-drawer-body {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .nav-drawer-overlay,
    .nav-drawer-content,
    .drawer-item {
        transition-duration: 0.01ms !important;
    }
}