:root {
    --cepsa-primary: #e74c3c;
    --cepsa-primary-dark: #b7000f;
    --cepsa-primary-light: #ff4d4d;
    --cepsa-secondary: #0066cc;
    --cepsa-secondary-light: #4d94ff;
    --cepsa-dark: #1a1a1a;
    --cepsa-gray: #2d2d2d;
    --cepsa-light: #f8f9fa;
    --cepsa-white: #ffffff;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 90px;
}

/* Estilos base */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

/* Efecto de transición suave para todo el layout */
.app-container {
    height: 100vh;
    display: flex;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Sidebar mejorado */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(
        180deg,
        var(--cepsa-primary) 0%,
        var(--cepsa-primary-dark) 100%
    );
    color: var(--cepsa-white);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1rem;
}

/* Secciones de navegación */
.nav-section {
    padding: 0 1rem 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-section:last-child {
    border-bottom: none;
}

.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.7);
    margin: 0.5rem 0 1rem 0.5rem;
    transition: all 0.3s ease;
}

/* Enlaces de navegación */
.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--cepsa-white);
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin: 0.25rem 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background-color: var(--cepsa-secondary-light);
    transform: scaleY(0);
    transform-origin: bottom;
    transition: transform 0.2s ease;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.nav-link:hover::before {
    transform: scaleY(1);
}

.nav-link i {
    font-size: 1.25rem;
    min-width: 24px;
    text-align: center;
    transition: all 0.3s ease;
}

.nav-link span {
    transition: all 0.3s ease;
}

/* Enlace de cerrar sesión */
.logout-link {
    margin-top: auto;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 0;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.logout-link:hover {
    background-color: rgba(0, 0, 0, 0.3);
}

/* Contenido principal */
.main-content {
    flex-grow: 1;
    overflow-y: auto;
    max-height: 100vh;
    padding: 2rem;
    background-color: var(--cepsa-light);
    transition: all 0.3s ease;
}

/* Header móvil */
.mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    height: 60px;
    background: linear-gradient(
        90deg,
        var(--cepsa-primary) 0%,
        var(--cepsa-primary-dark) 100%
    );
    color: var(--cepsa-white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.mobile-header span {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

#toggle-menu {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--cepsa-white);
    cursor: pointer;
    transition: transform 0.3s ease;
}

#toggle-menu:hover {
    transform: scale(1.1);
}

/* Efecto de acordeón para secciones (opcional) */
.nav-section-title {
    cursor: pointer;
    position: relative;
    padding-left: 1.5rem;
}

.nav-section-title::after {
    content: "\F282";
    font-family: "bootstrap-icons";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s ease;
}

.nav-section-title.collapsed::after {
    transform: translateY(-50%) rotate(-90deg);
}

/* Modo TABLET: solo íconos visibles */
@media (max-width: 991.98px) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    .sidebar:not(.open) .nav-link span,
    .sidebar:not(.open) .nav-section-title,
    .sidebar:not(.open) .logo-text,
    .sidebar:not(.open) .nav-section-title::after {
        display: none;
    }

    .sidebar:not(.open) .nav-link {
        justify-content: center;
        padding: 0.75rem 0;
    }

    .sidebar:not(.open) .nav-link:hover {
        transform: none;
    }

    .sidebar:not(.open) .nav-link::before {
        width: 100%;
        height: 4px;
        transform: scaleX(0);
        transform-origin: left;
    }

    .sidebar:not(.open) .nav-link:hover::before {
        transform: scaleX(1);
    }
}

/* Modo MÓVIL: barra lateral oculta y toggleable */
@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        top: 0;
        height: 100%;
        z-index: 1000;
        width: var(--sidebar-width);
        padding-top: 1rem;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .app-container {
        padding-top: 60px; /* Tiene que coincidir con la altura de mobile-header */
    }
}

/* Efecto de overlay cuando el sidebar está abierto en móvil */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.hoverEmpresa {
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: inline-block;
}

/* Efecto al pasar el mouse */
.hoverEmpresa:hover {
    color: #2563eb;
    transform: scale(1.02); /* Ligero zoom */
}

/* Efecto de subrayado animado */
.hoverEmpresa::after {
    content: "";
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: #2563eb;
    transition: width 0.3s ease;
}

.hoverEmpresa:hover::after {
    width: 100%;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--cepsa-primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--cepsa-primary-dark);
}

.nav-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-section-title:not(.collapsed) + .nav-section-content {
    max-height: 500px;
}

/* Sidebar completamente contraída */
.sidebar.sidebar-collapsed {
    width: 70px;
}

.sidebar.sidebar-collapsed .nav-link span,
.sidebar.sidebar-collapsed .nav-section-title,
.sidebar.sidebar-collapsed .logo-text,
.sidebar.sidebar-collapsed .nav-section-title::after {
    display: none;
}

.sidebar.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem 0;
}

/* Ajuste del contenido */
.sidebar.sidebar-collapsed + .main-content {
    margin-left: 70px;
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.25);
    font-weight: 600;
}

.nav-link.active::before {
    transform: scaleY(1);
}

/* Sidebar completamente OCULTA */
.sidebar.sidebar-hidden {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0;
    overflow: hidden;
    box-shadow: none;
}

/* El contenido ocupa todo */
.sidebar.sidebar-hidden + .main-content {
    margin-left: 0 !important;
    width: 100%;
}

/* Botón hamburguesa flotante */
.hamburger-floating {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 2000;
    background: var(--cepsa-primary);
    color: white;
    border-radius: 8px;
    padding: 6px 10px;
}

/* Estado NORMAL (sidebar visible) */
#toggle-menu {
    background: transparent;
    color: white;
    transition: all 0.3s ease;
}

/* Estado cuando la sidebar está OCULTA */
.sidebar-hidden ~ .mobile-header #toggle-menu,
.sidebar-hidden ~ .app-container #toggle-menu,
#toggle-menu.menu-hidden {
    background: var(--cepsa-primary);
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}
