/**
 * YOYAKU Dashboard - Dynamic Sidebar Styles
 * Additional styles for role-based navigation
 */

/* ========================================
   SIDEBAR FOOTER & USER SECTION
   ======================================== */

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Issue #34 — bug-report entry point. Opens the SAME feedback widget with a
   bug framing (the widget already attaches page/console/network context). */
.report-bug-link {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    padding: 8px 10px;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    text-align: center;
}
.report-bug-link:hover {
    color: var(--accent-emphasis);
    border-color: var(--accent-emphasis);
}

.user-section {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tint-soft);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.user-info-sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.user-name-sidebar {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    width: fit-content;
}

.role-badge.badge-admin {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

.role-badge.badge-label {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.role-badge.badge-label-preview {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

/* Sidebar nav literal badge (e.g. ⭐ for admin-only entries) — Phase H 2026-05-08
   Phase I 2026-05-08 fix : !important overrides .nav-item.active parent color
   cascade (label-light.css sets active nav-item color to --accent-hover).
   Without !important, the badge inherits parent color → wrong shade in light mode. */
/* Count badge (e.g. Preorder Gaps "55") — never let it squeeze the label;
   sits flush right of the flex:1 .nav-label. */
.nav-badge {
    flex-shrink: 0;
    margin-left: auto;
}
.nav-badge.nav-badge-literal {
    background: transparent !important;
    color: var(--accent, #c4956a) !important;
    padding: 0.125rem 0.25rem;
    margin-left: auto;
    font-size: 0.95rem;
    line-height: 1;
}
body.label-light .nav-badge.nav-badge-literal {
    color: var(--accent, #5DADE2) !important;
}
/* Active state should not dilute the ⭐ — keep accent regardless */
.nav-item.active .nav-badge.nav-badge-literal,
body.label-light .nav-item.active .nav-badge.nav-badge-literal {
    color: var(--accent) !important;
}

/* ========================================
   HEADER TOP ROW
   ======================================== */

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* ========================================
   VIEW MODE TOGGLE (Admin Only)
   ======================================== */

.view-mode-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 4px;
    color: #a78bfa;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.view-mode-toggle:hover {
    background: rgba(139, 92, 246, 0.25);
    border-color: rgba(139, 92, 246, 0.5);
}

.view-mode-toggle.label-mode {
    background: rgba(251, 191, 36, 0.15);
    border-color: rgba(251, 191, 36, 0.3);
    color: #fbbf24;
}

.view-mode-toggle.label-mode:hover {
    background: rgba(251, 191, 36, 0.25);
    border-color: rgba(251, 191, 36, 0.5);
}

.toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-icon svg {
    width: 12px;
    height: 12px;
}

.toggle-label {
    /* Text label next to icon */
}

.logout-btn-sidebar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.logout-btn-sidebar:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* ========================================
   NAV SEPARATORS
   ======================================== */

.nav-separator {
    margin: 16px 0 8px 0;
    padding: 0 12px;
}

.nav-separator span {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ========================================
   COLORED NAV ITEMS
   ======================================== */

/* Release - Violet */
.nav-item.nav-release:hover,
.nav-item.nav-release.active {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}

/* Packs - Orange */
.nav-item.nav-packs:hover,
.nav-item.nav-packs.active {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

/* Video - Red */
.nav-item.nav-video:hover,
.nav-item.nav-video.active {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* Statements - Blue */
.nav-item.nav-statements:hover,
.nav-item.nav-statements.active {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

/* Docs/CRM - Green */
.nav-item.nav-docs:hover,
.nav-item.nav-docs.active {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

/* Manufacturing - Orange (distinct from packs) */
.nav-item.nav-manufacturing:hover,
.nav-item.nav-manufacturing.active {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
}

/* ========================================
   SIDEBAR RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .sidebar-footer {
        padding: 16px 0;
    }

    .user-section {
        padding: 10px;
    }

    .nav-separator {
        margin: 12px 0 6px 0;
    }
}

/* ========================================
   MOBILE OFF-CANVAS NAVIGATION (issue #22)
   The rail becomes a drawer ≤768px; a body-anchored hamburger + backdrop
   toggle it. Desktop keeps the static sidebar (button hidden, no transform).
   ======================================== */

.yy-nav-toggle,
.yy-nav-backdrop {
    display: none;
}

@media (max-width: 768px) {
    .yy-nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 1200;
        width: 44px;
        height: 44px;
        padding: 0;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm, 8px);
        background: var(--bg-card);
        color: var(--text-primary);
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    }
    .yy-nav-toggle svg {
        width: 22px;
        height: 22px;
    }

    /* Drawer state: slide the rail in, dim the page, lock scroll.
       dashboard.css puts the sidebar back in the page flow on phones
       (position: relative, full width). Translated off-canvas it stayed
       invisible but kept its whole height above every page — a blank band
       of ~480px before the content (2026-10-07). The drawer is an overlay. */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: min(86vw, 320px);
        height: 100vh;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        z-index: 1210;
    }
    body.yy-nav-open .sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
    }

    .yy-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1205;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s ease;
    }
    body.yy-nav-open .yy-nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
    body.yy-nav-open {
        overflow: hidden;
    }

    /* The content already sits at the left edge; with the rail off-canvas the
       desktop left offset would leave a dead gutter on phones. */
    .main-content {
        margin-left: 0 !important;
        /* Clear the fixed menu button (12px + 44px) so it never covers a title. */
        padding-top: 64px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .yy-nav-backdrop {
        transition: none;
    }
}

/* ========================================
   ISSUE #13 v2 — IN-APP NOTIFICATION BELL
   Native <details> menu in the sidebar header (admins only). The panel
   expands in the sidebar flow (no fixed positioning, no overflow clipping).
   ======================================== */

.sidebar-notif-menu {
    position: relative;
    margin-left: auto;
}

.sidebar-notif-menu .notif-bell {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    list-style: none;
}
.sidebar-notif-menu .notif-bell::-webkit-details-marker {
    display: none;
}
.sidebar-notif-menu .notif-bell:hover {
    color: var(--accent-emphasis);
    border-color: var(--border);
}
.sidebar-notif-menu[open] .notif-bell {
    color: var(--accent-emphasis);
    border-color: var(--border);
    background: var(--bg-tint-soft);
}

.sidebar-notif-menu .notif-bell-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.sidebar-notif-menu .notif-badge {
    position: absolute;
    top: -5px;
    right: -7px;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 15px;
    text-align: center;
}

/* Panel expands in-flow below the header row */
.sidebar-notif-menu .notif-panel {
    margin: 6px 0 4px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.sidebar-notif-menu .notif-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.sidebar-notif-menu .notif-panel-title {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.sidebar-notif-menu .notif-mark-all {
    background: transparent;
    border: none;
    padding: 2px 4px;
    color: var(--accent-emphasis);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
}
.sidebar-notif-menu .notif-mark-all:hover {
    text-decoration: underline;
}

.sidebar-notif-menu .notif-list {
    max-height: 260px;
    overflow-y: auto;
}

.sidebar-notif-menu .notif-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.sidebar-notif-menu .notif-item:last-child {
    border-bottom: none;
}
.sidebar-notif-menu .notif-item:hover {
    background: var(--bg-tint-soft);
}
.sidebar-notif-menu .notif-item.is-unread {
    border-left: 2px solid var(--accent);
    padding-left: 8px;
}

.sidebar-notif-menu .notif-title {
    color: var(--text-primary);
    font-size: 0.78rem;
    line-height: 1.35;
    text-decoration: none;
    word-break: break-word;
}
a.sidebar-notif-menu .notif-title:hover,
.sidebar-notif-menu .notif-title:hover {
    color: var(--accent-emphasis);
}

.sidebar-notif-menu .notif-time {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.62rem;
}

.sidebar-notif-menu .notif-empty {
    padding: 14px 10px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: center;
}
