/**
 * /assets/css/sidebar-nav.css
 *
 * Purpose:  Desktop left sidebar navigation with full header integration.
 *           Transforms the bottom tabbar into a vertical sidebar on large screens.
 *           Includes: Logo (top), Tab navigation (middle), Actions + Profile (bottom).
 *           Active pages: admin, gm, character, group (set via body.sidebar-active in JS).
 *           Mobile (< 992px) keeps the bottom tabbar unchanged.
 * Deps:     app.css (CSS variables), app-tabbar.css
 * Load:     index.php
 * Version:  3.3.0 – Separate Badge/Pill fuer GM World (globe, teal)
 */

/* =========================
   CSS Variable for sidebar width
   ========================= */
:root {
    --sidebar-w: 210px;
}

/* =========================
   Sidebar-only elements: hidden by default (mobile)
   ========================= */
.sidebar-brand,
.sidebar-footer,
.sidebar-mode-badge {
    display: none;
}

/* =========================
   Desktop Sidebar (>= 992px)
   Activated via body.sidebar-active (toggled by JS in shell_tabbar.php)
   ========================= */
@media (min-width: 992px) {

    /* --- Sidebar Container --- */
    body.sidebar-active .bottom-tabbar {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        right: auto;
        width: var(--sidebar-w);
        padding: 0;
        z-index: 1025;
        pointer-events: auto;
    }

    /* --- Glass Pill becomes full-height sidebar --- */
    body.sidebar-active .tabbar-glass {
        max-width: none;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
        border-right: 1px solid rgba(255,255,255,0.08);
        background: rgba(14, 17, 22, 0.95);
        backdrop-filter: blur(24px) saturate(1.4);
        -webkit-backdrop-filter: blur(24px) saturate(1.4);
        box-shadow: 2px 0 16px rgba(0,0,0,0.3);
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    /* =========================
       Sidebar Brand (Logo + Mode Badge)
       ========================= */
    body.sidebar-active .sidebar-brand {
        display: flex;
        flex-direction: column;
        align-items: center;
        flex-shrink: 0;
        padding: 20px 12px 12px;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }

    .sidebar-brand__link {
        display: flex;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        width: 100%;
    }

    .sidebar-brand__logo {
        max-width: calc(var(--sidebar-w) - 32px);
        max-height: 52px;
        width: 100%;
        height: auto;
        object-fit: contain;
        opacity: 0.9;
        transition: opacity 0.2s ease;
    }

    .sidebar-brand__link:hover .sidebar-brand__logo {
        opacity: 1;
    }

    /* --- Mode Badge (Admin / GM) --- */
    body.sidebar-active .sidebar-mode-badge {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        margin-top: 8px;
        padding: 3px 10px;
        border-radius: 6px;
        font-size: 0.65rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    .sidebar-mode-badge--admin {
        background: rgba(255,107,107,0.12);
        color: var(--danger, #ff6b6b);
        border: 1px solid rgba(255,107,107,0.3);
    }

    .sidebar-mode-badge--gm {
        background: rgba(255,211,107,0.12);
        color: var(--gold, #ffd36b);
        border: 1px solid rgba(255,211,107,0.3);
    }

    .sidebar-mode-badge--gm-world {
        background: rgba(93,214,201,0.12);
        color: var(--accent, #5dd6c9);
        border: 1px solid rgba(93,214,201,0.3);
    }

    /* --- Tab Badge (e.g. "API" for Icons tab) --- */
    .sidebar-tab-badge {
        display: inline-flex;
        align-items: center;
        padding: 1px 5px;
        margin-left: 4px;
        border-radius: 4px;
        font-size: 0.55rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        background: rgba(93,214,201,0.12);
        color: var(--accent, #5dd6c9);
        border: 1px solid rgba(93,214,201,0.25);
        line-height: 1.2;
        vertical-align: middle;
    }

    /* =========================
       Tab Container (vertical)
       ========================= */
    body.sidebar-active .tabbar-inner {
        display: flex;
        flex-direction: column;
        height: auto;
        flex: 1 1 auto;
        overflow-x: hidden;
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: rgba(255,255,255,0.1) transparent;
        padding: 8px 0;
        gap: 2px;
        cursor: default;
    }

    body.sidebar-active .tabbar-inner::-webkit-scrollbar {
        width: 4px;
    }

    body.sidebar-active .tabbar-inner::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.1);
        border-radius: 2px;
    }

    /* --- Tab items become horizontal rows (icon + label) --- */
    body.sidebar-active .bottom-tabbar .nav-link {
        flex: 0 0 auto;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        gap: 10px;
        min-width: 0;
        width: 100%;
        padding: 10px 16px;
        border-radius: 0;
        transition: color 0.2s ease, background 0.2s ease;
    }

    /* --- Icon in sidebar --- */
    body.sidebar-active .bottom-tabbar .nav-link i {
        font-size: 1rem;
        width: 20px;
        text-align: center;
        flex-shrink: 0;
    }

    /* --- Custom SVG Icon in sidebar --- */
    body.sidebar-active .bottom-tabbar .nav-link .tabbar-custom-icon {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    /* --- Label always visible in sidebar --- */
    body.sidebar-active .bottom-tabbar .nav-link .lbl {
        opacity: 1;
        max-height: none;
        font-size: 0.78rem;
        font-weight: 500;
        text-transform: none;
        letter-spacing: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* --- Left-line indicator (replaces top-line) --- */
    body.sidebar-active .bottom-tabbar .nav-link::before {
        top: 50%;
        left: 0;
        width: 3px;
        height: 24px;
        border-radius: 0 2px 2px 0;
        transform: translateY(-50%) scaleY(0);
        transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    body.sidebar-active .bottom-tabbar .nav-link.active::before {
        transform: translateY(-50%) scaleY(1);
    }

    /* --- Hover state --- */
    body.sidebar-active .bottom-tabbar .nav-link:hover {
        color: rgba(255,255,255,0.75);
        background: rgba(255,255,255,0.04);
    }

    /* --- Active state --- */
    body.sidebar-active .bottom-tabbar .nav-link.active {
        color: #fff;
        background: rgba(93, 214, 201, 0.08);
    }

    body.sidebar-active .bottom-tabbar .nav-link.active i {
        transform: none;
    }

    /* --- Hide scroll arrows + fades in sidebar mode --- */
    body.sidebar-active .tabbar-scroll-arrow,
    body.sidebar-active .tabbar-glass::before,
    body.sidebar-active .tabbar-glass::after {
        display: none !important;
    }

    /* --- Disable scroll hint animation --- */
    body.sidebar-active .tabbar-inner.scroll-hint {
        animation: none;
    }

    /* =========================
       Sidebar Footer (Actions + Profile)
       ========================= */
    body.sidebar-active .sidebar-footer {
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
        border-top: 1px solid rgba(255,255,255,0.06);
    }

    /* --- Action Buttons Row (Dice, Notifications, Admin) --- */
    .sidebar-actions {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255,255,255,0.04);
    }

    .sidebar-actions__btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 8px;
        border: none;
        background: transparent;
        color: rgba(255,255,255,0.45);
        font-size: 0.95rem;
        cursor: pointer;
        transition: color 0.2s, background 0.2s;
        position: relative;
        text-decoration: none;
    }

    .sidebar-actions__btn:hover {
        color: rgba(255,255,255,0.85);
        background: rgba(255,255,255,0.06);
    }

    .sidebar-actions__badge {
        position: absolute;
        top: 2px;
        right: 2px;
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        background: var(--danger, #ff6b6b);
        color: #fff;
        font-size: 0.6rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
        line-height: 1;
    }

    /* --- Profile Section --- */
    .sidebar-profile {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
    }

    .sidebar-profile__link {
        display: flex;
        align-items: center;
        gap: 8px;
        text-decoration: none;
        color: var(--text, #e6edf3);
        flex: 1 1 auto;
        min-width: 0;
        border-radius: 8px;
        padding: 4px 6px;
        transition: background 0.2s;
    }

    .sidebar-profile__link:hover {
        background: rgba(255,255,255,0.04);
        color: var(--text, #e6edf3);
    }

    .sidebar-profile__avatar {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        object-fit: cover;
        border: 2px solid rgba(93,214,201,0.3);
        flex-shrink: 0;
    }

    .sidebar-profile__avatar--initials {
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, rgba(93,214,201,0.25), rgba(176,140,255,0.25));
        font-size: 12px;
        font-weight: 800;
        color: rgba(255,255,255,0.75);
    }

    .sidebar-profile__info {
        flex: 1 1 auto;
        min-width: 0;
    }

    .sidebar-profile__name {
        display: block;
        font-size: 0.75rem;
        font-weight: 600;
        color: rgba(255,255,255,0.8);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar-profile__logout {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        border-radius: 6px;
        color: rgba(255,255,255,0.3);
        text-decoration: none;
        transition: color 0.2s, background 0.2s;
        flex-shrink: 0;
    }

    .sidebar-profile__logout:hover {
        color: var(--danger, #ff6b6b);
        background: rgba(255,107,107,0.08);
    }

    /* =========================
       Layout: Push content right, hide header
       ========================= */
    body.sidebar-active .spa-content {
        margin-left: var(--sidebar-w);
        padding-bottom: 24px;
    }

    /* Header hidden — sidebar replaces it */
    body.sidebar-active .spa-header {
        display: none !important;
    }

    /* Remove bottom padding (no longer bottom bar) */
    body.sidebar-active.body-with-tabbar {
        padding-bottom: 0;
    }
}

/* =========================
   Notification Dropdown (moved to body in sidebar mode)
   ========================= */
@media (min-width: 992px) {
    body > .header-notif-dropdown {
        position: fixed !important;
        bottom: 70px;
        left: calc(var(--sidebar-w) + 8px);
        right: auto !important;
        top: auto !important;
        z-index: 10060;
    }
}

/* =========================
   Mobile Mode Pill (GM / Admin indicator in bottom tabbar)
   Visible only in mobile bottom tabbar, hidden in sidebar mode.
   ========================= */
.tabbar-mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    margin: auto 2px auto 0;
    border-radius: 1rem;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1;
}
.tabbar-mode-pill i {
    font-size: 0.6rem;
}
.tabbar-mode-pill--gm {
    background: rgba(255,211,107,0.15);
    color: var(--gold, #ffd36b);
    border: 1px solid rgba(255,211,107,0.3);
}
.tabbar-mode-pill--admin {
    background: rgba(255,107,107,0.15);
    color: var(--danger, #ff6b6b);
    border: 1px solid rgba(255,107,107,0.3);
}
.tabbar-mode-pill--gm-world {
    background: rgba(93,214,201,0.15);
    color: var(--accent, #5dd6c9);
    border: 1px solid rgba(93,214,201,0.3);
}

/* Hide mode pill in sidebar mode (sidebar has its own badge) */
@media (min-width: 992px) {
    body.sidebar-active .tabbar-mode-pill {
        display: none;
    }
}

/* =========================
   Reduced Motion
   ========================= */
@media (prefers-reduced-motion: reduce) {
    body.sidebar-active .bottom-tabbar .nav-link,
    body.sidebar-active .bottom-tabbar .nav-link::before {
        transition: none;
    }
}
