/* ============================================
   “双一流”建设项目管理与监测平台 - 统一弹出框样式 (扁平化设计)
   ============================================ */

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* 不使用 backdrop-filter：全屏模糊会触发整页重绘/合成，低配机或含大表格的页面（如项目管理）上弹窗会明显卡顿 */
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 确认框叠在业务弹窗之上，不替换主 overlay 内容 */
.modal-overlay.modal-overlay--confirm {
    z-index: 11000;
    background: rgba(0, 0, 0, 0.45);
}

/* 二级业务弹窗（如指标库上的添加/编辑），保留底层弹窗 */
.modal-overlay.modal-overlay--stack {
    z-index: 10002;
    background: rgba(0, 0, 0, 0.4);
}

/* 三级巢层（如叠层上的台账导入预览），不覆盖 stack 内容 */
.modal-overlay.modal-overlay--nest {
    z-index: 10050;
    background: rgba(0, 0, 0, 0.45);
}

/* Modal Container - 扁平化设计 */
.modal-box {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-box {
    transform: scale(1) translateY(0);
}

/* 确认操作进行中：弹窗内遮罩 + 转圈，防止误以为无响应而重复点击 */
.modal-busy-mask {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(248, 250, 252, 0.72);
    pointer-events: all;
    cursor: wait;
}

.modal-busy-panel {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.88);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
    color: #f8fafc;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.modal-busy-spin {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.28);
    border-top-color: #fff;
    border-radius: 50%;
    animation: modal-busy-spin 0.7s linear infinite;
    flex-shrink: 0;
}

.modal-busy-spin--btn {
    width: 14px;
    height: 14px;
    margin-right: 6px;
    vertical-align: -2px;
    border-color: rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
}

@keyframes modal-busy-spin {
    to { transform: rotate(360deg); }
}

.modal-overlay[data-modal-busy='1'] .modal-footer .btn:disabled {
    cursor: wait;
    opacity: 0.85;
}

.modal-body[data-modal-body-inert='1'] {
    pointer-events: none;
    user-select: none;
}

/* Modal Sizes - 更宽的布局 */
.modal-sm { width: 420px; }

.modal-sm .modal-footer {
    justify-content: center;
}

.modal-md { width: 560px; }
.modal-lg { width: 800px; }
.modal-xl { width: 1000px; }
.modal-xxl { width: 1200px; }

/* 绩效监控工作台：尽量大的内容区 */
.modal-monitor-workbench {
    width: min(1400px, 96vw);
    max-height: min(94vh, 980px);
}

/* 与业务页主容器 max-width 一致（如角色/菜单管理 white cards） */
.modal-match-page {
    width: min(1400px, 96vw);
    max-height: min(90vh, 880px);
}

.modal-match-page .modal-body {
    max-height: calc(90vh - 150px);
}

.modal-monitor-workbench .modal-body {
    max-height: calc(94vh - 150px);
}

/* 申报书版本左右对比 */
.modal-version-diff {
    width: min(1480px, 98vw);
    max-height: min(96vh, 1000px);
}

.modal-version-diff .modal-body {
    max-height: calc(96vh - 120px);
    padding: 16px 20px;
}

.modal-version-diff .modal-footer {
    justify-content: center;
}

/* Modal Header - 扁平化 */
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #1268a8 0%, #0b3d6e 100%);
    color: white;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h3 svg {
    width: 20px;
    height: 20px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    color: white;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-close svg {
    width: 18px;
    height: 18px;
}

/* Modal Body - 减少内边距 */
.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Modal Footer - 扁平化按钮区 */
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: center;
    gap: 12px;
}

.modal-footer.modal-footer--end {
    justify-content: flex-end;
}

.modal-footer.modal-footer--center {
    justify-content: center;
}

/* 叠在高 z-index 业务层（如 AI 生成绩效目标）之上 */
.modal-overlay.modal-overlay--elevated {
    z-index: 13000;
}

.modal-overlay.modal-overlay--nest.modal-overlay--elevated {
    z-index: 13050;
}

.modal-overlay.modal-overlay--confirm.modal-overlay--elevated {
    z-index: 13100;
}

