/* =============================================================================
   LAMHA — UNIFIED PUBLIC NAVBAR
   Single owner for the user-facing navbar loaded by layout.master.
   Landing-page body offset remains colocated with the hero motion stylesheet.
   ============================================================================= */

#navbar {
    --navbar-logo-filter: none;

    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: var(--z-toast);
    width: 100%;
    margin: 0;
    padding: var(--space-3) 0 var(--space-2);
    border: 0;
    border-radius: 0;
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--bg-primary) 82%, transparent) 0%,
        color-mix(in srgb, var(--bg-primary) 34%, transparent) 62%,
        transparent 100%
    );
    box-shadow: none;
    transition:
        padding var(--duration-normal) var(--ease-default),
        background-color var(--duration-normal) var(--ease-default),
        border-color var(--duration-normal) var(--ease-default),
        box-shadow var(--duration-normal) var(--ease-default);
}

#navbar .navbar-shell {
    align-items: center;
    justify-content: space-between;
}

#navbar .navbar-actions-zone {
    margin-inline-start: auto;
}

html[data-theme="light"] #navbar {
    --navbar-logo-filter: invert(1) contrast(1.08);
}

#navbar.scrolled {
    background: color-mix(in srgb, var(--bg-primary) 84%, transparent);
    -webkit-backdrop-filter: blur(var(--space-5)) saturate(125%);
    backdrop-filter: blur(var(--space-5)) saturate(125%);
    box-shadow: var(--shadow-lg);
}

#navbar .logo {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, .025);
}

#navbar .logo img {
    width: 29px;
    height: 29px;
    object-fit: contain;
    filter: var(--navbar-logo-filter);
    transition: filter var(--duration-normal) var(--ease-default), opacity var(--duration-fast) var(--ease-default);
}

#navbar .unified-search-bar {
    min-height: 44px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    background: color-mix(in srgb, var(--bg-primary) 42%, transparent);
    -webkit-backdrop-filter: blur(var(--radius-lg)) saturate(120%);
    backdrop-filter: blur(var(--radius-lg)) saturate(120%);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
}

#navbar .unified-search-bar:focus-within {
    border-color: var(--border-focus);
    background: color-mix(in srgb, var(--bg-secondary) 72%, transparent);
    box-shadow: var(--input-focus-shadow), var(--shadow-md);
}

/* =============================================================================
   PAGE-LEVEL NAVBAR ACTIONS
   ============================================================================= */

#navbar .gallery-layout-switcher {
    direction: ltr;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    background: color-mix(in srgb, var(--bg-primary) 54%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    backdrop-filter: blur(14px) saturate(120%);
    box-shadow: var(--shadow-xs);
}

#navbar .gallery-layout-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition:
        background-color var(--duration-fast) var(--ease-default),
        color var(--duration-fast) var(--ease-default),
        transform var(--duration-fast) var(--ease-default),
        box-shadow var(--duration-fast) var(--ease-default);
}

#navbar .gallery-layout-button:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

#navbar .gallery-layout-button:active {
    transform: scale(.94);
}

#navbar .gallery-layout-button:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

#navbar .gallery-layout-button.is-active,
#navbar .gallery-layout-button[aria-pressed="true"] {
    color: var(--text-inverse);
    background: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

#navbar .gallery-layout-button :is(svg, i) {
    width: 17px;
    height: 17px;
    stroke-width: 1.8;
}

/* =============================================================================
   ACCOUNT / NOTIFICATIONS
   ============================================================================= */

#navbar .notification-bell,
#navbar .user-dropdown {
    position: relative;
}

#navbar .notif-btn,
#navbar .user-btn {
    border: 1px solid transparent;
    background: transparent;
    transition:
        background-color var(--duration-fast) var(--ease-default),
        border-color var(--duration-fast) var(--ease-default),
        color var(--duration-fast) var(--ease-default),
        transform var(--duration-fast) var(--ease-default);
}

#navbar .notif-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
}

#navbar .notif-btn :is(i, svg) {
    width: 18px;
    height: 18px;
    stroke-width: 1.7;
}

#navbar .notif-btn:hover,
#navbar .notification-bell:has(.notif-dropdown.show) .notif-btn,
#navbar .user-btn:hover,
#navbar .user-btn.active {
    border-color: var(--border-subtle);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

