/* =====================================================
   Sistema de Modales Modernos
   ===================================================== */

/* Tokens MAC (login/videollamada cargan solo modals.css; integrador define :root en panel-styles) */
:root {
    --rn-btn-primary-bg: #d4ff00;
    --rn-btn-primary-border: #b8e600;
    --rn-btn-primary-text: #0a0a0a;
    --rn-btn-primary-hover-bg: #e5ff4d;
    --rn-focus-ring-mac: 0 0 0 3px rgba(212, 255, 0, 0.28);
}

/* Overlay del Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 1rem;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal Container */
.modal-container {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.05);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.modal-overlay.active .modal-container {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 2px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-icon.success {
    background: linear-gradient(135deg, #ccfbf1 0%, #99f6e4 100%);
    color: #0f766e;
}

.modal-icon.error {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
}

.modal-icon.warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #d97706;
}

.modal-icon.info {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    color: #0284c7;
}

.modal-header-content {
    flex: 1;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.25rem 0;
    letter-spacing: -0.02em;
}

.modal-subtitle {
    font-size: 0.9375rem;
    color: #64748b;
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.modal-close:hover {
    background: #e2e8f0;
    color: #475569;
}

.modal-close:focus-visible {
    outline: none;
    box-shadow: var(--rn-focus-ring-mac, 0 0 0 3px rgba(212, 255, 0, 0.28));
}

/* Modal Body */
.modal-body {
    padding: 2rem;
    color: #1e293b;
    line-height: 1.6;
}

.modal-body p {
    margin: 0 0 1rem 0;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

/* Modal Footer */
.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 2px solid #f1f5f9;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Botones del Modal — mismo perfil que cabecera MAC (3px, sin “pill”, sin lift) */
.modal-btn {
    padding: 0.35rem 0.85rem;
    min-height: 34px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 0.8125rem;
    line-height: 1.25;
    border-style: solid;
    border-width: 1px;
    cursor: pointer;
    box-sizing: border-box;
    transition:
        background 0.12s ease,
        border-color 0.12s ease,
        box-shadow 0.12s ease,
        color 0.12s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transform: none;
}

.modal-btn-primary {
    background: var(--rn-btn-primary-bg, #d4ff00);
    color: var(--rn-btn-primary-text, #0a0a0a);
    border-color: var(--rn-btn-primary-border, #b8e600);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.modal-btn-primary:hover {
    background: var(--rn-btn-primary-hover-bg, #e5ff4d);
    border-color: var(--rn-btn-primary-hover-bg, #e5ff4d);
    color: var(--rn-btn-primary-text, #0a0a0a);
    transform: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.modal-btn-secondary {
    background: #ffffff;
    color: #334155;
    border-color: #e2e8f0;
}

.modal-btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1f2937;
    transform: none;
    box-shadow: none;
}

.modal-btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border-color: #b91c1c;
}

.modal-btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: none;
    box-shadow: 0 1px 3px rgba(185, 28, 28, 0.25);
}

.modal-btn:focus-visible {
    outline: none;
}

.modal-btn-primary:focus-visible {
    box-shadow:
        var(--rn-focus-ring-mac, 0 0 0 3px rgba(212, 255, 0, 0.28)),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.modal-btn-secondary:focus-visible {
    box-shadow: var(--rn-focus-ring-mac, 0 0 0 3px rgba(212, 255, 0, 0.28));
}

.modal-btn-danger:focus-visible {
    box-shadow: var(--rn-focus-ring-mac, 0 0 0 3px rgba(212, 255, 0, 0.28));
}

/* Modal de Confirmación */
.modal-confirm .modal-container {
    max-width: 450px;
}

.modal-confirm .modal-body {
    text-align: center;
    padding: 2rem;
}

.modal-confirm .modal-icon {
    margin: 0 auto 1rem;
}

/* Animaciones */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
}

/* Responsive */
@media (max-width: 640px) {
    .modal-container {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1.25rem 1.5rem;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
    }
    
    .modal-btn {
        width: 100%;
        justify-content: center;
    }
}
