/* ================================================
   SIDEBAR NAVIGATION - VERSIÓN ORIGINAL CON GRADIENTE GUINDO
   ================================================ */

:root {
    --sidebar-width: 70px;
    --sidebar-expanded-width: 320px;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--color-guindo-dark) 0%, var(--color-guindo-primary) 100%);
    transition: width 0.3s ease, transform 0.3s ease;
    z-index: 1000;
    overflow: visible;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

/* DESKTOP: Hover para expandir sidebar - SOLO EN DESKTOP */
@media (min-width: 769px) {
    .sidebar:hover {
        width: var(--sidebar-expanded-width);
    }

    .sidebar:hover .sidebar-nav {
        overflow-y: auto;
    }

    .sidebar:hover .nav-item:hover .nav-submenu {
        max-height: 400px;
    }
}

/* ================================================
   SIDEBAR HEADER - LOGO DUAL MEJORADO
   ================================================ */

.sidebar-header {
    padding: 20px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: flex-start;
    align-items: center;
    min-height: 70px;
}

/* Centrar header cuando sidebar está expandido */
.sidebar:hover .sidebar-header,
.sidebar.mobile-open .sidebar-header {
    justify-content: center;
    text-align: center;
}

.sidebar-logo {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    text-decoration: none;
}

.sidebar-logo:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.6);
}

.sidebar-logo:active {
    transform: scale(0.95);
}

/* Expandir logo cuando sidebar está expandido */
.sidebar:hover .sidebar-logo,
.sidebar.mobile-open .sidebar-logo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
}

/* ================================================
   LOGOS - MINIMALISTA Y COMPLETO
   ================================================ */

.sidebar-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    top: 0;
    left: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Logo Minimalista - Visible por defecto */
.sidebar-logo-mini {
    opacity: 1;
    visibility: visible;
    transform: scale(1) rotate(0deg);
}

/* Logo Completo - Oculto por defecto */
.sidebar-logo-full {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) rotate(-10deg);
}

/* Cuando sidebar está expandido */
.sidebar:hover .sidebar-logo-mini,
.sidebar.mobile-open .sidebar-logo-mini {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) rotate(10deg);
}

.sidebar:hover .sidebar-logo-full,
.sidebar.mobile-open .sidebar-logo-full {
    opacity: 1;
    visibility: visible;
    transform: scale(1) rotate(0deg);
}

/* Efecto de brillo al hacer hover */
.sidebar-logo::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.3), transparent);
    transition: all 0.3s ease;
    z-index: -1;
}

.sidebar-logo:hover::before {
    width: 150%;
    height: 150%;
}

/* Animación de pulso sutil */
@keyframes subtle-pulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 0 2px 12px rgba(255, 215, 0, 0.3);
    }
}

.sidebar:hover .sidebar-logo,
.sidebar.mobile-open .sidebar-logo {
    animation: subtle-pulse 3s infinite;
}

/* ================================================
   NAVEGACIÓN
   ================================================ */

.sidebar-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    padding: 20px 0;
    list-style: none;
    flex: 1;
    overflow: hidden;
    overflow-x: hidden;
}

/* Personalizar scrollbar del menú */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.5);
    border-radius: 2px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.7);
}

.sidebar-nav > ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* ================================================
   ITEMS DEL MENÚ
   ================================================ */

.nav-item {
    position: relative;
    margin-bottom: 5px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 15px 15px;
    color: var(--color-white);
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    position: relative;
}

.nav-link:hover {
    background-color: rgba(255, 215, 0, 0.1);
    color: var(--color-dorado-accent);
}

.nav-link.active {
    background-color: rgba(255, 215, 0, 0.2);
    color: var(--color-dorado-accent);
    border-left: 4px solid var(--color-dorado-accent);
}

/* Mantener indicador visual cuando sidebar está contraído */
.sidebar:not(:hover) .nav-link.active {
    border-left: 4px solid var(--color-dorado-accent);
}

.sidebar:not(:hover) .nav-link.active .nav-icon {
    color: var(--color-dorado-accent);
}

.nav-icon {
    min-width: 40px;
    font-size: 18px;
    text-align: center;
}