#navbar :is(.notif-btn, .user-btn, .dropdown-item-custom, .notif-item):focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

#navbar .notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    border: 2px solid var(--bg-primary);
    border-radius: var(--radius-full);
    background: var(--danger);
    color: var(--color-white);
    font-size: 9px;
    font-weight: var(--font-bold);
    line-height: 1;
    box-shadow: var(--shadow-sm);
}

#navbar .user-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 42px;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    cursor: pointer;
}

#navbar .user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    overflow: hidden;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
}

#navbar .user-avatar img,
#navbar .notif-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#navbar .user-name {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    white-space: nowrap;
}

#navbar .user-btn:hover .user-name,
#navbar .user-btn.active .user-name {
    color: var(--text-primary);
}

#navbar .notif-dropdown,
#navbar .dropdown-menu-custom {
    position: absolute;
    z-index: var(--z-dropdown);
    top: calc(100% + var(--space-3));
    left: 0;
    right: auto;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    background: var(--bg-navbar);
    box-shadow: var(--shadow-xl);
    -webkit-backdrop-filter: blur(24px) saturate(125%);
    backdrop-filter: blur(24px) saturate(125%);
    opacity: 0;
    visibility: hidden;
    transform: translate3d(0, -8px, 0) scale(.985);
    transform-origin: top left;
    transition:
        opacity var(--duration-fast) var(--ease-out),
        visibility var(--duration-fast) var(--ease-out),
        transform var(--duration-fast) var(--ease-out);
}

#navbar .notif-dropdown::before,
#navbar .dropdown-menu-custom::before {
    content: '';
    position: absolute;
    z-index: 2;
    top: 0;
    left: var(--space-5);
    width: var(--space-10);
    height: 1px;
    background: var(--gradient-brand);
    opacity: .45;
    pointer-events: none;
}

#navbar .notif-dropdown.show,
#navbar .dropdown-menu-custom.show {
    opacity: 1;
    visibility: visible;
    transform: translate3d(0, 0, 0) scale(1);
}

#navbar .notif-dropdown {
    width: min(380px, calc(100vw - var(--space-6)));
    min-width: 0;
    padding: var(--space-2);
}

#navbar .notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 54px;
    padding: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
}

#navbar .notif-list {
    max-height: min(390px, 58vh);
    margin-top: var(--space-1);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border-default) transparent;
}

#navbar .notif-list::-webkit-scrollbar { width: 6px; }
#navbar .notif-list::-webkit-scrollbar-track { background: transparent; }
#navbar .notif-list::-webkit-scrollbar-thumb {
    border-radius: var(--radius-full);
    background: var(--border-default);
}

#navbar .notif-list > .notif-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: var(--space-3);
    min-height: 64px;
    margin: var(--space-1) 0;
    padding: var(--space-3);
    border: 0;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    text-align: right;
    background: transparent;
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-default), transform var(--duration-fast) var(--ease-default);
}

#navbar .notif-list > .notif-item:hover {
    background: var(--bg-elevated);
    transform: translateX(-2px);
}

#navbar .notif-list > .notif-item.unread {
    background: var(--accent-secondary-muted);
    box-shadow: inset -2px 0 0 var(--accent-primary);
}

#navbar .notif-list > .notif-item.unread:hover { background: var(--accent-muted); }

#navbar .notif-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    overflow: hidden;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: var(--shadow-xs);
}

#navbar .notif-text {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: var(--font-regular);
    line-height: var(--line-height-relaxed);
}

#navbar .notif-item.unread .notif-text {
    color: var(--text-primary);
    font-weight: var(--font-medium);
}

#navbar .notif-time {
    margin-top: var(--space-1);
    color: var(--text-muted);
    font-size: 11px;
}

#navbar .notif-list > div:not(.notif-item) {
    display: grid;
    place-items: center;
    min-height: 150px;
    padding: var(--space-8) var(--space-4) !important;
    border-radius: var(--radius-lg);
    color: var(--text-muted) !important;
    background: var(--bg-secondary);
}

#navbar .dropdown-menu-custom {
    width: 248px;
    min-width: 248px;
    padding: var(--space-2);
}

