/* Reset */
html,
body {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    background: #f5f7fa;
    color: #2c3e50;
    height: 100%;
    width: 100%;
}

:root {
    --sidebar-width: 280px;
    --sidebar-collapsed: 0px;
    --top-bar-height: 65px;
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
}

input {
    text-align: center !important;
}
/* ============================================================ */
/* LAYOUT PRINCIPAL */
/* ============================================================ */
.layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ============================================================ */
/* SIDEBAR */
/* ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #2c3e50;
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transform: translateX(0);
    transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

/* Sidebar header */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.2rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: var(--top-bar-height);
}

.btn-toggle-sidebar {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    min-width: 0;
    color: #ecf0f1;
    font-size: 1.2rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.btn-toggle-sidebar:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-logo {
    font-size: 1.4rem;
    color: #f1c40f;
    flex-shrink: 0;
}

.sidebar-titulos {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    overflow: hidden;
}

.sidebar-titulo {
    font-size: 1rem;
    font-weight: 600;
    color: #ecf0f1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-seccion {
    font-size: 0.7rem;
    color: #bdc3c7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Navegación */
.sidebar-nav {
    padding: 0.5rem 0 2rem 0;
    flex: 1;
}

.submenu-toggle {
    background: none;
    border: none;
    color: #ecf0f1;
    font-size: 0.95rem;
    text-align: left;
    padding: 0.75rem 1.2rem;
    cursor: pointer;
    width: 100%;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.submenu-toggle:hover {
    background: #34495e;
}

.submenu-toggle .arrow {
    transition: transform 0.25s ease;
    font-size: 0.75rem;
    color: #7f8c8d;
}

.submenu-toggle .arrow.rotated {
    transform: rotate(90deg);
}

.submenu-toggle span i {
    margin-right: 0.6rem;
    width: 1.4rem;
    text-align: center;
    color: #7f8c8d;
}

/* Submenús */
.submenu {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s ease, opacity 0.3s ease, padding 0.3s ease;
    padding: 0 0.5rem;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    margin: 0 0.3rem;
}

.submenu.open {
    max-height: 500px;
    opacity: 1;
    padding: 0.3rem 0.5rem;
}

.submenu a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #dce3ea;
    text-decoration: none;
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.submenu a i {
    width: 1.4rem;
    text-align: center;
    color: #7f8c8d;
}

.submenu a:hover {
    background: #34495e;
    padding-left: 1.2rem;
}

.submenu a.activo {
    background: #1a2632;
    font-weight: 600;
    border-left: 3px solid #f1c40f;
}

/* ============================================================ */
/* BOTÓN FLOTANTE PARA REABRIR SIDEBAR */
/* ============================================================ */
.btn-flotante-sidebar {
    position: fixed;
    top: 0.75rem;
    min-width: 0;
    left: 0.75rem;
    z-index: 999;
    background: #2c3e50;
    border: none;
    color: white;
    font-size: 1.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.25s ease;
    display: none;
    line-height: 1;
}

.btn-flotante-sidebar:hover {
    background: #34495e;
    transform: scale(1.05);
}

/* Mostrar botón flotante cuando el sidebar está colapsado */
.sidebar.collapsed~.main-area .btn-flotante-sidebar {
    display: block;
}

/* También visible en móvil cuando el sidebar está oculto */
@media (max-width: 768px) {
    .btn-flotante-sidebar {
        display: block;
    }

    .sidebar:not(.collapsed)~.main-area .btn-flotante-sidebar {
        display: none;
    }
}

/* ============================================================ */
/* ÁREA PRINCIPAL */
/* ============================================================ */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

.sidebar.collapsed~.main-area {
    margin-left: 0;
    width: 100%;
}

/* Contenido */
.contenido {
    flex: 1;
    padding: 1.5%;
    background: #f5f7fa;
    min-height: calc(100vh - var(--top-bar-height));
}

/* ============================================================ */
/* TOP-BAR (integrado dentro del main-area) */
/* ============================================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #7B1E1E;
    padding: 0 1.5rem;
    height: var(--top-bar-height);
    border-bottom: 3px solid #5a1515;
    flex-shrink: 0;
    color: white;
    gap: 1rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0;
}

.topbar-left .breadcrumb {
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255, 255, 255, 0.9);
}

.topbar-left .breadcrumb i {
    margin-right: 0.5rem;
    color: rgba(255, 255, 255, 0.6);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-shrink: 0;
}

.topbar-right .user-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
}

.topbar-right .logout-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
}

.topbar-right .logout-btn:hover {
    background: #e74c3c;
}

/* ============================================================ */
/* BANNER COMPLETAR DATOS */
/* ============================================================ */
.banner-completar-datos {
    background: #fff8e1;
    border-bottom: 2px solid #f0c040;
    padding: 0.6rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.banner-completar-datos .banner-texto {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #7a4f00;
}

.banner-completar-datos .banner-texto i {
    color: #e6a817;
    font-size: 1.1rem;
}

.banner-completar-datos .banner-btn {
    background: #e6a817;
    color: white;
    border: none;
    padding: 0.3rem 0.9rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}

.banner-completar-datos .banner-btn:hover {
    background: #c48f10;
}

.banner-completar-datos .banner-close {
    background: none;
    border: none;
    color: #a07020;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.3rem;
}

.banner-completar-datos .banner-close:hover {
    color: #7a4f00;
}

/* ============================================================ */
/* RESPONSIVE */
/* ============================================================ */

/* Tablets y móviles */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    .main-area {
        margin-left: 0;
        width: 100%;
    }

    .btn-flotante-sidebar {
        display: block;
    }

    .sidebar.open~.main-area .btn-flotante-sidebar {
        display: none;
    }
}

/* Móviles pequeños */
@media (max-width: 480px) {
    .topbar {
        padding: 0 0.8rem;
        height: 55px;
    }

    .topbar-left .breadcrumb {
        font-size: 0.85rem;
        max-width: 120px;
    }

    .topbar-right .user-name {
        font-size: 0.75rem;
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar-right .logout-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }

    .contenido {
        padding: 1rem;
    }

    .sidebar {
        width: 260px;
    }

    .banner-completar-datos {
        padding: 0.4rem 0.8rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
    }

    .banner-completar-datos .banner-texto {
        font-size: 0.8rem;
    }

    .banner-completar-datos .banner-btn {
        text-align: center;
    }
}

/* Ajuste para pantallas muy pequeñas */
@media (max-width: 360px) {
    .sidebar {
        width: 220px;
    }

    .sidebar-titulo {
        font-size: 0.85rem;
    }

    .sidebar-seccion {
        font-size: 0.6rem;
    }

    .submenu-toggle {
        font-size: 0.85rem;
        padding: 0.6rem 1rem;
    }

    .submenu a {
        font-size: 0.8rem;
        padding: 0.5rem 0.6rem;
    }
}

/* ============================================================ */
/* UTILIDADES */
/* ============================================================ */
.pointer {
    cursor: pointer;
}

.text-ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Scrollbar personalizado para sidebar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: #2c3e50;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #4a6572;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #5d7a8c;
}

/* ============================================================ */
/* ANIMACIONES */
/* ============================================================ */
@keyframes slideDownBanner {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.banner-completar-datos {
    animation: slideDownBanner 0.3s ease both;
}

/* ============================================================ */
/* REDUCIR MOVIMIENTO */
/* ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}