/**
 * Shared Navigation Component Styles
 * Used across all pages for 100% visual consistency
 */

/* Top Navigation Bar */
.top-nav {
    background: var(--bg-secondary);
    border-bottom: 0.25px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1001;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Navigation Container */
.nav-tabs {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
    padding: 0.5rem 1rem;
    overflow: hidden; /* Prevent any scrolling in nav bar */
}

/* Om Icon / App Logo */
.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px; /* Touch target */
    min-height: 44px; /* Touch target */
    padding: 0.5rem;
    text-decoration: none;
    transition: opacity 0.2s;
}

.nav-icon:hover {
    opacity: 0.8;
}

.nav-icon:focus-visible {
    outline: 2px solid #a78bfa;
    outline-offset: 2px;
    border-radius: 0.25rem;
}

.nav-icon svg {
    height: 32px;
    width: 32px;
}

/* Dropdown Container */
.nav-dropdown {
    position: relative;
    display: flex;
    align-items: center;
}

/* Dropdown Trigger Button */
.nav-dropdown-trigger {
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    min-height: 44px; /* Touch target */
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.nav-dropdown-trigger:hover {
    background-color: rgba(167, 139, 250, 0.1);
    color: #a78bfa;
}

.nav-dropdown-trigger:focus-visible {
    outline: 2px solid #a78bfa;
    outline-offset: 2px;
}

.nav-dropdown-trigger.active {
    background-color: rgba(167, 139, 250, 0.15);
    color: #a78bfa;
}

/* Dropdown Arrow */
.dropdown-arrow {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.nav-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

/* Body-Level Dropdown Menus (attached to body, escape all clipping) */
.body-level-menu {
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 0.5rem 0;
    display: none;
    opacity: 0;
    visibility: hidden;
    z-index: 999999; /* ABOVE EVERYTHING - body level */
    transition: opacity 0.15s, visibility 0.15s;
}

/* Legacy class for backward compatibility - same styling */
.nav-dropdown-menu.body-level-menu {
    /* Inherits all body-level-menu styles */
}

/* Dropdown Menu Item */
.nav-dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    min-height: 44px; /* Touch target */
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.95rem;
}

.nav-dropdown-item:hover {
    background-color: rgba(167, 139, 250, 0.1);
    color: #a78bfa;
}

.nav-dropdown-item:focus-visible {
    outline: 2px solid #a78bfa;
    outline-offset: -2px;
}

/* User Menu (Profile) */
.user-menu {
    margin-left: auto; /* Push to right */
    position: relative;
    display: flex;
    align-items: center;
    z-index: 9999;
}

/* Profile Button */
.profile-btn {
    width: 44px; /* Touch target */
    height: 44px; /* Touch target */
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 2px solid var(--border);
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1; /* Ensure text is vertically centered */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.profile-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.3);
}

.profile-btn:focus-visible {
    outline: 2px solid #a78bfa;
    outline-offset: 2px;
}

/* Profile Dropdown (body-level rendering) */
.profile-dropdown.body-level-menu {
    /* Inherits body-level-menu styling */
    padding: 0.75rem 0;
}

/* Profile Email */
.profile-email {
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
    word-break: break-all;
}

/* Profile Menu Item */
.profile-menu-item {
    display: block;
    padding: 0.75rem 1rem;
    min-height: 44px; /* Touch target */
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.95rem;
}

.profile-menu-item:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.profile-menu-item:focus-visible {
    outline: 2px solid #a78bfa;
    outline-offset: -2px;
}

/* Responsive Breakpoints */

/* Mobile: 320px - 374px (iPhone SE, small phones) */
@media (max-width: 374px) {
    .nav-tabs {
        gap: 0.2rem;
        padding: 0.5rem 0.35rem;
        /* NO overflow - let it compress/wrap naturally */
    }

    .nav-dropdown-trigger {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }

    .nav-icon {
        min-width: 40px;
        min-height: 40px;
        padding: 0.35rem;
    }

    .nav-icon svg {
        height: 26px;
        width: 26px;
    }

    .profile-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        line-height: 1; /* Ensure text is vertically centered on mobile */
    }

    /* Prevent dropdown overflow on very narrow screens */
    .nav-dropdown-menu {
        max-width: calc(100vw - 2rem);
        left: auto;
        right: 0;
    }

    .nav-dropdown:first-of-type .nav-dropdown-menu {
        left: 0;
        right: auto;
    }
}

/* Mobile: 375px - 389px (iPhone standard) */
@media (min-width: 375px) and (max-width: 389px) {
    .nav-tabs {
        gap: 0.35rem;
        padding: 0.5rem 0.75rem;
    }
}

/* Mobile: 390px - 767px (iPhone Pro, large phones) */
@media (min-width: 390px) and (max-width: 767px) {
    .nav-tabs {
        gap: 0.4rem;
        padding: 0.5rem 1rem;
    }
}

/* Tablet: 768px+ */
@media (min-width: 768px) {
    .nav-dropdown-menu {
        min-width: 220px;
    }
}

/* Desktop: 1024px+ */
@media (min-width: 1024px) {
    .nav-tabs {
        gap: 0.75rem;
        padding: 0.5rem 1.5rem;
    }

    .nav-dropdown-trigger {
        padding: 0.75rem 1.25rem;
    }
}
