/**
 * ============================================================================
 * MODAL ALERT MODERNIZADO - IMPACTANTE E PROFISSIONAL
 * ============================================================================
 * Upgrade visual do divAlertDefault.php mantendo 100% de compatibilidade
 * IDs preservados: myModal, myModalLabel, ErrorCliente
 * Classes isoladas: Todas com prefixo .modal-alert-*
 * ============================================================================
 */

/* ============================================================================
 * ANTI-FOUC (Flash of Unharmonized Content)
 * ============================================================================
 * Oculta elementos que serão harmonizados até o JS aplicar as cores
 * Usa visibility em vez de opacity para não interferir com animações
 */
#myModal:not(.harmonizado) .modal-alert-icon,
#myModal:not(.harmonizado) .modal-alert-btn-ok {
    visibility: hidden;
}

/* Quando harmonização for aplicada, mostra os elementos */
#myModal.harmonizado .modal-alert-icon,
#myModal.harmonizado .modal-alert-btn-ok {
    visibility: visible;
    animation: fadeInElement 0.3s ease forwards;
}

@keyframes fadeInElement {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==== OVERLAY COM BLUR MODERNIZADO ==== */
#myModal.modal.fade {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.6);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#myModal .modal-dialog.modal-alert-moderno {
    max-width: 500px;
    margin: 1.75rem auto;
    transform: scale(0.8) translateY(-20px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), 
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: visible !important;
    display: block !important;
    position: relative !important;
}

/* Bootstrap 3 usa .in ao invés de .show */
#myModal.show .modal-dialog.modal-alert-moderno,
#myModal.in .modal-dialog.modal-alert-moderno,
#myModal[style*="display: block"] .modal-dialog.modal-alert-moderno {
    transform: scale(1) translateY(0) !important;
    opacity: 1 !important;
}

/* ==== CONTENT COM GLASSMORPHISM ==== */
.modal-alert-content {
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 
        0 25px 70px rgba(0, 0, 0, 0.25),
        0 10px 30px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
    overflow: hidden;
    position: relative;
}

/* Brilho sutil no topo */
.modal-alert-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
}

/* ==== ÍCONE ANIMADO IMPACTANTE ==== */
.modal-alert-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px 0;
    position: relative;
}

.modal-alert-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    position: relative;
    animation: modalIconEntrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: all 0.3s ease;
}

/* Animação de entrada com bounce */
@keyframes modalIconEntrance {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.15) rotate(10deg);
    }
    70% {
        transform: scale(0.95) rotate(-5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Pulso contínuo no ícone */
.modal-alert-icon::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    animation: iconPulse 2s ease-out infinite;
    pointer-events: none;
}

@keyframes iconPulse {
    0% {
        box-shadow: 0 0 0 0 currentColor;
        opacity: 0.6;
    }
    70% {
        box-shadow: 0 0 0 16px currentColor;
        opacity: 0;
    }
    100% {
        box-shadow: 0 0 0 0 currentColor;
        opacity: 0;
    }
}

/* Ícone SVG dentro */
.modal-alert-icon svg {
    width: 42px;
    height: 42px;
    stroke-width: 2.5;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

/* ==== HEADER ELEGANTE ==== */
.modal-alert-header {
    border-bottom: none !important;
    padding: 20px 32px 8px !important;
    background: transparent !important;
    text-align: center;
    position: relative !important;
    overflow: visible !important;
}

.modal-alert-title {
    color: #1f2937 !important;
    font-size: 22px !important;
    font-weight: 700 !important;
    margin: 0 !important;
    line-height: 1.3 !important;
    width: 100%;
    text-align: center;
    letter-spacing: -0.02em;
    animation: titleSlideIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s backwards;
}

@keyframes titleSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Botão fechar com hover impactante */
.modal-alert-close {
    position: absolute !important;
    right: 20px !important;
    top: 20px !important;
    opacity: 0.4 !important;
    font-size: 32px !important;
    font-weight: 300 !important;
    color: #6b7280 !important;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    z-index: 10 !important;
}

.modal-alert-close:hover {
    opacity: 1 !important;
    background: rgba(239, 68, 68, 0.1) !important;
    color: #ef4444 !important;
    transform: rotate(90deg) scale(1.1) !important;
}

.modal-alert-close:active {
    transform: rotate(90deg) scale(0.95) !important;
}

/* Esconder X padrão do Bootstrap que pode aparecer duplicado */
#myModal .modal-header .close:not(.modal-alert-close) {
    display: none !important;
}

/* Garantir que o X seja clicável */
.modal-alert-close,
.modal-alert-close span {
    pointer-events: auto !important;
}

/* Garantir que o botão OK seja clicável */
.modal-alert-btn-ok {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* ==== BODY COM ANIMAÇÃO ==== */
.modal-alert-body {
    color: #4b5563 !important;
    font-size: 15px !important;
    line-height: 1.6 !important;
    padding: 16px 32px 24px !important;
    text-align: left !important;
    animation: bodyFadeIn 0.6s ease 0.3s backwards;
}

@keyframes bodyFadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mensagens curtas centralizadas */
.modal-alert-body.text-center {
    text-align: center !important;
}

/* Estilo para listas dentro da mensagem */
.modal-alert-body ul,
.modal-alert-body ol {
    margin: 12px 0;
    padding-left: 24px;
}

.modal-alert-body li {
    margin: 6px 0;
}

/* ==== FOOTER COM BOTÃO IMPACTANTE ==== */
.modal-alert-footer {
    border-top: none !important;
    padding: 0 32px 32px !important;
    background: transparent !important;
}

.modal-alert-btn-ok {
    width: 100%;
    border: none !important;
    outline: none !important;
    border-radius: 10px !important;
    padding: 13px 28px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    letter-spacing: 0.5px !important;
    cursor: pointer !important;
    /* Transição MUITO suave - 0.5s para movimento suave */
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
    /* Shadow inicial mais sutil (igual ao login) */
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12) !important;
    position: relative;
    overflow: hidden;
    /* Cor inicial neutra - será substituída pela harmonização ou ficará verde para avisos */
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff !important;
    text-transform: uppercase;
    animation: buttonSlideUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s backwards;
    /* Espaço para o ícone */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
}

/* Texto do botão acima do shimmer */
.modal-alert-btn-ok > * {
    position: relative;
    z-index: 1;
}

/* ==== EFEITO SHIMMER (LUZ PASSANDO) ==== */
.modal-alert-btn-ok::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transition: left 0.6s ease;
    pointer-events: none;
}

