/* ============================================
   MODAL GLOBAL - Reutilizable
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 22, 40, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.modal-container {
    background: var(--blanco);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-height: 96vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.25s ease;
}

.modal-overlay.visible .modal-container {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--gris-200);
    flex-shrink: 0;
    background: var(--azul-500);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--blanco);
}

.modal-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 1rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transicion);
}

.modal-close:hover {
    background: rgba(255,255,255,0.15);
    color: var(--blanco);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-body::-webkit-scrollbar {
    width: 5px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--gris-300);
    border-radius: 5px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--gris-200);
    flex-shrink: 0;
}

/* Responsivo */
@media (max-width: 768px) {
    .modal-container {
        max-height: 95vh;
        margin: 16px;
        border-radius: 10px;
    }

    .modal-header {
        padding: 14px 18px;
    }

    .modal-body {
        padding: 18px;
    }
}

/* ============================================
   BOTONES DE MENSAJES
   ============================================ */

.modal-botones {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-modal {
    padding: 11px 28px;
    border: none;
    border-radius: 8px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transicion);
    min-width: 120px;
}

.btn-modal-aceptar {
    background: var(--azul-400);
    color: var(--blanco);
}

.btn-modal-aceptar:hover {
    background: var(--azul-500);
    box-shadow: 0 4px 16px rgba(37, 99, 160, 0.3);
}

.btn-modal-cancelar {
    background: var(--gris-100);
    color: var(--gris-700);
}

.btn-modal-cancelar:hover {
    background: var(--gris-200);
}

/* ============================================
   TOGGLE SWITCH
   ============================================ */
.toggle-switch {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    padding: 5px 4px;
    border-radius: 6px;
    transition: background 0.15s ease;
}
.toggle-switch:hover {
    background: rgba(37, 99, 160, 0.05);
}
.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    background: #4B5563;
    border-radius: 20px;
    transition: background 0.25s ease;
    flex-shrink: 0;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle-switch input:checked + .toggle-slider {
    background: #00D4AA;
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
}
.toggle-label {
    font-size: 0.84rem;
    color: var(--gris-700);
}

/* Permisos grid */
.permisos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
    max-height: 350px;
    overflow-y: auto;
    padding: 6px 4px;
}
.permisos-grid::-webkit-scrollbar {
    width: 5px;
}
.permisos-grid::-webkit-scrollbar-thumb {
    background: var(--gris-300);
    border-radius: 5px;
}
.permiso-modulo {
    border: 1px solid var(--gris-200);
    border-radius: 10px;
    padding: 14px 14px 10px;
    background: var(--gris-50);
    transition: box-shadow 0.2s ease;
}
.permiso-modulo:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.permiso-modulo-title {
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--azul-500);
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--gris-200);
    display: flex;
    align-items: center;
    gap: 6px;
}
.permiso-modulo > .toggle-switch + .toggle-switch {
    border-top: 1px solid var(--gris-200);
    margin-top: 2px;
    padding-top: 6px;
}
.permiso-modulo-title i {
    font-size: 0.75rem;
    width: 16px;
    color: var(--azul-400);
}

/* Botones de acción para permisos */
.permiso-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border: 1px solid var(--azul-300);
    border-radius: 20px;
    background: transparent;
    color: var(--azul-400);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.2px;
}
.permiso-btn i {
    font-size: 0.7rem;
}
.permiso-btn:hover {
    background: var(--azul-400);
    border-color: var(--azul-400);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 160, 0.2);
}
.permiso-btn:active {
    transform: scale(0.96);
}
.permiso-btn-off {
    border-color: var(--gris-300);
    color: var(--gris-500);
}
.permiso-btn-off:hover {
    background: var(--gris-600);
    border-color: var(--gris-600);
    color: #fff;
    box-shadow: 0 2px 8px rgba(71, 85, 105, 0.2);
}