/* Alert/Info Box Styles - 扁平化 */
.modal-alert-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.modal-alert-icon svg {
    width: 24px;
    height: 24px;
}

.modal-alert-icon.success {
    background: linear-gradient(135deg, rgba(17, 153, 142, 0.15) 0%, rgba(56, 239, 125, 0.15) 100%);
    color: #11998e;
}

.modal-alert-icon.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(238, 90, 36, 0.15) 100%);
    color: #ef4444;
}

.modal-alert-icon.warning {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.15) 0%, rgba(251, 191, 36, 0.15) 100%);
    color: #f97316;
}

.modal-alert-icon.info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(18, 104, 168, 0.15) 100%);
    color: #3b82f6;
}

.modal-alert-icon.confirm {
    background: linear-gradient(135deg, rgba(18, 104, 168, 0.15) 0%, rgba(11, 61, 110, 0.15) 100%);
    color: #1268a8;
}

.modal-message {
    text-align: center;
}

.modal-message h4 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.modal-message p {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    margin: 0;
}

/* Form Styles inside Modal - 扁平化 */
.modal-form-group {
    margin-bottom: 16px;
}

.modal-form-group:last-child {
    margin-bottom: 0;
}

.modal-form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.modal-form-label .required {
    color: #ef4444;
    margin-left: 4px;
}

.modal-form-input,
.modal-form-select,
.modal-form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: #1a1a2e;
    background: #f9fafb;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

.modal-form-input:focus,
.modal-form-select:focus,
.modal-form-textarea:focus {
    outline: none;
    border-color: #1268a8;
    background: white;
    box-shadow: 0 0 0 3px rgba(18, 104, 168, 0.1);
}

.modal-form-textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-form-input::placeholder,
.modal-form-textarea::placeholder {
    color: #9ca3af;
}

/* Form Row */
.modal-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* File Upload - 扁平化 */
.file-upload-area {
    border: 2px dashed #e5e7eb;
    border-radius: 10px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    background: #f9fafb;
}

.file-upload-area:hover {
    border-color: #1268a8;
    background: rgba(18, 104, 168, 0.05);
}

.file-upload-area.dragover {
    border-color: #1268a8;
    background: rgba(18, 104, 168, 0.1);
}

.file-upload-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, rgba(18, 104, 168, 0.1) 0%, rgba(11, 61, 110, 0.1) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    color: #1268a8;
}

.file-upload-icon svg {
    width: 24px;
    height: 24px;
}

.file-upload-text {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 6px;
}

.file-upload-text strong {
    color: #1268a8;
}

.file-upload-hint {
    font-size: 12px;
    color: #9ca3af;
}

/* File List */
.file-list {
    margin-top: 12px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 6px;
    transition: background-color 0.2s ease;
}

.file-item:hover {
    background: #f3f4f6;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.file-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-icon.pdf { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.file-icon.doc { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.file-icon.xls { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.file-icon.txt { background: rgba(107, 114, 128, 0.1); color: #6b7280; }

.file-icon svg {
    width: 18px;
    height: 18px;
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 11px;
    color: #9ca3af;
}

.file-delete {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #9ca3af;
    transition: background-color 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.file-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.file-delete svg {
    width: 16px;
    height: 16px;
}

/* Button Styles - 扁平化 */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, #1268a8 0%, #0b3d6e 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(18, 104, 168, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(18, 104, 168, 0.4);
}

.btn-secondary {
    background: #f3f4f6;
    color: #4b5563;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(17, 153, 142, 0.3);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(17, 153, 142, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

/* Form Validation */
.modal-form-group.error .modal-form-input,
.modal-form-group.error .modal-form-textarea {
    border-color: #ef4444;
}

.modal-form-error {
    font-size: 12px;
    color: #ef4444;
    margin-top: 4px;
    display: none;
}

.modal-form-group.error .modal-form-error {
    display: block;
}

/* Animation */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-box {
    animation: modalSlideIn 0.25s ease;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-box {
        width: 95vw !important;
        margin: 12px;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px 16px;
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .modal-form-row {
        grid-template-columns: 1fr;
    }
}
