/* css/modals.css */

/* Generic Modal Overlay */
.modal-overlay {
    display: none; /* MODIFIED: Default to none, JS will add .active to show */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000; /* Higher than quiz-engine and review-manager */
    padding: 20px;
    /* display: flex; /* REMOVED: Now controlled by .active class */
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    /* Optional: animation for modal appearance */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active { /* Class added by JS to show the modal */
    display: flex !important; /* ADDED !important to ensure it overrides if needed */
    opacity: 1;
    visibility: visible;
}


/* Generic Modal Content Box */
.modal-content {
    background: var(--bg-card); /* Using CSS variable */
    border-radius: var(--border-radius); /* Using CSS variable */
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 600px;
    max-height: 90vh; /* Limit height for scrollability */
    overflow-y: auto; /* Allow content to scroll */
    position: relative;
    box-sizing: border-box;
    animation: modalSlideIn 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    color: var(--text-primary); /* Ensure text color is set */
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Specific Modal: AI Upload Modal */
#aiUploadModal .modal-content { /* Targeting AI Upload Modal specifically if needed for different width */
    max-width: 700px; /* Wider for AI upload content */
}


/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 1px solid var(--border-color-light); /* Using CSS variable */
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(240, 147, 251, 0.03));
}

.modal-header h3 {
    color: var(--text-primary);
    font-size: 1.4rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

/* Modal Body */
.modal-body {
    padding: 25px 30px;
    /* Ensure child elements respect padding */
    box-sizing: border-box;
}

/* Modal Footer */
.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color-light); /* Using CSS variable */
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: #f8fafc;
    box-sizing: border-box;
}

/* Tab Navigation within Modals (for AI Upload) */
.method-tabs {
    display: flex;
    gap: 2px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit; /* Ensure font consistency */
}

.tab-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.5);
}

.upload-method { /* Tab content visibility */
    display: none;
}

.upload-method.active {
    display: block;
}

.method-description {
    margin-bottom: 15px;
}

.method-description p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* File Drop Zone (for AI Upload) */
.file-drop-zone {
    border: 2px dashed var(--border-color-light); /* Using CSS variable */
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    background: #f7fafc;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.file-drop-zone:hover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.drop-zone-icon {
    font-size: 2.5rem;
    opacity: 0.6;
}

.drop-zone-text p {
    margin: 0;
    color: var(--text-secondary);
}

.drop-zone-text p:first-child {
    color: var(--text-primary);
    font-weight: 600;
}

.file-info {
    margin-top: 15px;
    padding: 12px;
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 6px;
    color: var(--text-secondary); /* Ensure text color */
}

.file-info p {
    margin: 0;
    font-size: 0.9rem;
    color: inherit; /* Inherit color from parent */
}

/* AI Import Options */
.ai-import-options {
    margin-top: 25px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border-color-light); /* Using CSS variable */
    box-sizing: border-box;
}

.ai-import-options h5 {
    color: var(--text-primary);
    font-size: 1.1rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* JSON Input for AI Upload Modal */
#aiJsonInput {
    width: 100%;
    height: 200px;
    padding: 15px;
    border: 1px solid var(--border-color-light); /* Using CSS variable */
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    resize: vertical;
    background: white;
    line-height: 1.4;
    color: var(--text-primary); /* Ensure text color */
    box-sizing: border-box;
}

#aiJsonInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* AI Duel Subject Select Modal */
#aiDuelSubjectModal .modal-content { /* Targeting AI Duel Modal specifically */
    max-width: 450px; /* Adjusted max width */
}


#aiDuelSubjectSelect {
    width: 100%;
    padding: 12px 15px;
    margin-top: 10px;
    border: 1px solid var(--border-color-light); /* Using CSS variable */
    border-radius: 8px;
    font-size: 0.95rem;
    background-color: white;
    color: var(--text-secondary);
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#aiDuelSubjectSelect:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* Responsive adjustments for modals */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 10px;
        align-items: flex-start; /* Align modal to top on mobile */
        padding-top: 20px;
    }
    .modal-content {
        max-height: calc(100vh - 40px); /* Fill almost full height */
        margin: 0; /* Remove auto margins */
    }
    .modal-header {
        padding: 20px 15px;
    }
    .modal-body {
        padding: 20px 15px;
    }
    .modal-footer {
        padding: 15px;
        flex-direction: column; /* Stack buttons in footer */
    }
    .method-tabs { /* Tab buttons stack */
       flex-direction: column; /* Stack tab buttons on smaller screens */
    }
    .tab-btn {
        padding: 12px 16px;
    }
    .file-drop-zone {
        padding: 30px 15px;
    }
    .ai-import-options {
        padding: 15px;
    }
    #aiJsonInput {
        height: 150px;
    }
}

@media (max-width: 480px) {
    .modal-content {
        max-height: calc(100vh - 20px); /* Tighter fit on very small screens */
    }
    .modal-header {
        padding: 15px 10px;
    }
    .modal-header h3 {
        font-size: 1.2rem;
    }
    .modal-close {
        width: 30px; height: 30px; font-size: 1.2rem;
    }
    .modal-body {
        padding: 15px 10px;
    }
    .modal-footer {
        padding: 10px;
    }
    .tab-btn {
        font-size: 0.8rem;
        padding: 10px 12px;
    }
    .file-drop-zone {
        padding: 20px 10px;
    }
    .ai-import-options h5 {
        font-size: 1rem;
    }
    #aiJsonInput {
        height: 120px;
        font-size: 0.8rem;
    }
}

/* css/modals.css */

/* ... 你已有的其他 modal 样式 ... */

/* 用户协议模态框特定样式 */
#userAgreementModal .modal-body {
    text-align: left;
    line-height: 1.6;
}

#userAgreementModal .modal-body h4 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-size: 1.2em;
    color: var(--primary-color);
    border-left: 4px solid var(--primary-color);
    padding-left: 10px;
}

#userAgreementModal .modal-body h4:first-child {
    margin-top: 0;
}


#userAgreementModal .modal-body ul,
#userAgreementModal .modal-body ol {
    padding-left: 25px;
    margin-bottom: 1em;
}

#userAgreementModal .modal-body ul li,
#userAgreementModal .modal-body ol li {
    margin-bottom: 0.5em;
}