/* ===================================================
   SIDEBAR - Menú lateral, tema claro y elegante
   =================================================== */
:root {
    --sb-collapsed: 68px;
    --sb-expanded: 235px;
    --sb-bg: #e8eeff;
    --sb-border: #e8e8f2;
    --sb-accent: #195DFF;
    --sb-text: #3a3a4a;
    --sb-hover-bg: #ffffff;
    --sb-active-bg: #ffffff;
    --sb-transition: 0.28s ease;
    --sb-shadow: 2px 0 16px rgba(25, 93, 255, 0.08);
}

body {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ====== SIDEBAR ====== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sb-collapsed);
    background: var(--sb-bg);
    border-right: 1px solid var(--sb-border);
    box-shadow: var(--sb-shadow);
    transition: width var(--sb-transition);
    z-index: 1040;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar:hover {
    width: var(--sb-expanded);
}

/* ====== BRAND ====== */
.sidebar-brand {
    display: flex;
    align-items: center;
    height: 64px;
    padding: 0 16px;
    border-bottom: 1px solid var(--sb-border);
    flex-shrink: 0;
    white-space: nowrap;
    background: linear-gradient(135deg, #f8faff 0%, #ffffff 100%);
}

.sidebar-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none !important;
}

.sidebar-logo-link img {
    flex-shrink: 0;
}

/* ====== NAV ====== */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--sb-border); border-radius: 4px; }

/* ====== ITEMS ====== */
.sidebar-item {
    display: flex;
    align-items: center;
    padding: 11px 16px;
    color: var(--sb-text);
    text-decoration: none !important;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.18s, color 0.18s, border-left-color 0.18s;
    border-left: 3px solid transparent;
    user-select: none;
}

a.sidebar-item:hover,
.sidebar-group > .sidebar-item:hover {
    background-color: var(--sb-hover-bg);
    color: var(--sb-accent);
    text-decoration: none !important;
}

a.sidebar-item.active {
    background-color: var(--sb-active-bg);
    color: var(--sb-accent);
    border-left-color: var(--sb-accent);
    font-weight: 600;
}

/* ====== ICON ====== */
.sidebar-icon {
    font-size: 19px;
    min-width: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aa8800;
}

/* ====== LABEL ====== */
.sidebar-label {
    font-size: 14px;
    opacity: 0;
    transition: opacity var(--sb-transition);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--sb-text) !important;
}

.sidebar:hover .sidebar-label {
    opacity: 1;
}

/* ====== ARROW ====== */
.sidebar-arrow {
    font-size: 11px;
    opacity: 0;
    transition: opacity var(--sb-transition), transform 0.22s;
    flex-shrink: 0;
    margin-left: 4px;
}

.sidebar:hover .sidebar-arrow {
    opacity: 1;
}

.sidebar-group.open > .sidebar-item .sidebar-arrow {
    transform: rotate(180deg);
}

/* ====== SUBMENU ====== */
.sidebar-group {
    position: relative;
}

.sidebar-submenu {
    background: #e8eeff;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar:hover .sidebar-group.open .sidebar-submenu,
.sidebar-group.open .sidebar-submenu {
    max-height: 500px;
}

/* Sidebar bloqueado abierto cuando hay un submenú activo */
.sidebar.sb-locked {
    width: var(--sb-expanded);
}

.sidebar.sb-locked .sidebar-label,
.sidebar.sb-locked .sidebar-arrow {
    opacity: 1;
}

.sidebar-subitem {
    display: block;
    padding: 9px 16px 9px 52px;
    font-size: 13px;
    color: var(--sb-text);
    text-decoration: none !important;
    white-space: nowrap;
    border-left: 3px solid transparent;
    transition: background-color 0.18s, color 0.18s;
}

.sidebar-subitem:hover {
    background-color: var(--sb-hover-bg);
    color: var(--sb-accent);
}

.sidebar-subitem.active {
    color: var(--sb-accent);
    background-color: var(--sb-active-bg);
    border-left-color: var(--sb-accent);
    font-weight: 600;
}

/* ====== FOOTER ====== */
.sidebar-footer {
    padding: 4px 0;
    border-top: 1px solid var(--sb-border);
    flex-shrink: 0;
    background: #e8eeff;
}

.sidebar-music-item {
    border-left: 3px solid transparent;
    cursor: default !important;
}

.sidebar-music-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
}

/* ====== MAIN WRAPPER ====== */
.main-wrapper {
    margin-left: var(--sb-collapsed);
    padding-top: 64px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ====== DESKTOP TOPBAR ====== */
#desktop-topbar {
    position: fixed;
    top: 0;
    left: var(--sb-collapsed);
    right: 0;
    display: flex;
    align-items: center;
    height: 64px;
    padding: 0 20px;
    background: #e8eeff;
    border-bottom: 1px solid var(--sb-border);
    box-shadow: 0 2px 10px rgba(25, 93, 255, 0.07);
    z-index: 1030;
}

#desktop-topbar-contacts {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    margin-left: auto;
}

.topbar-contact-link {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--sb-accent) !important;
    text-decoration: none !important;
    transition: color 0.18s;
}

.topbar-contact-link:hover {
    color: #0040cc;
}

.topbar-contact-link i {
    font-size: 15px;
}

#desktop-brand-name {
    display: block;
    font-family: space, sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--sb-accent);
    line-height: 1.1;
}

#desktop-brand-sub {
    display: block;
    font-size: 11px;
    color: #888;
    letter-spacing: 0.03em;
}

/* ====== MOBILE TOPBAR ====== */
#mobile-topbar {
    display: none;
}

/* ====== OVERLAY ====== */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1039;
    backdrop-filter: blur(2px);
}

#sidebar-overlay.show {
    display: block;
}

/* ====== RESPONSIVE - MOBILE ====== */
@media (max-width: 767.98px) {
    body {
        flex-direction: column;
    }

    #desktop-topbar {
        display: none;
    }

    #mobile-topbar {
        display: flex;
        align-items: center;
        height: 56px;
        background: #ffffff;
        border-bottom: 1px solid var(--sb-border);
        padding: 0 14px;
        position: sticky;
        top: 0;
        z-index: 1041;
        box-shadow: 0 2px 10px rgba(25, 93, 255, 0.07);
        flex-shrink: 0;
    }

    .sidebar {
        left: calc(-1 * var(--sb-expanded));
        width: var(--sb-expanded) !important;
        transition: left var(--sb-transition);
        z-index: 1045;
    }

    .sidebar:hover {
        width: var(--sb-expanded) !important;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .sidebar .sidebar-label,
    .sidebar .sidebar-arrow {
        opacity: 1 !important;
    }

    .sidebar-group.open .sidebar-submenu {
        max-height: 500px !important;
    }

    .main-wrapper {
        margin-left: 0;
    }
}

/* ====== RESPONSIVE - TABLET ====== */
@media (min-width: 768px) and (max-width: 991.98px) {
    :root {
        --sb-collapsed: 60px;
        --sb-expanded: 215px;
    }
}

/* ====== TOUCH: desactivar hover pegajoso ====== */
body.touch-device .sidebar:hover {
    width: var(--sb-collapsed);
}
body.touch-device .sidebar:hover .sidebar-label,
body.touch-device .sidebar:hover .sidebar-arrow {
    opacity: 0;
}
body.touch-device .sidebar.sb-locked {
    width: var(--sb-expanded);
}
body.touch-device .sidebar.sb-locked .sidebar-label,
body.touch-device .sidebar.sb-locked .sidebar-arrow {
    opacity: 1;
}
