/* modal.css - Fixed Theme Inheritance */

/* ===== THEME VARIABLES ===== */
:root {
    /* Light Theme (Default) */
    --modal-bg: rgb(204, 218, 246);
    --modal-border: rgb(189, 206, 244);
    --modal-header-bg: rgb(189, 206, 244);
    --modal-header-text: #333333;
    --modal-text: #333333;
    --modal-shadow: 0 25px 100px rgba(0, 0, 0, 0.15);
    --modal-close-bg: #dc3545;
    --modal-close-hover: #c82333;
    --modal-close-text: #ffffff;
    --modal-backdrop: rgba(0, 0, 0, 0.6);
    --modal-loading-bg: rgba(255, 255, 255, 0.9);
    --iframe-bg: #f8f9fa;
    --iframe-border: rgb(189, 206, 244);
    
    /* Font */
    --modal-font: 'Helvetica', 'Arial', sans-serif;
}

/* Dark Theme - Apply to BODY when dark theme is active */
body.dark-theme,
body.dark-mode,
body[data-theme="dark"],
.modal-container.dark-theme {
    --modal-bg: rgb(31, 32, 36);
    --modal-border: rgb(38, 40, 44);
    --modal-header-bg: rgb(38, 40, 44);
    --modal-header-text: #e0e0e0;
    --modal-text: #e0e0e0;
    --modal-shadow: 0 25px 100px rgba(0, 0, 0, 0.5);
    --modal-close-bg: #dc3545;
    --modal-close-hover: #c82333;
    --modal-close-text: #ffffff;
    --modal-backdrop: rgba(0, 0, 0, 0.8);
    --modal-loading-bg: rgba(31, 32, 36, 0.95);
    --iframe-bg: #2c3e50;
    --iframe-border: rgb(38, 40, 44);
}

/* ===== CORE MODAL STYLES ===== */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-backdrop);
    z-index: 9998;
    backdrop-filter: blur(4px);
}

.modal-container {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--modal-bg);
    color: var(--modal-text);
    border-radius: 12px;
    box-shadow: var(--modal-shadow);
    z-index: 9999;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    border: 2px solid var(--modal-border);
    font-family: var(--modal-font);
}

.modal-container.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ===== DEFAULT MODAL SIZES ===== */
.modal-xs { width: 300px; min-height: 200px; }
.modal-sm { width: 500px; min-height: 300px; }
.modal-md { width: 700px; min-height: 400px; }
.modal-lg { width: 900px; min-height: 500px; }
.modal-xl { width: 1100px; min-height: 600px; }

/* ===== MODAL HEADER ===== */
.modal-header {
    background: var(--modal-header-bg);
    color: var(--modal-header-text);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--modal-border);
    font-family: var(--modal-font);
}

.modal-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

/* ===== CLOSE BUTTON ===== */
.modal-close {
    background: var(--modal-close-bg);
    border: none;
    color: var(--modal-close-text);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--modal-font);
    font-weight: normal;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--modal-close-hover);
    transform: scale(1.1);
}

/* ===== MODAL BODY ===== */
.modal-body {
    padding: 20px;
    overflow-y: auto;
    font-family: var(--modal-font);
}

/* Ensure proper height distribution */
.modal-container:not(.modal-full) {
    display: flex;
    flex-direction: column;
    max-width: 95%;
    max-height: 95vh;
}

/* ===== IFRAME ===== */
.iframe-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 8px;
    background: var(--iframe-bg);
    border: 2px solid var(--iframe-border);
}

.iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 6px;
}

/* ===== LOADING ===== */
.modal-loading {
    text-align: center;
    padding: 40px 20px;
    background: var(--modal-loading-bg);
    border-radius: 8px;
}

.modal-spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid var(--modal-close-bg);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .modal-xs,
    .modal-sm,
    .modal-md,
    .modal-lg,
    .modal-xl {
        width: 95vw;
        max-width: 95vw;
    }
}
/* FORCE THEME COLORS - ADD THIS AT THE END OF modal.css */
.modal-container.dark-theme {
    background: rgb(31, 32, 36) !important;
    border-color: rgb(38, 40, 44) !important;
    color: #e0e0e0 !important;
}

.modal-container.dark-theme .modal-header {
    background: rgb(38, 40, 44) !important;
    border-bottom-color: rgb(38, 40, 44) !important;
    color: #e0e0e0 !important;
}

.modal-container.dark-theme .modal-close {
    background: #dc3545 !important;
    color: white !important;
}

.modal-container.light-theme {
    background: rgb(204, 218, 246) !important;
    border-color: rgb(189, 206, 244) !important;
    color: #333333 !important;
}

.modal-container.light-theme .modal-header {
    background: rgb(189, 206, 244) !important;
    border-bottom-color: rgb(189, 206, 244) !important;
    color: #333333 !important;
}

.modal-container.light-theme .modal-close {
    background: #dc3545 !important;
    color: white !important;
}