.nav-text {
    margin-left: 15px;
    font-weight: 500;
    flex: 1;
}

.nav-arrow {
    font-size: 12px;
    transition: all 0.3s ease;
    margin-left: auto;
    opacity: 0;
}

.sidebar:hover .nav-arrow {
    opacity: 1;
}

.nav-item.expanded .nav-arrow {
    transform: rotate(180deg);
}

/* ================================================
   SUBMENU
   ================================================ */

.nav-submenu {
    background-color: rgba(0, 0, 0, 0.3);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    list-style: none;
    padding: 0;
    margin: 0;
}

/* DESKTOP: Expandir en hover */
.nav-item:hover .nav-submenu {
    max-height: 400px;
}

.nav-submenu-link {
    padding: 10px 20px 10px 75px;
    color: #ccc;
    text-decoration: none;
    display: block;
    transition: all 0.3s ease;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.nav-submenu-link:hover {
    color: var(--color-dorado-accent);
    background-color: rgba(255, 215, 0, 0.05);
    border-left-color: var(--color-dorado-accent);
}

.nav-submenu-link.active {
    color: var(--color-dorado-accent);
    background-color: rgba(255, 215, 0, 0.1);
    border-left-color: var(--color-dorado-accent);
}

/* ================================================
   FOOTER DEL SIDEBAR
   ================================================ */

.sidebar-footer {
    padding: var(--spacing-md);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    max-height: 0;
    overflow: hidden;
}

.sidebar:hover .sidebar-footer,
.sidebar.mobile-open .sidebar-footer {
    opacity: 1;
    visibility: visible;
    max-height: 100px;
}

.sidebar-footer-text {
    font-size: var(--font-size-xs);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    line-height: 1.4;
}

/* ================================================
   MOBILE MENU
   ================================================ */

.sidebar-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: var(--color-guindo-primary);
    color: var(--color-dorado-accent);
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 1002;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.sidebar-toggle:hover {
    background: var(--color-dorado-accent);
    color: var(--color-guindo-primary);
    transform: scale(1.1);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: none;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ================================================
   AJUSTE DEL CONTENIDO PRINCIPAL
   ================================================ */

.main-content {
    position: relative;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* ================================================
   RESPONSIVE - TABLET Y MÓVIL
   ================================================ */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%) !important;
        width: var(--sidebar-expanded-width);
    }

    .sidebar.mobile-open {
        transform: translateX(0) !important;
    }

    .sidebar.active {
        transform: translateX(0) !important;
    }

    .sidebar-header {
        padding: 10px;
        min-height: 50px;
    }

    .sidebar-logo {
        width: 25px;
        height: 25px;
    }

    .sidebar.mobile-open .sidebar-logo {
        width: 40px;
        height: 40px;
    }

    /* Ocultar footer en móvil para ahorrar espacio */
    .sidebar-footer {
        display: none !important;
    }

    /* Mostrar elementos siempre en móvil */
    .sidebar.mobile-open .nav-section-title,
    .sidebar.mobile-open .nav-arrow {
        opacity: 1;
        visibility: visible;
        max-height: 100px;
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    /* Click para expandir submenus en móvil - reducir altura para que quepan mejor */
    .nav-item.expanded .nav-submenu {
        max-height: 300px;
        overflow-y: auto;
    }

    /* Reducir padding de items de menú para ahorrar espacio */
    .nav-link {
        padding: 10px 15px;
    }

    .nav-submenu-link {
        padding: 8px 15px 8px 45px;
    }
}

@media (max-width: 480px) {
    .sidebar-logo {
        width: 25px;
        height: 25px;
    }

    .sidebar.mobile-open .sidebar-logo {
        width: 40px;
        height: 40px;
    }
}

/* ================================================
   ACCESIBILIDAD
   ================================================ */

.sidebar-logo:focus-visible {
    outline: 3px solid var(--color-dorado-accent);
    outline-offset: 3px;
    border-radius: 50%;
}

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
    .sidebar-logo,
    .sidebar-header,
    .sidebar,
    .nav-link,
    .nav-submenu {
        transition: none !important;
        animation: none !important;
    }
}
