/* ===== RESET Y BASE MOBILE-FIRST ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    transition: all 0.3s ease;
    position: relative;
}

/* ===== BOTÓN ABRIR SIDEBAR - MOBILE FIRST ===== */
.open-sidebar-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 10000;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border: none;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0.25rem 0.9375rem rgba(52, 152, 219, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.open-sidebar-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0.375rem 1.25rem rgba(52, 152, 219, 0.6);
}

.open-sidebar-btn .material-icons {
    font-size: 1.5rem;
}

/* ===== BOTÓN CERRAR SIDEBAR ===== */
.close-sidebar-btn {
    position: absolute;
    top: 0.9375rem;
    right: 0.9375rem;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 0.125rem 0.5rem rgba(231, 76, 60, 0.3);
    z-index: 1001;
}

.close-sidebar-btn:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 0.25rem 0.9375rem rgba(231, 76, 60, 0.5);
}

/* ===== SIDEBAR - MOBILE FIRST ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: -15.625rem; /* -250px */
    width: 15.625rem; /* 250px */
    height: 100vh;
    background: linear-gradient(145deg, #2c3e50 0%, #34495e 50%, #2c3e50 100%);
    box-shadow: 0.25rem 0 1.25rem rgba(0, 0, 0, 0.3);
    z-index: 9999;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.25rem;
}

.sidebar::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        45deg,
        rgba(52, 152, 219, 0.1) 0%,
        rgba(155, 89, 182, 0.1) 100%
    );
    pointer-events: none;
}

.sidebar.show {
    left: 0;
}

/* Estados del sidebar */
body.sidebar-hidden .sidebar {
    left: -15.625rem; /* -250px */
}

/* Mostrar botón SOLO cuando sidebar está oculto */
body.sidebar-hidden .open-sidebar-btn {
    display: flex;
}

/* Ocultar botón cuando sidebar está visible */
body:not(.sidebar-hidden) .open-sidebar-btn {
    display: none !important;
}

/* ===== OVERLAY PARA MÓVILES ===== */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* ===== LOGO ===== */
.logo img {
    max-width: 100%;
    width: 12.5rem; /* 200px */
    height: auto;
    border-radius: 0.75rem;
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.logo img:hover {
    transform: scale(1.05);
    box-shadow: 0 0.375rem 1.5625rem rgba(0, 0, 0, 0.4);
}

/* ===== MENÚ PRINCIPAL ===== */
.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar ul li {
    position: relative;
    margin: 0.3125rem 0;
    border-radius: 0.625rem;
    overflow: visible;
    transition: all 0.3s ease;
}

.sidebar ul li:hover {
    transform: translateX(0.3125rem);
}

.sidebar ul li a,
.sidebar ul li strong {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.25rem;
    color: #ecf0f1;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    z-index: 1;
    border-radius: 0.625rem;
    min-height: 2.75rem; /* 44px - touch friendly */
}

.sidebar ul li a::before,
.sidebar ul li strong::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    transition: all 0.4s ease;
    z-index: -1;
    border-radius: 0.625rem;
}

.sidebar ul li:hover a::before,
.sidebar ul li:hover strong::before {
    left: 0;
}

.sidebar ul li.active {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    box-shadow: 0 0.25rem 0.9375rem rgba(52, 152, 219, 0.3);
    border-radius: 0.625rem;
}

.sidebar ul li.active a,
.sidebar ul li.active strong {
    color: white;
    font-weight: 600;
}

.sidebar ul li .material-icons {
    margin-right: 0.75rem;
    font-size: 1.25rem;
    transition: all 0.3s ease;
}

.sidebar ul li:hover .material-icons {
    transform: scale(1.2);
}

/* ===== INDICADOR DE SUBMENU ===== */
.sidebar ul li.has-submenu strong::after {
    content: "▸";
    position: absolute;
    right: 0.9375rem;
    top: 50%;
    transform: translateY(-50%);
    transition: all 0.3s ease;
    color: #bdc3c7;
    font-size: 0.75rem;
}

.sidebar ul li.has-submenu:hover strong::after,
.sidebar ul li.has-submenu.active strong::after {
    color: white;
    transform: translateY(-50%) rotate(90deg);
}

