﻿/* Sidebar tooltip (moved out of _Sidebar.cshtml <style> block). */
.sidebar-item.has-tooltip { position: relative; }
.sidebar-tooltip {
    position: fixed;
    background: #1f2937;
    color: #ffffff;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    z-index: var(--phs-z-sidebar-rail);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.sidebar-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #1f2937;
}

/* ============================================
   FLOATING SIDEBAR STYLES - COMPLETE VERSION
   ============================================ */

/* Sidebar container — full viewport height, docked left (above page chrome) */
.floating-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1060;
    transition: var(--phs-transition);
    overflow-x: visible;
    overflow-y: visible;
}

/* Material Symbols in Sidebar */
.sidebar-icon .material-symbols-rounded {
    color: #a1a5b7 !important;
    font-size: 1.125rem !important;
}

.sidebar-inner {
    background: var(--phs-ink-primary, #181c32);
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: var(--app-sidebar-rail-width, 72px);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    padding-top: var(--app-header-height, 60px);
}

.sidebar-logo {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--app-sidebar-rail-width, 72px);
    height: var(--app-header-height, 60px);
    min-height: var(--app-header-height, 60px);
    max-height: var(--app-header-height, 60px);
    box-sizing: border-box;
    background-color: #1e1e2d;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1062;
    margin: 0;
}

    .sidebar-logo img {
        max-width: 44px;
        max-height: calc(var(--app-header-height, 60px) - 16px);
        width: auto;
        height: auto;
        object-fit: contain;
        display: block;
    }

.sidebar-items-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    /* Breathing room between the logo rail and the first item (Home). */
    padding: 24px 4px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
}

    /* Custom scrollbar styling */
    .sidebar-items-container::-webkit-scrollbar {
        width: 6px;
    }

    .sidebar-items-container::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05);
        border-radius: 3px;
    }

    .sidebar-items-container::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 3px;
    }

        .sidebar-items-container::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.3);
        }

/* Firefox scrollbar */
.sidebar-items-container {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.05);
}

/* When the JS overflow manager is active, never show a scrollbar — items that do not
   fit are moved into the "More" flyout instead. (Class is added by JS so a scrollbar
   remains as a graceful fallback if the script fails to run.) */
.sidebar-items-container.sb-overflow-managed {
    overflow: hidden;
}

/* "More" overflow chevron — hidden until items overflow the rail height */
.sidebar-more-toggle .sidebar-icon i {
    transition: transform 0.2s ease;
}
.sidebar-more-toggle[aria-expanded="true"] .sidebar-icon i {
    transform: rotate(90deg);
}

/* Flyout panel that holds the overflowed rail items (a mini vertical rail) */
.sidebar-overflow-flyout {
    position: fixed;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    background: var(--phs-ink-primary, #181c32);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px 6px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.35);
    z-index: 1061;
    min-width: var(--app-sidebar-rail-width, 72px);
    max-height: calc(100vh - 24px);
}
.sidebar-overflow-flyout .sidebar-item {
    width: 60px;
}

/* Sidebar Items */
.sidebar-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    width: 100%;
    padding: 2px 4px;
    z-index: 1;
    overflow: visible !important;
    flex-shrink: 0;
    cursor: pointer;
}

.sidebar-label {
    display: block;
    width: 100%;
    max-width: 88px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    color: #a1a5b7;
    letter-spacing: 0.01em;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

.sidebar-item:hover .sidebar-label,
.sidebar-item:focus-within .sidebar-label {
    color: #e4e6ef;
}

.sidebar-item.active .sidebar-label {
    color: #ffffff;
}

.sidebar-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s ease, opacity 0.2s ease;
    border: none;
    position: relative;
}

    .sidebar-icon i {
        font-size: 1.125rem !important;
        line-height: 1;
        color: #a1a5b7 !important;
        transition: color 0.2s ease, opacity 0.2s ease;
        opacity: 1 !important;
    }

    .sidebar-icon i svg {
        width: 1em !important;
        height: 1em !important;
        vertical-align: -0.0625em;
    }


.floating-sidebar .popup-link i {
    color: #64748b !important;
}

.floating-sidebar .popup-link:hover i {
    color: #667eea !important;
}


.sidebar-icon:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: none;
}

    .sidebar-icon:hover i {
        color: #e4e6ef !important;
    }

/* Active — Figma-style filled pill behind icon (no left edge line) */
.sidebar-item.active .sidebar-icon {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.55) 0%, rgba(118, 75, 162, 0.6) 100%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

    .sidebar-item.active .sidebar-icon i {
        color: #ffffff !important;
    }

[data-theme="dark"] .sidebar-item.active .sidebar-icon {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.45) 0%, rgba(118, 75, 162, 0.5) 100%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* Hover Popup - Maximum visibility */
.sidebar-popup {
    position: fixed !important;
    background: #ffffff;
    border-radius: 16px;
    min-width: 300px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
    padding: 0;
    padding-bottom: 8px;
    display: none;
    z-index: var(--phs-z-editor-dialog) !important;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    isolation: isolate;
}

.popup-header {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 14px 16px;
    margin-left: 0;
    background: #2F3246;
    color: #ffffff;
    border-radius: 16px 16px 0 0;
    border-bottom: 1px solid #e5e7eb;
    text-align: center;
}

