﻿/* ========================================
   CSS Variables & Theme Support
   ======================================== */

:root {
    --brand: #0071e3;
    --bg: #f5f5f7;
    --text: #1d1d1f;
    --muted: #6e6e73;
    --card: #ffffff;
    --border: rgba(0,0,0,.08);
    --shadow: 0 2px 8px rgba(0,0,0,.08);
    --nav-bg: rgba(255,255,255,.95);
    --nav-border: var(--border);
    --success: #10b981;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111214;
        --text: #f5f5f7;
        --muted: #a1a1aa;
        --card: #181a1f;
        --border: rgba(255,255,255,.12);
        --shadow: 0 2px 8px rgba(0,0,0,.35);
        --brand: #4da3ff;
        --nav-bg: rgba(24,26,31,.85);
    }
}

/* Manual theme override */
[data-theme="light"] {
    --brand: #0071e3;
    --bg: #f5f5f7;
    --text: #1d1d1f;
    --muted: #6e6e73;
    --card: #ffffff;
    --border: rgba(0,0,0,.08);
    --shadow: 0 2px 8px rgba(0,0,0,.08);
    --nav-bg: rgba(255,255,255,.95);
}

[data-theme="dark"] {
    --bg: #111214;
    --text: #f5f5f7;
    --muted: #a1a1aa;
    --card: #181a1f;
    --border: rgba(255,255,255,.12);
    --shadow: 0 2px 8px rgba(0,0,0,.35);
    --brand: #4da3ff;
    --nav-bg: rgba(24,26,31,.85);
}

body {
    background: var(--bg);
    color: var(--text);
}

/* ========================================
   Main Navigation
   ======================================== */

.main-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
}

[data-theme="dark"] .main-nav {
    background: rgba(24,26,31,.85);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: 64px;
    gap: 20px;
}

/* ========================================
   Logo
   ======================================== */

.logo {
    justify-self: start;
    display: flex;
    gap: 8px;
    align-items: center;
    text-decoration: none;
    color: var(--brand);
    font-weight: 600;
    font-size: 18px;
    transition: opacity 0.2s;
}

    .logo:hover {
        opacity: 0.8;
    }

    .logo svg {
        width: 22px;
        height: 22px;
    }

/* ========================================
   Navigation Center Links
   ======================================== */

.nav-center {
    justify-self: center;
    display: flex;
    gap: 24px;
}

.nav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 12px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    box-sizing: initial;
}

    .nav-link:hover {
        color: var(--text);
        background: rgba(0,0,0,.04);
    }

[data-theme="dark"] .nav-link:hover {
    background: rgba(255,255,255,.06);
}

/* Desktop: Active state with background */
.nav-link.active {
    color: #fff;
    background: var(--brand);
}

/* Icon and text visibility - Desktop */
.nav-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    stroke-width: 2;
    display: none;
}

.nav-icon-filled {
    display: none;
}

.nav-text {
    display: inline;
}



/* ========================================
   Navigation Right Side
   ======================================== */

.nav-right {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-signin {
    padding: 5px 10px !important;
}

/* ========================================
   Search Box (for future use)
   ======================================== */

.search-box {
    position: relative;
}

.search-input {
    background: var(--bg);
    border: none;
    border-radius: 20px;
    padding: 8px 12px 8px 34px;
    width: 200px;
    font-size: 14px;
    color: var(--text);
    transition: all 0.2s;
}

    .search-input:focus {
        outline: none;
        width: 240px;
        background: var(--card);
        box-shadow: 0 2px 8px rgba(0,0,0,.08);
    }

    .search-input::placeholder {
        color: var(--muted);
    }

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

[data-theme="dark"] .search-input {
    background: rgba(255,255,255,.06);
    color: var(--text);
}

    [data-theme="dark"] .search-input:focus {
        background: var(--card);
    }

/* ========================================
   User Menu & Avatar
   ======================================== */

.user-menu {
    position: relative;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    padding: 0;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
}

    .user-avatar:hover {
        transform: scale(1.05);
        box-shadow: 0 4px 8px rgba(0,0,0,.15);
    }

    .user-avatar:focus {
        outline: none;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
    }

    .user-avatar:active {
        transform: scale(0.95);
    }

/* ========================================
   Menu Component (replaces old .dropdown)
   ======================================== */

.menu {
    position: relative;
}

    .menu.open .menu-pop {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

.menu-pop {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,.12);
    padding: 4px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
}

[data-theme="dark"] .menu-pop {
    background: var(--card);
    box-shadow: 0 4px 24px rgba(0,0,0,.4);
}

/* Menu Items */
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

    .menu-item:hover {
        background: var(--bg);
    }

    .menu-item:focus {
        outline: none;
        background: var(--bg);
    }

    .menu-item:active {
        transform: scale(0.98);
    }

[data-theme="dark"] .menu-item:hover,
[data-theme="dark"] .menu-item:focus {
    background: rgba(255,255,255,.08);
}

.menu-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 2;
}

/* Menu Divider */
.menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* Logout Menu Item (special styling) */
.menu-item--logout {
    width: 100%;
    text-align: left;
}

/* ========================================
   Toast Notifications
   ======================================== */

.item-menu-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--success);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    z-index: 9999;
    font-size: 14px;
    font-weight: 500;
    animation: toastSlideIn 0.3s ease;
}

.item-menu-toast--error {
    background: #ef4444;
}

@keyframes toastSlideIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    cursor: pointer;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

    .btn-primary:hover {
        filter: brightness(1.1);
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(0,0,0,.15);
    }

    .btn-primary:active {
        transform: translateY(0);
    }

/* ========================================
   Page Content
   ======================================== */

.page-content {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 16px;
    box-shadow: var(--shadow);
}