/* ===== SUBMENUS FLOTANTES - MOBILE FIRST ===== */
.submenu-popup {
    position: fixed;
    min-width: 11.25rem; /* 180px */
    max-width: 12.5rem; /* 200px */
    background: linear-gradient(145deg, #34495e 0%, #2c3e50 100%);
    border: 0.125rem solid rgba(52, 152, 219, 0.4);
    border-radius: 0.75rem;
    box-shadow: 0 0.9375rem 2.1875rem rgba(0, 0, 0, 0.6),
        0 0.3125rem 0.9375rem rgba(0, 0, 0, 0.3),
        inset 0 0.0625rem 0 rgba(255, 255, 255, 0.1);
    list-style: none;
    padding: 0.625rem 0;
    margin: 0;

    /* Estado inicial oculto */
    display: none;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-0.9375rem) scale(0.9);

    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100000;
    overflow: hidden;
    pointer-events: none;

    /* Posición inicial móvil */
    left: 16.875rem; /* 270px */
    top: 6.25rem; /* 100px */
}

/* Estado visible de submenús */
.submenu-popup.visible {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(0) scale(1) !important;
    pointer-events: auto !important;
}

/* Glassmorphism effect */
.submenu-popup::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        45deg,
        rgba(52, 152, 219, 0.08) 0%,
        rgba(155, 89, 182, 0.08) 50%,
        rgba(52, 152, 219, 0.08) 100%
    );
    border-radius: 0.75rem;
    pointer-events: none;
}

/* Items dentro de submenús */
.submenu-popup li {
    position: relative;
    margin: 0.1875rem 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    overflow: hidden;
}

.submenu-popup li:hover {
    background: linear-gradient(
        135deg,
        rgba(52, 152, 219, 0.3) 0%,
        rgba(155, 89, 182, 0.3) 100%
    );
    transform: translateX(0.5rem);
    box-shadow: 0 0.1875rem 0.625rem rgba(52, 152, 219, 0.4);
}

/* Links dentro de submenús */
.submenu-popup a {
    display: block;
    padding: 0.75rem 1.25rem;
    color: #bdc3c7;
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    border-radius: 0.375rem;
    white-space: nowrap;
    min-height: 2.75rem; /* 44px - touch friendly */
}

.submenu-popup a:hover {
    color: white;
    background: linear-gradient(
        135deg,
        rgba(52, 152, 219, 0.4) 0%,
        rgba(155, 89, 182, 0.4) 100%
    );
    padding-left: 1.875rem;
    transform: translateX(0.1875rem);
    font-weight: 600;
}

/* Flecha en links */
.submenu-popup a::before {
    content: "▸";
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: all 0.3s ease;
    color: #3498db;
    font-weight: bold;
    font-size: 0.75rem;
}

.submenu-popup a:hover::before {
    opacity: 1;
    left: 0.5rem;
    transform: translateY(-50%) scale(1.3);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    padding: 2.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    min-height: 100vh;
    width: 100%;
    transition: all 0.3s ease;
}

/* ===== ANIMACIONES ===== */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-3.125rem);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sidebar ul li {
    animation: slideInLeft 0.6s ease-out;
    animation-fill-mode: both;
}

.sidebar ul li:nth-child(1) {
    animation-delay: 0.1s;
}
.sidebar ul li:nth-child(2) {
    animation-delay: 0.2s;
}
.sidebar ul li:nth-child(3) {
    animation-delay: 0.3s;
}
.sidebar ul li:nth-child(4) {
    animation-delay: 0.4s;
}
.sidebar ul li:nth-child(5) {
    animation-delay: 0.5s;
}
.sidebar ul li:nth-child(6) {
    animation-delay: 0.6s;
}
.sidebar ul li:nth-child(7) {
    animation-delay: 0.7s;
}
.sidebar ul li:nth-child(8) {
    animation-delay: 0.8s;
}

@keyframes submenuAppear {
    from {
        opacity: 0;
        transform: translateX(-1.25rem) scale(0.8);
        filter: blur(0.125rem);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
        filter: blur(0);
    }
}

.submenu-popup.visible {
    animation: submenuAppear 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== SCROLLBAR PERSONALIZADO ===== */
.sidebar::-webkit-scrollbar {
    width: 0.375rem;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    border-radius: 0.1875rem;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
}

/* ===== CONTENT DEMO ===== */
.content-demo {
    background: white;
    padding: 1.875rem;
    border-radius: 0.9375rem;
    box-shadow: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.1);
    margin: 1.25rem 0;
}

.content-demo h1 {
    color: #2c3e50;
    margin-bottom: 1.25rem;
    font-size: 1.5rem;
}

.content-demo p {
    color: #7f8c8d;
    line-height: 1.6;
    margin-bottom: 0.9375rem;
}

/* ===== RESPONSIVE DESIGN - MOBILE FIRST ===== */