/* Ícone check no botão OK */
.modal-alert-btn-ok::before {
    content: '✓';
    font-size: 20px;
    font-weight: 700;
    display: inline-block;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 1;
}

/* Animação do botão ao aparecer */
@keyframes buttonSlideUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ======================================================
   HOVER E ACTIVE - PADRÃO IGUAL AO LOGIN
   ====================================================== */

/* Hover: Elevação SUAVE e sombra maior */
.modal-alert-btn-ok:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2) !important;
}

/* Shimmer ativa no hover (luz passa da esquerda para direita) */
.modal-alert-btn-ok:hover::after {
    left: 100%;
}

/* Ícone check com bounce no hover */
.modal-alert-btn-ok:hover::before {
    transform: scale(1.2) rotate(10deg);
}

/* Active: Pressionado (volta SUAVEMENTE) */
.modal-alert-btn-ok:active {
    transform: translateY(0px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    transition: all 0.1s ease !important;
}


/* ==== TIPOS DE ALERT (harmonizados dinamicamente) ==== */

/* Success - Verde harmonizado com cliente */
#myModal.alert-success .modal-alert-icon {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 3px solid rgba(16, 185, 129, 0.2);
}

#myModal.alert-success .modal-alert-btn-ok {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* Error - Vermelho impactante */
#myModal.alert-error .modal-alert-icon {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 3px solid rgba(239, 68, 68, 0.2);
}

#myModal.alert-error .modal-alert-btn-ok {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

#myModal.alert-error .modal-alert-icon::after {
    animation: iconShake 0.5s ease-out, iconPulse 2s ease-out 0.5s infinite;
}

@keyframes iconShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px) rotate(-5deg); }
    75% { transform: translateX(8px) rotate(5deg); }
}

/* Warning - Amarelo/Laranja */
#myModal.alert-warning .modal-alert-icon {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 3px solid rgba(245, 158, 11, 0.2);
}

#myModal.alert-warning .modal-alert-btn-ok {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* Info - Azul */
#myModal.alert-info .modal-alert-icon {
    background: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
    border: 3px solid rgba(59, 130, 246, 0.2);
}

#myModal.alert-info .modal-alert-btn-ok {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

/* Aviso padrão - Cinza elegante */
#myModal.alert-aviso .modal-alert-icon {
    background: rgba(107, 114, 128, 0.12);
    color: #6b7280;
    border: 3px solid rgba(107, 114, 128, 0.2);
}

#myModal.alert-aviso .modal-alert-btn-ok {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

/* ==== RESPONSIVIDADE IMPECÁVEL ==== */
@media (max-width: 576px) {
    #myModal .modal-dialog.modal-alert-moderno {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-alert-content {
        border-radius: 20px !important;
    }
    
    .modal-alert-icon-wrapper {
        padding: 36px 24px 0;
    }
    
    .modal-alert-icon {
        width: 80px;
        height: 80px;
    }
    
    .modal-alert-icon svg {
        width: 48px;
        height: 48px;
    }
    
    .modal-alert-header {
        padding: 24px 32px 10px !important;
    }
    
    .modal-alert-title {
        font-size: 22px !important;
    }
    
    .modal-alert-close {
        right: 16px;
        top: 16px;
        width: 36px;
        height: 36px;
    }
    
    .modal-alert-body {
        font-size: 15px !important;
        padding: 16px 32px 28px !important;
    }
    
    .modal-alert-footer {
        padding: 0 32px 32px !important;
    }
    
    .modal-alert-btn-ok {
        padding: 14px 28px !important;
        font-size: 15px !important;
    }
}

@media (max-width: 400px) {
    .modal-alert-icon-wrapper {
        padding: 32px 20px 0;
    }
    
    .modal-alert-header {
        padding: 20px 24px 8px !important;
    }
    
    .modal-alert-title {
        font-size: 20px !important;
    }
    
    .modal-alert-body {
        font-size: 14px !important;
        padding: 14px 24px 24px !important;
    }
    
    .modal-alert-footer {
        padding: 0 24px 28px !important;
    }
}

/* ==== PREFERS REDUCED MOTION (ACESSIBILIDADE) ==== */
@media (prefers-reduced-motion: reduce) {
    #myModal .modal-dialog.modal-alert-moderno,
    .modal-alert-icon,
    .modal-alert-title,
    .modal-alert-body,
    .modal-alert-btn-ok {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
    
    .modal-alert-icon::after {
        animation: none !important;
    }
}

/* ==== EFEITO DE FADE DO BACKDROP ==== */
#myModal.fade .modal-backdrop {
    opacity: 0;
    transition: opacity 0.3s ease;
}

#myModal.show .modal-backdrop {
    opacity: 0.6;
}

