.left-panel {
    display: flex;
    flex-direction: column;
    /* background: var(--bg-secondary); */
    border-right: 1px solid var(--border);
    width: calc(var(--hub-sidebar-width) + var(--sidebar-width));
    font-family: "Quantico", sans-serif;
    transition: width 0.3s ease, opacity 0.25s ease, border-width 0.3s ease;
    overflow: hidden;
    flex-shrink: 1;
}

.left-panel.theme-modern {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(240, 245, 255, 0.7));
}


/* Sidebar uses --unicorn-color directly so the user-picked alpha is honored
   (the panel shows through the background image). The `backdrop-filter: blur`
   was removed from `.modal-overlay` because blurring a region with a
   translucent panel beneath causes flicker on every backdrop repaint. */
.theme-dark-unicorn .left-panel {
    background: linear-gradient(135deg,
            color-mix(in srgb, var(--unicorn-color, #9333ea) 85%, black),
            color-mix(in srgb, var(--unicorn-color, #9333ea) 8%, black));
}


.theme-unicorn .left-panel {
    background: linear-gradient(135deg,
            color-mix(in srgb, var(--unicorn-color, #9333ea) 85%, black),
            color-mix(in srgb, var(--unicorn-color, #9333ea) 60%, black));
}

.left-panel-header {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}


.logo-box {
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-text {
    display: flex;
    align-items: baseline;
    font-family: "Iceland", sans-serif;
    letter-spacing: 1px;
}

.logo-k {
    color: white;
    font-size: 1.65rem;
    font-weight: 400;
}

.logo-yst {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.35rem;
    font-weight: 400;
    margin-left: -2px;
}

.server-selector-wrapper {
    flex: 1;
    position: relative;
}

.sidebar-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    cursor: pointer;
    padding: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sidebar-expand-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.server-selector-btn {
    width: 100%;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
    font-size: 0.8rem;
    font-weight: 500;
}

.server-selector-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.server-selector-arrow {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
}



.server-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
}

.server-dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background 0.15s;
}

.server-dropdown-item:hover {
    background: var(--bg-tertiary);
}

.server-dropdown-item.active {
    background: rgba(51, 122, 234, 0.15);
}

.server-dropdown-item.manage {
    flex-direction: row;
    color: var(--accent);
    font-weight: 500;
}

.server-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.server-item-host {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.server-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.dropdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
}

.sidebar-tabs {
    display: flex;
    padding: 0 8px;
    gap: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}


.sidebar-tab {
    flex: 1;
    padding: 8px 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: #ffffff;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.sidebar-tab:hover:not(.disabled) {
    background: rgba(0, 0, 0, 0.03);
}

.sidebar-tab.active {
    border-bottom-color: #ffffff;
}

.sidebar-tab.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}



.left-panel-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.lib-sidebar {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid var(--border);
}

.theme-unicorn .lib-sidebar {
    border-left-color: rgba(255, 255, 255, 0.1);
}

/* Sidebar Specifics from app.css */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.new-doc-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    margin-bottom: 16px;
    transition: background 0.2s;
}

.new-doc-btn:hover {
    background: var(--accent-hover);
}

.doc-tree {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ============================================
   EXPANDED VIEW - Visão expandida
   ============================================ */

.left-panel.collapsed {
    width: 0;
    opacity: 0;
    border-width: 0;
}

/* Floating button over the main content (mobile hamburger + expanded-view
   restore). Replaces the old main-content-toolbar — no dedicated bar, no
   stolen vertical space. */
.main-float-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    opacity: 0.65;
    cursor: pointer;
    transition: all 0.2s ease;
}

.main-float-btn:hover {
    opacity: 1;
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.main-float-btn:active {
    transform: scale(0.95);
}

.main-float-btn svg {
    width: 14px;
    height: 14px;
}

/* ============================================
   MOBILE HAMBURGER BUTTON
   ============================================ */

.mobile-menu-btn {
    display: none !important;
}

.mobile-sidebar-close {
    display: none;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    /* Hide sidebar by default on mobile */
    .left-panel {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 2000;
        width: calc(var(--hub-sidebar-width) + var(--sidebar-width));
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        opacity: 1;
        background: var(--bg-secondary);
    }

    /* Show sidebar when toggled via mobile-open class */
    .left-panel.mobile-open {
        transform: translateX(0);
    }

    /* Override collapsed state on mobile — collapsed hides it fully */
    .left-panel.collapsed {
        transform: translateX(-100%);
        width: calc(var(--hub-sidebar-width) + var(--sidebar-width));
        opacity: 1;
    }

    /* Overlay behind sidebar when open */
    .mobile-sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1999;
    }

    .mobile-sidebar-overlay.active {
        display: block;
    }

    /* Show hamburger button on mobile */
    .mobile-menu-btn {
        display: flex !important;
    }

    /* Show close button inside sidebar on mobile */
    .mobile-sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 8px;
        right: 8px;
        z-index: 10;
        width: 32px;
        height: 32px;
        border-radius: 6px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        background: rgba(0, 0, 0, 0.3);
        color: rgba(255, 255, 255, 0.8);
        cursor: pointer;
        transition: all 0.2s;
    }

    .mobile-sidebar-close:hover {
        background: rgba(0, 0, 0, 0.5);
        color: white;
    }

    /* Hide the expanded-view restore button on mobile (hamburger replaces it) */
    .main-float-btn.desktop-only {
        display: none;
    }

    /* Hide users panel on mobile */
    .users-panel {
        display: none;
    }
}

/* GLOBAL SEARCH */
.btn-search{
    background: transparent;
    cursor: pointer;
    transition: background 0.2s ease-out;
    /* Tighter than the global .btn so it lines up with the slimmer tabs row. */
    padding: 6px 12px;
}

.btn-search:hover{
    background: #ffffff71;
}

.search-empty{
    padding-left: 1rem;
}

.search-count{
    margin:0px;
    color: var(--text-secondary);
}

.search-group-header{
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border-top: var(--accent-bg) 1px solid;
    padding-left: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-group-title{
    margin: 0px;
    text-transform: uppercase;
    font-family: "Quantico", sans-serif;
}

.search-group-count{
    padding: 0px 20px;
}

.search-results{
}

.search-result-item{
    cursor: pointer;
    user-select: none;
    padding-left: 1rem;
    padding-top: 5px;
    padding-bottom: 5px;
    border-bottom: 1px var(--border) solid;
    margin:0px;
    transition: background-color 0.2s ease-out,opacity 0.2s ease-out;
}

.search-result-item:hover{
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    /* opacity:0.5; */
}

.search-input-wrap{
    width: 100%;
    position: relative;
}

.search-input-wrap::before{
    content: "🔍";
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 16px;
    line-height: 1;
}

.search-input{
    width: 98%;
    height: 2rem;
    background-color: var(--bg-tertiary);
    border-color: var(--text-secondary);
    border: 2px var(--border) solid;
    border-radius: 6px;
    padding: 1.5rem;
    padding-left: 2.75rem;
    transition: border-color 0.15s ease-out;
    font-family: "Quantico", sans-serif;
    display: block;
    font-size: larger;
}

.search-input:focus {
    border-color: var(--accent) !important;
    outline: none;
}

.search-input:focus-visible {
    border-color: var(--accent) !important;
    outline: none;
}