/**
 * TPM Modal Styles
 * Consolidated modal styling (extracted from inline CSS duplicates)
 * 
 * @package TPM
 * @since 9.0.0
 * @version 9.1.91
  * Scoped to body.tpm-page to override theme styles
 */

/* ========================================================================
   Modal Container (rendered at wp_footer with very high priority)
   ======================================================================== */
body.tpm-page #tpm-modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999999 !important;
    pointer-events: none;
}

/* ========================================================================
   Modal Overlay & Container
   ======================================================================== */
body.tpm-page .tpm-modal {
    position: fixed;
    inset: 0;
    z-index: 999999999 !important;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    pointer-events: auto;
}

body.tpm-page .tpm-modal.is-active {
    display: flex !important;
}

body.tpm-page .tpm-modal-backdrop ,
body.tpm-page .tpm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    z-index: 999999998 !important;
    animation: tpm-backdrop-enter 0.25s ease-out forwards;
}

body.tpm-page .tpm-modal.is-closing .tpm-modal-backdrop ,
body.tpm-page .tpm-modal.is-closing .tpm-modal-overlay {
    animation: tpm-backdrop-exit 0.2s ease-in forwards;
}

@keyframes tpm-backdrop-enter {
    from {
        opacity: 0;
        -webkit-backdrop-filter: blur(0);
        backdrop-filter: blur(0);
    }
    to {
        opacity: 1;
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
    }
}

@keyframes tpm-backdrop-exit {
    from {
        opacity: 1;
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
    }
    to {
        opacity: 0;
        -webkit-backdrop-filter: blur(0);
        backdrop-filter: blur(0);
    }
}

/* ========================================================================
   Modal Content
   ======================================================================== */
body.tpm-page .tpm-modal-content {
    position: relative;
    z-index: 999999999 !important;
    background: #fff;
    border-radius: var(--tpm-radius-lg, 0.75rem);
    box-shadow: var(--tpm-shadow-lg, 0 10px 25px rgba(0,0,0,0.15));
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    animation: tpm-modal-enter 0.25s ease-out forwards;
}

body.tpm-page .tpm-modal.is-closing .tpm-modal-content {
    animation: tpm-modal-exit 0.2s ease-in forwards;
}

body.tpm-page .tpm-modal-content.tpm-modal-lg {
    max-width: 700px;
}

body.tpm-page .tpm-modal-content.tpm-modal-sm {
    max-width: 350px;
}

@keyframes tpm-modal-enter {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes tpm-modal-exit {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
}

/* ========================================================================
   Modal Header
   ======================================================================== */
body.tpm-page .tpm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--tpm-border, #e2e8f0);
}

body.tpm-page .tpm-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--tpm-text, #1e293b);
    margin: 0;
}

body.tpm-page .tpm-modal-close {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--tpm-radius, 0.5rem);
    cursor: pointer;
    color: var(--tpm-text-muted, #64748b);
    transition: all 0.2s;
}

body.tpm-page .tpm-modal-close:hover {
    background: var(--tpm-bg-secondary, #f8fafc);
    color: var(--tpm-text, #1e293b);
}

/* ========================================================================
   Modal Body
   ======================================================================== */
body.tpm-page .tpm-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 60vh;
}

/* ========================================================================
   Modal Footer
   ======================================================================== */
body.tpm-page .tpm-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--tpm-border, #e2e8f0);
    background: var(--tpm-bg-secondary, #f8fafc);
}

/* ========================================================================
   Confirm Modal (Special Styling)
   ======================================================================== */
body.tpm-page .tpm-modal-confirm .tpm-modal-content {
    text-align: center;
    padding: 2rem;
}

body.tpm-page .tpm-modal-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

body.tpm-page .tpm-modal-confirm .tpm-modal-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

body.tpm-page .tpm-modal-message {
    color: var(--tpm-text-muted, #64748b);
    margin-bottom: 1.5rem;
}

body.tpm-page .tpm-modal-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

/* ========================================================================
   Loading Modal
   ======================================================================== */
body.tpm-page .tpm-modal-loading .tpm-modal-content {
    text-align: center;
    padding: 2.5rem;
}

body.tpm-page .tpm-modal-loading .tpm-spinner {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem;
}

body.tpm-page .tpm-modal-loading-text {
    color: var(--tpm-text-muted, #64748b);
    font-size: 0.9375rem;
}

/* ========================================================================
   Form Modal
   ======================================================================== */
body.tpm-page .tpm-modal-form .tpm-form-group {
    margin-bottom: 1rem;
}

body.tpm-page .tpm-modal-form .tpm-form-group:last-child {
    margin-bottom: 0;
}

/* ========================================================================
   Responsive
   ======================================================================== */
@media (max-width: 640px) {
    body.tpm-page .tpm-modal {
        padding: 0.5rem;
    }
    
    body.tpm-page .tpm-modal-content {
        max-width: 100%;
        margin: 0;
        border-radius: var(--tpm-radius, 0.5rem);
    }
    
    body.tpm-page .tpm-modal-header ,
    body.tpm-page .tpm-modal-body ,
    body.tpm-page .tpm-modal-footer {
        padding: 1rem;
    }
    
    body.tpm-page .tpm-modal-buttons {
        flex-direction: column;
    }
    
    body.tpm-page .tpm-modal-buttons .tpm-btn {
        width: 100%;
    }
}
