/* main.css - Estilos principales del sistema */

/* Variables CSS */
:root {
    --primary-color: #231e60;
    --secondary-color: #332c8c;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    
    --gradient-primary: linear-gradient(135deg, #46bb84 0%, #369266 100%);
    --gradient-secondary: linear-gradient(135deg, #231e60 0%, #332c8c 100%);
    --gradient-success: linear-gradient(135deg, #107c42 0%, #185c37 100%);
    
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    --box-shadow-hover: 0 25px 45px rgba(0, 0, 0, 0.15);
    
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --transition: all 0.3s ease;
}

/* Reset y base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: #f5f7fa;
    color: var(--dark-color);
    line-height: 1.6;
}

/* Utilidades generales */
.gradient-primary {
    background: var(--gradient-primary);
}

.gradient-secondary {
    background: var(--gradient-secondary);
}

.gradient-success {
    background: var(--gradient-success);
}

.shadow-custom {
    box-shadow: var(--box-shadow);
}

.shadow-hover:hover {
    box-shadow: var(--box-shadow-hover);
    transform: translateY(-2px);
}

.border-radius-custom {
    border-radius: var(--border-radius);
}

.border-radius-lg {
    border-radius: var(--border-radius-lg);
}

.transition-custom {
    transition: var(--transition);
}

/* Botones personalizados */
.btn-custom {
    border-radius: var(--border-radius);
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    transition: var(--transition);
    border: none;
}

.btn-primary-custom {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    color: white;
}

.btn-secondary-custom {
    background: var(--gradient-secondary);
    color: white;
}

.btn-secondary-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(240, 147, 251, 0.4);
    color: white;
}

.btn-success-custom {
    background: var(--gradient-success);
    color: white;
}

.btn-success-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 172, 254, 0.4);
    color: white;
}

/* Formularios */
.form-control-custom {
    border: 2px solid #e1e5e9;
    border-radius: var(--border-radius);
    padding: 1rem 0.75rem;
    font-size: 1rem;
    transition: var(--transition);
}

.form-control-custom:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.input-group-custom .input-group-text {
    background: transparent;
    border: 2px solid #e1e5e9;
    border-right: none;
    border-radius: var(--border-radius) 0 0 var(--border-radius);
}

.input-group-custom .form-control {
    border-left: none;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

/* Cards */
.card-custom {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    background: white;
}

.card-custom:hover {
    box-shadow: var(--box-shadow-hover);
    transform: translateY(-2px);
}

.card-header-custom {
    background: var(--gradient-primary);
    color: white;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    padding: 1.25rem;
    border: none;
}

/* Alertas personalizadas */
.alert-custom {
    border-radius: var(--border-radius);
    border: none;
    font-weight: 500;
    padding: 1rem 1.25rem;
}

/* Navegación */

.navbar .dropdown {
    position: static;
}

@media (max-width: 991.98px) {
    .navbar .dropdown {
        position: relative;
    }
}

.navbar-custom {
    background: var(--gradient-primary);
    box-shadow: var(--box-shadow);
    padding: 0.5rem 0;
    min-height: 60px;
    z-index: 1030; /* Asegurar que esté arriba */
}

.navbar-brand-custom {
    font-weight: 700;
    font-size: 1.5rem;
    color: white;
}

.nav-link-custom {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    transition: var(--transition);
}

.nav-link-custom:hover {
    color: white;
    transform: translateY(-1px);
}

/* Sidebar */
.sidebar-custom {
    background: white;
    box-shadow: var(--box-shadow);
    border-radius: 0;
    padding: 1rem;
    height: calc(100vh - 60px); /* Ajustado a la nueva altura de navbar */
    position: fixed;
    top: 60px; /* Altura exacta de la navbar */
    left: 0;
    width: var(--sidebar-width);
    z-index: 1000;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
}

.sidebar-menu li {
    margin-bottom: 0.5rem;
}

.sidebar-menu a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--dark-color);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: var(--gradient-primary);
    color: white;
    transform: translateX(5px);
}

/* Tablas */
.table-custom {
    background: white;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--box-shadow);
}