/* ========================================
   Breadcrumbs
   ======================================== */

.cb-breadcrumbs {
    max-width: 1200px;
    margin: 8px auto 0;
    padding: 0 16px;
}

    .cb-breadcrumbs ol {
        align-items: center;
        list-style: none;
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        padding: 0;
        margin: 0;
    }

    .cb-breadcrumbs .crumb {
        display: flex;
        align-items: center;
        color: var(--muted);
        font-size: 14px;
    }

        .cb-breadcrumbs .crumb a {
            color: inherit;
            text-decoration: none;
            transition: color 0.2s;
            font-weight: 600;
        }

            .cb-breadcrumbs .crumb a:hover {
                color: var(--text);
                text-decoration: underline;
            }

        .cb-breadcrumbs .crumb.current span {
            color: var(--text);
            font-weight: 600;
            display: inline-flex;
            align-items: center;
            line-height: 1;
        }

        .cb-breadcrumbs .crumb:not(:last-child)::after {
            content: "/";
            margin-left: 8px;
            color: var(--muted);
        }

    .cb-breadcrumbs .owner-chip {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 4px 12px 4px 4px;
        background: color-mix(in oklab, var(--brand), var(--card) 70%);
        color: #fff;
        border-radius: 20px;
        text-decoration: none;
        transition: opacity 0.2s;
    }

        .cb-breadcrumbs .owner-chip:hover {
            opacity: 0.85;
            text-decoration: none !important;
        }

    .cb-breadcrumbs .owner-avatar {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        overflow: hidden;
        object-fit: cover;
    }

    .cb-breadcrumbs .owner-name {
        font-size: 12px;
        color: #fff;
        text-decoration: none;
        display: inline-flex;
        align-items: center;
    }

/* ========================================
   Responsive Design - Mobile Navigation
   ======================================== */

@media (max-width: 768px) {
    .main-nav {
        padding: 0 16px;
    }

    .nav-container {
        grid-template-columns: auto 1fr auto; /* Logo+tabs, spacer, right */
        height: 56px;
        gap: 0;
    }

    .logo {
        font-size: 16px;
        justify-self: start;
    }

    /* Tabs near logo */
    .nav-center {
        display: flex;
        gap: 2px;
        justify-self: start;
        margin-left: 12px;
    }

    .nav-right {
        justify-self: end;
        gap: 8px;
    }

    /* Mobile: Show icons, hide text */
    .nav-icon {
        display: block;
    }

    .nav-icon-filled {
        display: none;
    }

    .nav-text {
        display: none;
    }

    /* Nav buttons on mobile */
    .nav-link {
        padding: 6px;
        border-radius: 8px;
        width: 36px;
        height: 36px;
        justify-content: center;
        background: transparent;
    }

        .nav-link:hover {
            background: rgba(255,255,255,.08);
        }

        /* Active state: colored filled icon */
        .nav-link.active {
            background: transparent;
            color: var(--brand);
        }

            /* Switch to filled icon when active */
            .nav-link.active .nav-icon {
                display: none;
            }

            .nav-link.active .nav-icon-filled {
                display: block;
            }

    .nav-icon,
    .nav-icon-filled {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    /* Mobile bell adjustments */
    .nav-bell {
        width: 36px;
        height: 36px;
    }

    .nav-bell-icon {
        width: 20px;
        height: 20px;
    }

    /* User avatar */
    .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .menu-pop {
        right: -8px;
        min-width: 200px;
    }

    .btn {
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* ========================================
   Notification Bell (all screens)
   ======================================== */

.nav-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: var(--muted);
    text-decoration: none;
    transition: all 0.2s;
    padding-right: 4px;
    box-sizing: initial;
}

    .nav-bell--active {
        color: var(--brand);
        background: transparent;
    }

        .nav-bell--active:hover {
            color: var(--brand);
            background: transparent;
        }

    .nav-bell:hover {
        color: var(--text);
        background: rgba(0,0,0,.04);
    }

[data-theme="dark"] .nav-bell:hover {
    background: rgba(255,255,255,.08);
}

/* Bell icon states */
.nav-bell-icon {
    width: 22px;
    height: 22px;
}

.nav-bell-icon--notified {
    display: none;
}

/* When has notifications - swap icons */
.nav-bell.has-notifications .nav-bell-icon {
    display: none;
}

.nav-bell.has-notifications .nav-bell-icon--notified {
    display: block;
}

/* Legacy badge support (optional) */
.nav-bell-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
}

    .nav-bell-badge:empty {
        display: none;
    }

    .nav-bell-badge[data-count]:not([data-count=""]):not([data-count="0"]) {
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        top: 4px;
        right: 4px;
        color: #fff;
        font-size: 10px;
        font-weight: 600;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        .nav-bell-badge[data-count]:not([data-count=""]):not([data-count="0"])::before {
            content: attr(data-count);
        }

@media (max-width: 480px) {
    .main-nav {
        padding: 0 12px;
    }

    .nav-container {
        height: 52px;
    }

    .nav-center {
        margin-left: 8px;
        gap: 0;
    }

    .nav-right {
        gap: 6px;
    }

    .nav-link {
        width: 34px;
        height: 34px;
        padding: 5px;
    }

    .nav-icon,
    .nav-icon-filled {
        width: 20px;
        height: 20px;
    }

    .nav-bell {
        width: 34px;
        height: 34px;
    }

    .nav-bell-icon {
        width: 18px;
        height: 18px;
    }

    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 11px;
    }

    .menu-pop {
        min-width: 180px;
        right: -4px;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .main-nav,
    .user-menu,
    .menu-pop,
    .item-menu-toast {
        display: none !important;
    }
}
