/**
 * Layout Styles - Page Structure Components
 * ~280 lines | Navbar, sub-navigation, containers
 * 
 * TABLE OF CONTENTS (search "--- SECTION:"):
 * -------------------------------------------
 * NAVBAR       line 15     Top navigation bar with glassmorphism
 * USERMENU     line 55     Profile dropdown menu
 * SUBNAV       line 135    Secondary tabs/pills navigation
 * CONTAINERS   line 230    Main content containers and grid
 */

/* --- SECTION: NAVBAR --- */
.navbar {
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    --navbar-pill-font-size: clamp(0.72rem, 0.20vw + 0.66rem, 0.85rem);
    --navbar-pill-pad-y: clamp(0.34rem, 0.18vw + 0.30rem, 0.42rem);
    --navbar-pill-pad-x: clamp(0.52rem, 0.45vw + 0.40rem, 0.80rem);
    --navbar-pill-gap: clamp(0.24rem, 0.40vw + 0.12rem, 0.50rem);
}

.navbar-content {
    max-width: var(--container-width);
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: clamp(0.85rem, 4vw, 1.125rem);
    color: var(--text-primary);
    letter-spacing: -0.01em;
    white-space: nowrap;
    min-width: 0;
    overflow: hidden;
}

.brand > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand svg { 
    color: #06b6d4; 
    width: clamp(18px, 5vw, 24px);
    height: clamp(18px, 5vw, 24px);
    flex-shrink: 0;
    filter: drop-shadow(0 0 6px rgba(6, 182, 212, 0.4));
}

.brand .brand-suffix {
    font-weight: 400;
    opacity: 0.6;
    font-size: 0.9em;
}

.navbar-module-context {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: fit-content;
}

@media (max-width: 1360px) {
    .navbar-content { gap: 0.6rem; }
}

@media (max-width: 1180px) {
    .brand {
        flex: 1 1 auto;
        min-width: 0;
    }

    .brand > span,
    .brand .brand-suffix {
        display: inline;
        font-size: 0.82em;
        opacity: 0.62;
    }
}

/* Share navbar (public links) */
.navbar.navbar-share {
    height: auto; /* allow wrapping on small screens */
    min-height: var(--header-height);
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.navbar-content.navbar-content-share {
    display: flex; /* override grid layout */
    justify-content: space-between;
    align-items: flex-start;
}

.share-brand {
    cursor: default;
    min-width: 0;
    flex: 1 1 auto;
}

.share-brand .brand-text { min-width: 0; }

/* Prevent "Shared: <label>" from overflowing on mobile */
.share-brand .brand-subtitle {
    max-width: 100%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.share-navbar-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 0 0 auto;
}

.pill.share-expires-pill {
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

@media (max-width: 720px) {
    .navbar-content.navbar-content-share {
        flex-wrap: wrap;
        row-gap: 0.5rem;
    }

    .share-navbar-meta {
        width: 100%;
        justify-content: flex-start;
    }
}

/* --- SECTION: USERMENU --- */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-menu-trigger,
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.user-menu-trigger svg,
.user-avatar svg {
    width: 18px;
    height: 18px;
}

.user-menu-trigger:hover,
.user-menu-trigger:focus-visible,
.user-avatar:hover,
.user-avatar:focus-visible,
.user-menu.show .user-menu-trigger,
.user-menu.show .user-avatar {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(247, 147, 26, 0.3);
    transform: translateY(-1px);
}

.user-menu-trigger:focus-visible,
.user-avatar:focus-visible { outline: none; }
.user-menu-trigger:active,
.user-avatar:active { transform: translateY(1px); }

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 220px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.25);
    padding: 0.3rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px) scale(0.98);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0.16s;
    z-index: 120;
}

.user-menu.show .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    transition-delay: 0s;
}

.dropdown-header {
    padding: 0.75rem 0.85rem 0.6rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0.35rem;
}

.dropdown-header-sm {
    padding: 0.6rem 0.85rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.dropdown-user-name {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.2;
}

.dropdown-user-email {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 0.3rem 0.5rem;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 40px;
    padding: 0 0.85rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
    margin-bottom: 2px;
}

.dropdown-item:last-child { margin-bottom: 0; }
.dropdown-item svg { width: 16px; height: 16px; color: var(--text-secondary); transition: color 0.15s; }

.dropdown-item:hover,
.dropdown-item:focus-visible {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-primary);
}

.dropdown-item:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.35);
}

.dropdown-item:hover svg,
.dropdown-item:focus-visible svg { color: var(--text-primary); }

.dropdown-item.active {
    background: rgba(247, 147, 26, 0.12);
    color: var(--primary);
    border-left: 3px solid var(--primary);
    padding-left: calc(0.85rem - 3px);
}

.dropdown-item.active svg { color: var(--primary); }