.popup-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin: 4px 8px;
    border-radius: 10px;
    color: #475569;
    text-decoration: none;
    transition: var(--phs-transition);
    font-size: 0.875rem;
    font-weight: 500;
}

    .popup-link i {
        width: 20px;
        min-width: 20px;
        font-size: 1.125rem !important;
        line-height: 1;
        color: rgba(0, 0, 0, 0.3) !important;
    }

    .popup-link i svg {
        width: 1em !important;
        height: 1em !important;
        vertical-align: -0.0625em;
    }

    .popup-link:hover {
        background: #f1f5f9;
        color: #1e293b;
        transform: translateX(2px);
    }

    .popup-link:hover i {
        color: #667eea;
    }

/* Nested configuration submenu */
.popup-link-group {
    position: relative;
}

.popup-link-parent {
    cursor: pointer;
}

.popup-link-parent .popup-chevron {
    margin-left: auto;
    font-size: 0.75rem !important;
    width: auto !important;
    min-width: auto !important;
    color: #94a3b8 !important;
    transition: transform 0.2s ease, color 0.2s ease;
}

.popup-link-parent:hover .popup-chevron,
.popup-link-parent.is-open .popup-chevron,
.popup-link-parent:focus .popup-chevron {
    color: #667eea !important;
}

.sidebar-subpopup {
    position: fixed !important;
    background: #ffffff;
    border-radius: 16px;
    min-width: 300px;
    max-width: 340px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
    padding: 0;
    padding-bottom: 8px;
    display: none;
    z-index: 1000000 !important;
    border: 1px solid #e5e7eb;
}

[data-theme="dark"] .sidebar-subpopup {
    background: #1e293b;
    border-color: #374151;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

/* Dark theme support */
[data-theme="dark"] .sidebar-popup {
    background: #1e293b;
    border-color: #374151;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

    [data-theme="dark"] .sidebar-popup::before {
        background: #1e293b;
        border-color: #374151;
    }

[data-theme="dark"] .popup-link {
    color: #cbd5e1;
}

    /* Light mode fixes the icon at rgba(0,0,0,0.3); the dark block never re-colored
       it, so the flyout menu icons stayed near-black on the dark menu. Mirror the
       light pattern with white (5.6:1 on the #1e293b popup - clears the 3:1 floor). */
    [data-theme="dark"] .popup-link i {
        color: rgba(255, 255, 255, 0.55) !important;
    }

    [data-theme="dark"] .popup-link:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #ffffff;
    }

    [data-theme="dark"] .popup-link:hover i {
        color: #c7d2fe !important;
    }

/* Main content: left clears rail; right is minimal — quick-links panel floats over content */
body.sidebar-enabled .app-wrapper {
    padding-left: var(--app-sidebar-content-offset, calc(var(--app-sidebar-rail-width, 72px) + 1rem));
    padding-right: 1rem;
    transition: padding-left 0.3s ease;
}

[data-theme="dark"] .sidebar-inner {
    /* Match the dark chrome (header #0f0f1e, body #1a1a2e) instead of a
       saturated royal blue that fought the rest of the theme. */
    background: #12121f;
}

[data-theme="dark"] .sidebar-icon i {
    color: #a1a5b7 !important;
}

[data-theme="dark"] .sidebar-icon:hover i {
    color: #e4e6ef !important;
}

[data-theme="dark"] .sidebar-item.active .sidebar-icon i {
    color: #ffffff !important;
}

[data-theme="dark"] .sidebar-label {
    color: #a1a5b7;
}

[data-theme="dark"] .sidebar-item:hover .sidebar-label,
[data-theme="dark"] .sidebar-item:focus-within .sidebar-label {
    color: #e4e6ef;
}

[data-theme="dark"] .sidebar-item.active .sidebar-label {
    color: #ffffff;
}

[data-theme="dark"] .sidebar-items-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .sidebar-items-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

    [data-theme="dark"] .sidebar-items-container::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.25);
    }

/* The sidebar entrance slide (slideInLeft) was removed: this is a full-page-reload app,
   so it replayed on every navigation and read as the whole left menu sliding in each time. */

/* Responsive Design */
@media (max-width: 1400px) {
    .sidebar-items-container {
        /* Keep the logo-to-Home breathing room at narrower widths too. */
        padding: 24px 3px 12px;
        gap: 16px;
    }

    .sidebar-icon {
        width: 44px;
        height: 44px;
    }

        .sidebar-icon i {
            font-size: 1.125rem !important;
        }
}

@media (max-width: 1200px) {
    .sidebar-icon {
        width: 42px;
        height: 42px;
    }

        .sidebar-icon i {
            font-size: 1.125rem !important;
        }

    .sidebar-items-container {
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .floating-sidebar {
        left: 10px;
        bottom: 20px;
        top: auto;
        transform: none;
    }

    .sidebar-inner {
        flex-direction: row;
        padding: 10px;
        gap: 18px;
        border-radius: 0;
        height: auto;
        width: auto;
    }

    .sidebar-logo {
        display: none;
    }

    .sidebar-items-container {
        flex-direction: row;
        padding: 0;
        gap: 12px;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .sidebar-item {
        flex: 0 0 auto;
        min-width: 72px;
        padding: 2px 6px;
    }

    .sidebar-label {
        font-size: 0.5625rem;
        max-width: 72px;
    }

    .sidebar-icon {
        width: 36px;
        height: 36px;
        border-radius: 0;
    }

        .sidebar-icon i {
            font-size: 1.125rem !important;
        }

    .sidebar-popup::before {
        left: 50%;
        bottom: -7px;
        top: auto;
        transform: translateX(-50%) rotate(45deg);
    }

    body.sidebar-enabled .app-wrapper {
        padding-left: 20px;
        padding-right: 20px;
        padding-bottom: 80px;
    }
}
