/* ============================================
   NAVIGATION REDESIGN - Best-in-Class App Navigation
   ============================================ */

/* ===== CSS VARIABLES FOR NAV ===== */
:root {
    --nav-height: 90px;
    --nav-bg: #ffffff;
    --nav-bg-dark: #0f172a;
    --nav-border: #e5e7eb;
    --nav-text: #374151;
    --nav-text-muted: #6b7280;
    --nav-accent: #005F60;
    --nav-accent-light: rgba(0, 95, 96, 0.1);
    --bottom-nav-height: 72px;
    --sidebar-width: 280px;
}

@media (min-width: 768px) {
    :root {
        --nav-height: 130px;
    }
}

/* ===== HIDE OLD NAVIGATION WHEN LOGGED IN ===== */
body.logged-in #marketing-nav-desktop,
body.logged-in #signInLink-desktop,
body.logged-in #mobile-signin-btn {
    display: none !important;
}

body.logged-in #curator-nav-desktop {
    display: none !important; /* We'll use the new nav instead */
}

/* ===== NEW HEADER FOR LOGGED-IN USERS ===== */
.app-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    height: var(--nav-height);
}

body.logged-in .app-header {
    display: flex;
}

body.logged-in header.header-visible {
    display: none;
}

.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Logo Section */
.app-header-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--nav-text);
}

.app-header-logo img {
    height: 77px !important;
    width: auto !important;
    max-height: none !important;
}

@media (min-width: 768px) {
    .app-header-logo img {
        height: 110px !important;
    }
}

/* Ensure mobile logged-in header shows larger logo */
@media (max-width: 767px) {
    body.logged-in .app-header-logo img {
        height: 77px !important;
    }
}

.app-header-logo-text {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
    display: none;
}

@media (min-width: 768px) {
    .app-header-logo-text {
        display: block;
        font-size: 1.3rem;
    }
}

/* Desktop Navigation */
.app-nav-desktop {
    display: none;
    align-items: center;
    gap: 0.25rem;
}

@media (min-width: 992px) {
    .app-nav-desktop {
        display: flex;
    }
}

.app-nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    color: var(--nav-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
}

.app-nav-item:hover {
    background: var(--nav-accent-light);
    color: var(--nav-accent);
}

.app-nav-item.active {
    background: var(--nav-accent-light);
    color: var(--nav-accent);
}

.app-nav-item i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.app-nav-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Primary Action Button (Desktop) */
.app-nav-cta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--primary);
    color: white !important;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.15s ease;
    margin-left: 0.5rem;
}

.app-nav-cta:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 95, 96, 0.3);
}

/* Header Right Section */
.app-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Scout Points Badge */
.app-scout-badge {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: linear-gradient(135deg, #4fd1c5 0%, #38b2ac 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
}

.app-scout-badge:hover {
    color: white;
    transform: scale(1.02);
}

@media (min-width: 576px) {
    .app-scout-badge {
        display: flex;
    }
}

/* User Menu Button */
.app-user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem;
    padding-right: 0.75rem;
    background: var(--bg-warm);
    border: 1px solid var(--nav-border);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.app-user-btn:hover {
    background: var(--nav-accent-light);
    border-color: var(--nav-accent);
}

.app-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.app-user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--nav-text);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: none;
}

@media (min-width: 768px) {
    .app-user-name {
        display: block;
    }
}

.app-user-chevron {
    color: var(--nav-text-muted);
    font-size: 0.75rem;
    transition: transform 0.15s ease;
}

.app-user-btn[aria-expanded="true"] .app-user-chevron {
    transform: rotate(180deg);
}

/* User Dropdown Menu */
.app-user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    min-width: 280px;
    background: white;
    border: 1px solid var(--nav-border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1001;
}

.app-user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.app-user-dropdown-header {
    padding: 1rem;
    border-bottom: 1px solid var(--nav-border);
}

.app-user-dropdown-email {
    font-size: 0.8rem;
    color: var(--nav-text-muted);
    margin-bottom: 0.75rem;
}

.app-user-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.app-user-stat {
    text-align: center;
    padding: 0.5rem;
    background: var(--bg-warm);
    border-radius: 8px;
}

.app-user-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.app-user-stat-label {
    font-size: 0.65rem;
    color: var(--nav-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.app-user-dropdown-body {
    padding: 0.5rem;
}

.app-user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--nav-text);
    text-decoration: none;
    transition: all 0.15s ease;
}

.app-user-dropdown-item:hover {
    background: var(--nav-accent-light);
    color: var(--nav-accent);
}

.app-user-dropdown-item i {
    width: 20px;
    text-align: center;
    color: var(--nav-text-muted);
}

.app-user-dropdown-item:hover i {
    color: var(--nav-accent);
}

.app-user-dropdown-divider {
    height: 1px;
    background: var(--nav-border);
    margin: 0.5rem 0;
}

.app-user-dropdown-item.danger {
    color: #ef4444;
}

.app-user-dropdown-item.danger i {
    color: #ef4444;
}

/* ===== MOBILE BOTTOM NAVIGATION ===== */
.app-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

body.logged-in .app-bottom-nav {
    display: flex;
}