.dropdown-item.danger { color: #ef4444; }
.dropdown-item.danger svg { color: #ef4444; }
.dropdown-item.danger:hover { background: rgba(239, 68, 68, 0.12); color: #f87171; }
.dropdown-item.danger:hover svg { color: #f87171; }
.dropdown-item.danger:focus-visible {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.35);
}
.dropdown-item.danger:focus-visible svg { color: #f87171; }

/* Mobile quick module navigation (generated from user menu links) */
.mobile-bottom-nav {
    display: none;
}

/* --- SECTION: SUBNAV --- */
.sub-nav {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 0 1.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 2rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: relative;
}

.sub-nav::-webkit-scrollbar { display: none; }

.sub-nav-content {
    max-width: var(--container-width);
    margin: 0 auto;
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 0;
    width: 100%;
}

.nav-pill {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.nav-pill:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.nav-pill.active {
    color: var(--primary);
    background: var(--primary-soft);
}

.nav-pill-toggle {
    display: none;
    margin-left: auto;
    padding: 0.5rem;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* Sub-nav mobile styles */
@media (max-width: 768px) {
    .sub-nav {
        margin: 0;
        padding: 0;
        border: none;
        height: 0;
        overflow: visible;
        z-index: 1000;
    }
    
    .sub-nav-content {
        display: none;
        flex-direction: column;
        position: fixed;
        top: var(--header-height);
        z-index: 1000;
        left: 0;
        right: 0;
        background: var(--bg-body);
        border-bottom: 1px solid var(--border-light);
        padding: 0.5rem 1rem 1rem 1rem;
        box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
        gap: 0.5rem;
        height: auto;
        width: 100%;
    }

    .sub-nav-content.open { display: flex; }

    .nav-pill {
        width: 100%;
        text-align: left;
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        background: var(--bg-surface);
        border: 1px solid var(--border-light);
        color: var(--text-primary);
        border-radius: var(--radius-md);
        justify-content: flex-start;
    }

    .nav-pill:hover,
    .nav-pill:active {
        background: var(--bg-surface-hover);
        border-color: var(--text-secondary);
    }
    
    .nav-pill.active {
        background: var(--primary-soft);
        color: var(--primary);
        border-color: var(--primary);
    }

    .nav-pill-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px; 
        height: 38px; 
        padding: 0;
        border-radius: var(--radius-sm);
        border: 1px solid var(--border-light); 
        background: var(--bg-surface); 
    }

    .user-menu .dropdown-menu {
        width: min(280px, 92vw);
    }
    .dropdown-item {
        min-height: 44px;
        padding: 0 0.85rem;
        font-size: 0.9rem;
    }
}

@media (min-width: 769px) {
    .sub-nav {
        position: sticky;
        top: var(--header-height);
        z-index: 40;
        background: var(--bg-body);
        margin-top: -1px;
    }

    .sub-nav-content {
        display: flex !important;
        flex-direction: row !important;
        position: static !important;
        box-shadow: none !important;
        background: transparent !important;
        border: none !important;
        padding: 0.75rem 0 !important;
        justify-content: center;
    }
}

/* --- SECTION: CONTAINERS --- */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem 2rem;
    width: 100%;
}

.dashboard-container {
    margin-top: 4rem;
}

.hero h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Mobile container adjustments */
@media (max-width: 640px) {
    .navbar { padding: 0 1rem; }
    .main-container { padding: 0 0.9rem 1.25rem; }
    .navbar-content { 
        min-height: 64px; 
        align-items: center; 
        gap: 0.5rem;
    }
    .grid { grid-template-columns: 1fr; }
    .dashboard-container { margin-top: 1rem; padding-bottom: 2rem; }

    .brand { gap: 0.5rem; } /* Tighter gap on mobile */

    .sub-nav.sub-nav-mobile { 
        display: block; 
        height: auto !important;
        min-height: 1px;
        padding: 0 1rem; 
        position: relative;
        z-index: 1100;
    }
    
    .sub-nav.sub-nav-mobile .sub-nav-content { 
        display: none; 
        flex-direction: column; 
        gap: 0.4rem; 
        padding: 0.5rem;
        background: var(--bg-surface);
        border: 1px solid var(--border-light);
        border-radius: var(--radius-md);
        margin-top: 0.5rem;
        width: 260px;
        position: fixed;
        top: var(--header-height);
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
        z-index: 1100;
    }
    
    .sub-nav.sub-nav-mobile .sub-nav-content.open { display: flex; }
    
    .sub-nav.sub-nav-mobile .nav-pill { 
        justify-content: flex-start; 
        width: 100%;
        text-align: left;
    }

    .user-menu .dropdown-menu {
        width: min(240px, 92vw);
        right: 0;
        left: auto;
    }

}

@media (max-width: 768px) {
    body.has-mobile-bottom-nav {
        padding-bottom: calc(var(--mobile-bottom-nav-height, 68px) + env(safe-area-inset-bottom, 0px) + 0.85rem);
    }

    .mobile-bottom-nav {
        position: fixed;
        left: 0.8rem;
        right: 0.8rem;
        bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
        z-index: 90;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
        gap: 0.35rem;
        padding: 0.4rem;
        border-radius: 14px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        background: rgba(10, 10, 15, 0.9);
        backdrop-filter: blur(18px);
        box-shadow: 0 14px 28px rgba(0, 0, 0, 0.42);
    }

    .mobile-bottom-nav-item {
        min-width: 0;
        min-height: 46px;
        border: 1px solid transparent;
        border-radius: 10px;
        background: transparent;
        color: var(--text-secondary);
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.01em;
        line-height: 1.2;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.12rem;
        padding: 0.28rem 0.2rem;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        cursor: pointer;
        transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
    }

    .mobile-bottom-nav-item svg {
        width: 15px;
        height: 15px;
        color: inherit;
        flex-shrink: 0;
    }

    .mobile-bottom-nav-item:hover,
    .mobile-bottom-nav-item:focus-visible {
        background: rgba(148, 163, 184, 0.14);
        color: var(--text-primary);
        border-color: rgba(148, 163, 184, 0.22);
        outline: none;
    }

    .mobile-bottom-nav-item.active {
        background: var(--primary-soft);
        color: var(--primary);
        border-color: rgba(247, 147, 26, 0.42);
    }

    .mobile-bottom-nav-item.active svg {
        color: var(--primary);
    }

    .mobile-bottom-nav-label {
        display: block;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Utilities */
.section { display: none; }
.section.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