.table-custom thead {
    background: var(--gradient-primary);
    color: white;
}

.table-custom tbody tr:hover {
    background-color: rgba(102, 126, 234, 0.1);
}

/* Modales */
.modal-content-custom {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-hover);
}

.modal-header-custom {
    background: var(--gradient-primary);
    color: white;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    border: none;
}

/* Badges */
.badge-custom {
    border-radius: var(--border-radius);
    font-weight: 500;
    padding: 0.5rem 0.75rem;
}

/* Loading spinner */
.spinner-custom {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.slide-in {
    animation: slideIn 0.5s ease-out;
}

.shake {
    animation: shake 0.5s ease-in-out;
}

/* Estados */
.estado-pendiente {
    background-color: #fff3cd;
    color: #856404;
}

.estado-aprobado {
    background-color: #d4edda;
    color: #155724;
}

.estado-rechazado {
    background-color: #f8d7da;
    color: #721c24;
}

.estado-activo {
    background-color: #d1ecf1;
    color: #0c5460;
}

.estado-inactivo {
    background-color: #f8d7da;
    color: #721c24;
}

/* Sidebar responsive */
@media (max-width: 768px) {
    .sidebar-custom {
        position: fixed;
        top: 80px;
        left: -100%;
        width: 250px;
        height: calc(100vh - 80px);
        z-index: 1050;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar-custom.show {
        left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .card-custom {
        margin-bottom: 1rem;
    }
    
    .btn-custom {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .metric-card {
        margin-bottom: 1rem;
    }
}

@media (max-width: 576px) {
    :root {
        --border-radius: 8px;
        --border-radius-lg: 12px;
    }
    
    .card-custom {
        border-radius: var(--border-radius);
    }
    
    .card-header-custom {
        border-radius: var(--border-radius) var(--border-radius) 0 0;
    }
}

/* ======================================= */
/* ARREGLOS PARA NAVBAR Y SIDEBAR */
/* ======================================= */

/* Fix para navbar más compacta */
.navbar-custom {
    background: var(--gradient-primary);
    box-shadow: var(--box-shadow);
    padding: 0.5rem 0; /* Reducido de 1rem a 0.5rem */
    min-height: 60px; /* Altura fija más pequeña */
}

.navbar-facilitator {
    background: var(--facilitator-gradient);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(111, 66, 193, 0.1);
    box-shadow: var(--facilitator-shadow);
    padding: 0.5rem 0;
    min-height: 60px;
    z-index: 1030;
}

.navbar-participant {
    background: var(--participant-gradient);
    padding: 0.5rem 0;
    min-height: 60px;
    z-index: 1030;
}

/* Logo del sistema */
.system-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    flex-shrink: 0; /* Evita que se comprima */
}

.navbar-brand-custom {
    font-weight: 700;
    font-size: 1.2rem; /* Reducido de 1.5rem */
    color: white;
    text-decoration: none;
    white-space: nowrap;
}

.navbar-brand-custom:hover {
    color: white;
    text-decoration: none;
}

/* ======================================= */
/* SIDEBAR COLAPSABLE - VERSIÓN MEJORADA */
/* ======================================= */

/* Variables para sidebar */
:root {
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 70px;
    --navbar-height: 60px;
}

/* Ajustar contenedor principal */
.container-fluid[style*="margin-top"] {
    margin-top: 80px !important;
}

/* Sidebar base */
.sidebar-custom {
    background: white;
    box-shadow: var(--box-shadow);
    border-radius: 0; /* Sin border-radius para que se pegue al borde */
    padding: 1rem;
    height: calc(100vh - var(--navbar-height));
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: var(--sidebar-width);
    z-index: 1000;
    overflow-y: auto;
    transition: all 0.3s ease;
}

/* Sidebar colapsada en desktop */
.sidebar-custom.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-custom.collapsed .sidebar-menu a span {
    display: none;
}

.sidebar-custom.collapsed .sidebar-menu a {
    justify-content: center;
    padding: 0.75rem 0.5rem;
}

/* Contenido principal ajustado */
main.col-md-9 {
    margin-left: var(--sidebar-width);
    margin-top: 80px; /* Espacio suficiente para navbar + un poco más */
    transition: margin-left 0.3s ease;
    padding: 1.5rem;
    width: calc(100% - var(--sidebar-width));
}

main.col-md-9.expanded {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* Botón toggle para desktop */
.sidebar-toggle-desktop {
    position: fixed;
    top: calc(60px + 1rem); /* Ajustado a nueva altura de navbar */
    left: calc(var(--sidebar-width) - 20px);
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--box-shadow);
    transition: all 0.3s ease;
}

.sidebar-toggle-desktop.collapsed {
    left: calc(var(--sidebar-collapsed-width) - 20px);
}

.sidebar-toggle-desktop:hover {
    background: var(--dark-color);
    transform: scale(1.1);
}

/* Menu items con iconos y texto */
.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--dark-color);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: var(--transition);
    gap: 0.75rem;
}

.sidebar-menu a i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-menu a span {
    transition: opacity 0.3s ease;
}

/* ======================================= */
/* RESPONSIVE PARA MÓVIL */
/* ======================================= */

@media (max-width: 991.98px) {
    main.col-md-9 {
        margin-left: 0;
        margin-top: 70px; /* Menos espacio en móvil */
        width: 100%;
        padding: 1rem;
    }
    
    .facilitator-portal main {
        margin-left: 0;
        margin-top: 70px !important;
        width: 100%;
        padding: 1rem;
    }
    
    .container-fluid[style*="margin-top"] {
        margin-top: 70px !important;
    }
    
    .sidebar-toggle-desktop {
        display: none;
    }
    
    .sidebar-custom {
        position: fixed;
        top: 60px;
        left: -var(--sidebar-width);
        width: var(--sidebar-width);
        height: calc(100vh - 60px);
        z-index: 1050;
        transition: left 0.3s ease;
        border-radius: 0;
    }
    
    .sidebar-custom.show {
        left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }
}

/* ======================================= */
/* AJUSTES ADICIONALES */
/* ======================================= */

/* Ajustar el layout para facilitadores y participantes */
.facilitator-portal main {
    margin-left: var(--sidebar-width);
    margin-top: 80px !important; /* Sobrescribir el inline style */
    width: calc(100% - var(--sidebar-width));
    transition: all 0.3s ease;
    padding: 1.5rem;
}

.participant-portal main {
    margin-left: var(--sidebar-width);
    margin-top: 80px;
    width: calc(100% - var(--sidebar-width));
    transition: all 0.3s ease;
    padding: 1.5rem;
}

.facilitator-portal main.expanded {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

.participant-portal main.expanded {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

@media (max-width: 991.98px) {
    .facilitator-portal main {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 991.98px) {
    .participant-portal main {
        margin-left: 0;
        margin-top: 70px;
        width: 100%;
        padding: 1rem;
    }
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 1.5rem;
    margin-top: 0.5rem;
}

/* Asegurar que el dropdown funcione correctamente */
.dropdown-menu {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    padding: 0.5rem 0;
    min-width: 200px;
    z-index: 1040;
    margin-top: 0.5rem;
}

.dropdown-menu .dropdown-item {
    padding: 0.5rem 1rem;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.dropdown-menu .dropdown-item:hover {
    background: #f8f9fa;
    color: #333;
}

.dropdown-menu .dropdown-item:active {
    background: var(--primary-color);
    color: white;
}

.dropdown-menu .dropdown-header {
    padding: 0.5rem 1rem;
    margin-bottom: 0;
    font-size: 0.875rem;
    color: #6c757d;
    white-space: nowrap;
}

.dropdown-menu .dropdown-divider {
    height: 0;
    margin: 0.5rem 0;
    overflow: hidden;
    border-top: 1px solid #e9ecef;
}

/* Asegurar que el toggle del dropdown funcione */
.dropdown-toggle::after {
    display: inline-block;
    margin-left: 0.255em;
    vertical-align: 0.255em;
    content: "";
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-bottom: 0;
    border-left: 0.3em solid transparent;
}
