/**
 * UI Modal System - Sistema Unificado de Modais
 * Substitui alert(), confirm() e loaders nativos
 * Compatível com o layout atual do sistema
 */

/* ===== OVERLAY ===== */
.ui-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ui-modal-overlay.active {
    opacity: 1;
}

.ui-modal-overlay.blocked {
    cursor: wait;
}

/* ===== MODAL CONTAINER ===== */
.ui-modal {
    position: relative;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    z-index: 9999;
}

.ui-modal-overlay.active .ui-modal {
    transform: scale(1);
}

/* Modal sizes */
.ui-modal--small {
    width: 400px;
}

.ui-modal--large {
    width: 700px;
}

/* ===== MODAL HEADER ===== */
.ui-modal__header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #f8f9fa;
}

.ui-modal__header-icon {
    font-size: 2rem;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.ui-modal__header-content {
    flex: 1;
}

.ui-modal__header-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
}

.ui-modal__header-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
    flex-shrink: 0;
}

.ui-modal__header-close:hover {
    color: #000;
}

.ui-modal__header-close:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== MODAL BODY ===== */
.ui-modal__body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 60px;
}

.ui-modal__body-message {
    margin: 0;
    line-height: 1.6;
    color: #333;
    font-size: 0.95rem;
}

.ui-modal__body-message p {
    margin: 0 0 0.75rem 0;
}

.ui-modal__body-message p:last-child {
    margin-bottom: 0;
}

/* ===== MODAL FOOTER ===== */
.ui-modal__footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: #f8f9fa;
}

.ui-modal__footer--center {
    justify-content: center;
}

.ui-modal__footer--space-between {
    justify-content: space-between;
}

/* ===== LOADING MODAL ===== */
.ui-modal--loading {
    width: 300px;
    text-align: center;
}

.ui-modal--loading .ui-modal__body {
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 150px;
}

.ui-modal__spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3aa6ea;
    border-radius: 50%;
    animation: ui-modal-spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes ui-modal-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ui-modal__loading-text {
    color: #666;
    font-size: 0.95rem;
    margin: 0;
}

/* ===== MODAL TYPES (COLORS) ===== */
/* Info (Azul) */
.ui-modal--info .ui-modal__header-icon {
    background: #e7f3ff;
    color: #3aa6ea;
}

.ui-modal--info .ui-modal__header-title {
    color: #3aa6ea;
}

/* Success (Verde) */
.ui-modal--success .ui-modal__header-icon {
    background: #dcfce7;
    color: #22c55e;
}

.ui-modal--success .ui-modal__header-title {
    color: #16a34a;
}

/* Warning (Amarelo) */
.ui-modal--warning .ui-modal__header-icon {
    background: #fef3c7;
    color: #f59e0b;
}

.ui-modal--warning .ui-modal__header-title {
    color: #d97706;
}

/* Error (Vermelho) */
.ui-modal--error .ui-modal__header-icon {
    background: #ffebee;
    color: #ff7373;
}

.ui-modal--error .ui-modal__header-title {
    color: #ff7373;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .ui-modal {
        width: 95% !important;
        max-width: 95% !important;
        margin: 1rem;
    }
    
    .ui-modal__header {
        padding: 1rem;
    }
    
    .ui-modal__body {
        padding: 1rem;
    }
    
    .ui-modal__footer {
        padding: 0.75rem 1rem;
        flex-direction: column;
    }
    
    .ui-modal__footer .btn {
        width: 100%;
        margin: 0;
    }
}

/* ===== ACCESSIBILITY ===== */
.ui-modal[aria-hidden="true"] {
    display: none;
}

.ui-modal:focus {
    outline: none;
}

/* ===== ANIMATIONS ===== */
@keyframes ui-modal-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.ui-modal-overlay.active {
    animation: ui-modal-fade-in 0.3s ease;
}