/* Hide bottom nav on desktop */
@media (min-width: 992px) {
    body.logged-in .app-bottom-nav {
        display: none;
    }
}

.app-bottom-nav-inner {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

.app-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 0.5rem 0.25rem;
    color: #6b7280;
    text-decoration: none;
    transition: all 0.15s ease;
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
}

.app-bottom-nav-item.active {
    color: var(--nav-accent);
}

.app-bottom-nav-item:active {
    transform: scale(0.95);
}

/* Ensure button elements match link styling */
button.app-bottom-nav-item {
    color: #6b7280;
    font-family: inherit;
}

button.app-bottom-nav-item:hover,
button.app-bottom-nav-item:focus {
    color: var(--nav-accent);
    outline: none;
}

.app-bottom-nav-icon {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
    position: relative;
}

.app-bottom-nav-badge {
    position: absolute;
    top: -4px;
    right: -8px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #ef4444;
    color: white;
    font-size: 0.6rem;
    font-weight: 600;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-bottom-nav-label {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Center FAB Button */
.app-bottom-nav-fab {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.app-bottom-nav-fab-btn {
    position: absolute;
    top: -24px;
    width: 56px;
    height: 56px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 95, 96, 0.4);
    text-decoration: none;
    transition: all 0.2s ease;
}

.app-bottom-nav-fab-btn:hover,
.app-bottom-nav-fab-btn:active {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0, 95, 96, 0.5);
    color: white;
}

/* ===== MOBILE MENU OVERLAY REDESIGN ===== */
.app-mobile-menu {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.app-mobile-menu.show {
    opacity: 1;
    visibility: visible;
}

.app-mobile-menu-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 320px;
    background: white;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.app-mobile-menu.show .app-mobile-menu-panel {
    transform: translateX(0);
}

.app-mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--nav-border);
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.app-mobile-menu-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-mobile-menu-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.app-mobile-menu-user-info h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.app-mobile-menu-user-info p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--nav-text-muted);
}

.app-mobile-menu-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-warm);
    border: none;
    border-radius: 50%;
    color: var(--nav-text);
    cursor: pointer;
}

.app-mobile-menu-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-warm);
}

.app-mobile-menu-stat {
    text-align: center;
}

.app-mobile-menu-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.app-mobile-menu-stat-label {
    font-size: 0.7rem;
    color: var(--nav-text-muted);
    text-transform: uppercase;
}

.app-mobile-menu-section {
    padding: 0.5rem 0;
}

.app-mobile-menu-section-title {
    padding: 0.5rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--nav-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.app-mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    color: var(--nav-text);
    text-decoration: none;
    transition: all 0.15s ease;
}

.app-mobile-menu-item:hover,
.app-mobile-menu-item:active {
    background: var(--nav-accent-light);
}

.app-mobile-menu-item.active {
    background: var(--nav-accent-light);
    color: var(--nav-accent);
}

.app-mobile-menu-item i {
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
    color: var(--nav-text-muted);
}

.app-mobile-menu-item.active i,
.app-mobile-menu-item:hover i {
    color: var(--nav-accent);
}

.app-mobile-menu-item-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-mobile-menu-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid var(--nav-border);
}

.app-mobile-menu-signout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem;
    background: #fef2f2;
    color: #ef4444;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.app-mobile-menu-signout:hover {
    background: #fee2e2;
}

/* ===== ADJUST MAIN CONTENT FOR NAV ===== */
body.logged-in #app-root {
    padding-bottom: calc(var(--bottom-nav-height) + 1rem);
}

@media (min-width: 992px) {
    body.logged-in #app-root {
        padding-bottom: 0;
    }
}

/* ===== SCOUT MODE - HIDE NAV ===== */
body.scout-active .app-header,
body.scout-active .app-bottom-nav {
    display: none !important;
}

/* ===== MEMORIAL PAGE - TRANSPARENT HEADER OPTION ===== */
body.memorial-page-active .app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

/* ===== DARK MODE FOR DASHBOARD PAGES ===== */
body.dashboard-page-active .app-header {
    background: var(--nav-bg-dark);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dashboard-page-active .app-header-logo-text,
body.dashboard-page-active .app-nav-item,
body.dashboard-page-active .app-user-name {
    color: rgba(255, 255, 255, 0.9);
}

body.dashboard-page-active .app-nav-item:hover,
body.dashboard-page-active .app-nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

body.dashboard-page-active .app-user-btn {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

body.dashboard-page-active .app-scout-badge {
    background: linear-gradient(135deg, rgba(79, 209, 197, 0.3) 0%, rgba(56, 178, 172, 0.3) 100%);
    border: 1px solid rgba(79, 209, 197, 0.5);
}

body.dashboard-page-active .app-bottom-nav {
    background: var(--nav-bg-dark);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dashboard-page-active .app-bottom-nav-item {
    color: rgba(255, 255, 255, 0.6);
}

body.dashboard-page-active .app-bottom-nav-item.active {
    color: #4fd1c5;
}

/* ===== ANIMATION KEYFRAMES ===== */
@keyframes nav-slide-up {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.app-bottom-nav {
    animation: nav-slide-up 0.3s ease;
}