/* Tablets - 481px+ */
@media (min-width: 30.0625rem) {
    .open-sidebar-btn {
        width: 3.125rem;
        height: 3.125rem;
        top: 1.25rem;
        left: 1.25rem;
    }

    .open-sidebar-btn .material-icons {
        font-size: 1.5rem;
    }

    .sidebar {
        width: 17.5rem; /* 280px */
        left: -17.5rem;
    }

    body.sidebar-hidden .sidebar {
        left: -17.5rem;
    }

    .logo img {
        width: 15rem; /* 240px */
    }

    .sidebar ul li a,
    .sidebar ul li strong {
        font-size: 0.9375rem;
        padding: 1rem 1.25rem;
    }

    .submenu-popup {
        min-width: 13.75rem; /* 220px */
        max-width: 17.5rem; /* 280px */
        left: 18.75rem; /* 300px */
    }

    .submenu-popup a {
        padding: 0.875rem 1.25rem;
        font-size: 0.875rem;
    }

    .main-content {
        padding: 2.5rem;
    }
}

/* Desktop pequeño - 769px+ */
@media (min-width: 48.0625rem) {
    .sidebar {
        width: 17.5rem; /* 280px */
    }

    .sidebar ul li a,
    .sidebar ul li strong {
        font-size: 1rem;
        padding: 1.125rem 1.5rem;
    }

    .sidebar ul li .material-icons {
        font-size: 1.375rem;
    }

    .submenu-popup {
        min-width: 15rem; /* 240px */
        max-width: 18.75rem; /* 300px */
    }

    .submenu-popup a {
        font-size: 0.9375rem;
        padding: 1rem 1.5rem;
    }

    .content-demo h1 {
        font-size: 1.75rem;
    }
}

/* Desktop grande - 1025px+ */
@media (min-width: 64.0625rem) {
    .sidebar {
        width: 18.75rem; /* 300px */
        left: -18.75rem;
    }

    body.sidebar-hidden .sidebar {
        left: -18.75rem;
    }

    .logo img {
        width: 16.25rem; /* 260px */
    }

    .sidebar ul li a,
    .sidebar ul li strong {
        font-size: 1rem;
        padding: 1.25rem 1.5rem;
    }

    .submenu-popup {
        min-width: 16.25rem; /* 260px */
        max-width: 20rem; /* 320px */
        left: 20rem; /* 320px */
    }

    .submenu-popup a {
        font-size: 1rem;
        padding: 1.125rem 1.5rem;
    }

    .main-content {
        padding: 3.125rem;
    }

    .content-demo {
        padding: 2.5rem;
    }

    .content-demo h1 {
        font-size: 2rem;
    }
}

/* Desktop extra grande - 1441px+ */
@media (min-width: 90.0625rem) {
    .sidebar {
        width: 20rem; /* 320px */
        left: -20rem;
    }

    body.sidebar-hidden .sidebar {
        left: -20rem;
    }

    .submenu-popup {
        left: 21.25rem; /* 340px */
        min-width: 17.5rem; /* 280px */
        max-width: 21.875rem; /* 350px */
    }

    .main-content {
        padding: 3.75rem;
    }
}

/* Móviles muy pequeños - hasta 320px */
@media (max-width: 20rem) {
    .open-sidebar-btn {
        width: 2.5rem;
        height: 2.5rem;
        top: 0.75rem;
        left: 0.75rem;
    }

    .open-sidebar-btn .material-icons {
        font-size: 1.25rem;
    }

    .sidebar {
        width: 14.375rem; /* 230px */
        left: -14.375rem;
        padding: 1rem;
    }

    body.sidebar-hidden .sidebar {
        left: -14.375rem;
    }

    .close-sidebar-btn {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.875rem;
    }

    .logo img {
        width: 10rem; /* 160px */
    }

    .sidebar ul li a,
    .sidebar ul li strong {
        font-size: 0.8125rem;
        padding: 0.75rem 1rem;
    }

    .sidebar ul li .material-icons {
        font-size: 1.125rem;
        margin-right: 0.5rem;
    }

    .submenu-popup {
        min-width: 10rem; /* 160px */
        max-width: 11.875rem; /* 190px */
        left: 15.625rem; /* 250px */
    }

    .submenu-popup a {
        padding: 0.625rem 1rem;
        font-size: 0.75rem;
    }

    .main-content {
        padding: 1.25rem;
    }

    .content-demo {
        padding: 1.25rem;
    }

    .content-demo h1 {
        font-size: 1.25rem;
    }
}

/* Orientación landscape en móviles */
@media (max-height: 30rem) and (orientation: landscape) {
    .sidebar {
        overflow-y: auto;
    }

    .sidebar ul li a,
    .sidebar ul li strong {
        padding: 0.75rem 1.25rem;
    }

    .logo img {
        max-width: 8.75rem; /* 140px */
    }
}