#navbar .dropdown-item-custom {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 46px;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: var(--font-medium);
    text-align: right;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-default), color var(--duration-fast) var(--ease-default), transform var(--duration-fast) var(--ease-default);
}

#navbar .dropdown-item-custom :is(i, svg) {
    box-sizing: border-box;
    width: 30px;
    height: 30px;
    padding: 6px;
    flex: 0 0 30px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-muted);
    stroke-width: 1.7;
    transition: var(--transition-fast);
}

#navbar .dropdown-item-custom:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    transform: translateX(-2px);
}

#navbar .dropdown-item-custom:hover :is(i, svg) {
    border-color: var(--border-default);
    color: var(--text-primary);
}

/* Appearance switch ------------------------------------------------------ */

#navbar .theme-toggle-item {
    align-items: center;
    text-align: start;
}

#navbar .theme-toggle-copy {
    min-width: 0;
    flex: 1;
    display: grid;
    gap: 1px;
}

#navbar .theme-toggle-copy strong {
    color: inherit;
    font-size: 13px;
    font-weight: var(--font-medium);
    line-height: 1.3;
}

#navbar .theme-toggle-copy small {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: var(--font-regular);
    line-height: 1.35;
}

#navbar .theme-toggle-switch {
    direction: ltr;
    position: relative;
    width: 40px;
    height: 23px;
    flex: 0 0 40px;
    padding: 3px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    box-shadow: inset 0 1px 2px color-mix(in srgb, var(--color-black) 8%, transparent);
    transition:
        background-color var(--duration-normal) var(--ease-default),
        border-color var(--duration-normal) var(--ease-default),
        box-shadow var(--duration-normal) var(--ease-default);
}

#navbar .theme-toggle-switch__thumb {
    width: 15px;
    height: 15px;
    display: block;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    box-shadow: var(--shadow-sm);
    transform: translateX(0);
    transition:
        transform var(--duration-normal) var(--ease-out),
        background-color var(--duration-normal) var(--ease-default);
}

html[data-theme="light"] #navbar .theme-toggle-switch {
    border-color: var(--border-strong);
    background: var(--text-primary);
}

html[data-theme="light"] #navbar .theme-toggle-switch__thumb {
    background: var(--text-inverse);
    transform: translateX(17px);
}

#navbar .theme-toggle-item:active .theme-toggle-switch__thumb {
    width: 17px;
}

#navbar .dropdown-divider-custom {
    height: 1px;
    margin: var(--space-2) var(--space-1);
    background: var(--border-subtle);
}

#navbar .dropdown-menu-custom form { margin: 0; }

#navbar .dropdown-menu-custom form .dropdown-item-custom:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

#navbar .dropdown-menu-custom form .dropdown-item-custom:hover :is(i, svg) {
    border-color: var(--danger-border);
    background: var(--danger-bg);
    color: var(--danger);
}

@media (max-width: 768px) {
    #navbar .logo {
        margin-left: 4px;
    }

    #navbar .user-name {
        display: none;
    }

    #navbar .notif-dropdown {
        position: fixed;
        top: calc(var(--navbar-height-mobile) + var(--space-2));
        right: var(--space-3);
        left: var(--space-3);
        width: auto;
        max-width: none;
        max-height: calc(100dvh - var(--navbar-height-mobile) - var(--space-6));
        transform-origin: top center;
    }

    #navbar .dropdown-menu-custom {
        top: calc(100% + var(--space-2));
        width: min(260px, calc(100vw - var(--space-6)));
        min-width: 0;
    }

    #navbar .user-btn { padding: var(--space-1); }
}

@media (prefers-reduced-motion: reduce) {
    #navbar :is(.notif-dropdown, .dropdown-menu-custom, .notif-list > .notif-item, .dropdown-item-custom, .gallery-layout-button, .theme-toggle-switch, .theme-toggle-switch__thumb) {
        transition: none;
        transform: none;
    }

    #navbar .logo img {
        transition: none;
    }

    html[data-theme="light"] #navbar .theme-toggle-switch__thumb {
        transform: translateX(17px);
    }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    #navbar.scrolled,
    #navbar .unified-search-bar,
    #navbar .gallery-layout-switcher {
        background: var(--bg-secondary);
    }
}
