/**
 * 动态表单对话框样式
 * 
 * 与 founder-latex-compare 现有对话框风格保持一致
 * 
 * @package founder-latex-compare
 * @since 1.1.0
 */

/* ========================================
   表单对话框基础样式（使用flc-floating-dialog类保持一致）
   ======================================== */

#flc-form-dialog {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background-color: #fff !important;
    border-radius: 5px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
    z-index: 999999999 !important; /* 确保在所有元素之上 */
    min-width: 400px !important;
    max-width: 600px !important;
    width: 90% !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
    transition: opacity 0.2s ease !important;
    /* display 由JavaScript控制，不使用!important */
    display: none;
    pointer-events: auto !important; /* 确保可以接收点击 */
}

#flc-form-dialog.show {
    display: block;
    animation: flc-dialog-fadein 0.3s ease-out;
}

@keyframes flc-dialog-fadein {
    from {
        opacity: 0;
        transform: translate(-50%, -48%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* 拖动中样式 */
#flc-form-dialog.flc-dragging {
    opacity: 0.9;
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.2);
    user-select: none;
    transform: none; /* 拖动时移除居中变换 */
}

/* 对话框头部（可拖动） */
#flc-form-dialog .flc-dialog-header {
    padding: 8px 10px;
    background: #f0f0f0;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    font-size: 12px;
    font-weight: 600;
    user-select: none;
    border-radius: 5px 5px 0 0;
}

#flc-form-dialog .flc-dialog-controls {
    display: flex;
    gap: 5px;
}

#flc-form-dialog .flc-dialog-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    background-color: transparent;
    color: #666;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

#flc-form-dialog .flc-dialog-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #333;
}

#flc-form-dialog .flc-dialog-close .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* 对话框内容区域 */
#flc-form-dialog .flc-dialog-content {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

/* ========================================
   表单字段样式
   ======================================== */

.flc-form-group {
    margin-bottom: 15px;
}

.flc-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    font-size: 13px;
}

.flc-form-group label .required {
    color: #e74c3c;
    margin-left: 2px;
    font-weight: bold;
}

.flc-form-hint {
    color: #666;
    font-size: 12px;
    font-weight: normal;
    margin-left: 5px;
}

.flc-form-group input[type="text"],
.flc-form-group textarea,
.flc-form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: inherit;
}

.flc-form-group input[type="text"]:focus,
.flc-form-group textarea:focus,
.flc-form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.flc-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* 表单操作按钮 */
.flc-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.flc-btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.flc-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.flc-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.flc-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.flc-btn-secondary {
    background: #f5f5f5;
    color: #333;
}

.flc-btn-secondary:hover {
    background: #e0e0e0;
}

/* ========================================
   图片上传区域
   ======================================== */

#flc-image-upload-container {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.flc-image-upload-area {
    display: block;
    border: 2px dashed #ddd;
    border-radius: 4px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafafa;
}

.flc-image-upload-area:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.flc-image-upload-area.drag-over {
    border-color: #667eea;
    background: #e8ebff;
    border-style: solid;
}

.flc-image-upload-area .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
    color: #999;
}

.flc-image-upload-area p {
    margin: 10px 0 0 0;
    color: #666;
    font-size: 13px;
}

/* 图片预览容器 */
.flc-image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.flc-image-preview:empty {
    display: none;
}

/* 单个图片预览项 */
.flc-image-preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.flc-image-preview-item img {
    max-width: 100%;
    max-height: 70px;
    object-fit: contain;
}

.flc-image-filename {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 10px;
    padding: 3px 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flc-image-loading {
    font-size: 11px;
    color: #667eea;
    animation: flc-pulse 1.5s infinite;
}

@keyframes flc-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* 删除按钮 */
.flc-image-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
}

.flc-image-preview-remove:hover {
    background: rgba(231, 76, 60, 0.9);
}

.flc-image-preview-remove .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

/* ========================================
   遮罩层
   ======================================== */

.flc-dialog-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.3) !important;
    z-index: 999999998 !important;  /* 在对话框下面一层 */
    pointer-events: none !important;  /* 让点击穿透，不拦截对话框的拖动 */
    animation: fadeIn 0.3s ease-out !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ========================================
   响应式设计
   ======================================== */

@media (max-width: 768px) {
    #flc-form-dialog {
        width: 95%;
        min-width: auto;
        max-width: none;
    }
    
    #flc-form-dialog .flc-dialog-content {
        max-height: 70vh;
    }
    
    .flc-image-preview-item {
        width: 80px;
        height: 80px;
    }
    
    .flc-form-actions {
        flex-direction: column-reverse;
    }
    
    .flc-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ========================================
   滚动条美化
   ======================================== */

#flc-form-dialog .flc-dialog-content::-webkit-scrollbar {
    width: 8px;
}

#flc-form-dialog .flc-dialog-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#flc-form-dialog .flc-dialog-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

#flc-form-dialog .flc-dialog-content::-webkit-scrollbar-thumb:hover {
    background: #999;
}

