/**
 * AI 渲染风格弹窗样式
 * 统一的弹窗视觉设计，灵感来自 AI 效果图弹窗
 * 
 * @author AI Assistant
 * @date 2025-11-17
 */

/* ===== 弹窗遮罩 ===== */
.ai-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.ai-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

/* ===== 弹窗容器 ===== */
.ai-modal-container {
  position: relative;
  width: 100%;
  max-height: 90vh;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== 弹窗头部 ===== */
.ai-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.ai-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.ai-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.ai-modal-close:hover {
  background: #f3f4f6;
  color: #1f2937;
}

/* ===== 弹窗主体 ===== */
.ai-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* 全局错误提示 */
.ai-modal-global-error {
  padding: 12px 16px;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #dc2626;
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

/* ===== 步骤式布局 ===== */
.ai-modal-step {
  margin-bottom: 16px;
}

.ai-modal-step:last-child {
  margin-bottom: 0;
}

.ai-modal-step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.ai-modal-step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-modal-step-label {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

.ai-modal-step-content {
  padding-left: 32px;
  background: #f9fafb;
  border-radius: 8px;
  padding: 16px;
}

/* ===== 表单元素 ===== */
.ai-modal-body label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 6px;
}

.ai-modal-body label.required::after {
  content: '*';
  color: #ef4444;
  margin-left: 4px;
}

.ai-modal-body input[type="text"],
.ai-modal-body input[type="email"],
.ai-modal-body input[type="tel"],
.ai-modal-body input[type="password"],
.ai-modal-body input[type="number"],
.ai-modal-body textarea,
.ai-modal-body select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  color: #1f2937;
  transition: all 0.2s;
  box-sizing: border-box;
}

.ai-modal-body input::placeholder,
.ai-modal-body textarea::placeholder {
  color: #9ca3af;
}

.ai-modal-body input:focus,
.ai-modal-body textarea:focus,
.ai-modal-body select:focus {
  outline: none;
  border-color: var(--theme-primary, #667eea);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-modal-body input.error,
.ai-modal-body textarea.error,
.ai-modal-body select.error {
  border-color: #ef4444;
}

.ai-modal-body textarea {
  min-height: 80px;
  resize: vertical;
}

/* 字段错误提示 */
.ai-modal-error {
  font-size: 12px;
  color: #ef4444;
  margin-top: 4px;
}

/* 表单组 */
.ai-modal-form-group {
  margin-bottom: 16px;
}

.ai-modal-form-group:last-child {
  margin-bottom: 0;
}

/* ===== 弹窗底部 ===== */
.ai-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

/* ===== 按钮样式 ===== */
.ai-modal-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
  white-space: nowrap;
}

.ai-modal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-modal-btn-primary {
  background: var(--theme-primary, #667eea);
  color: white;
}

.ai-modal-btn-primary:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-modal-btn-secondary {
  background: #e5e7eb;
  color: #1f2937;
}

.ai-modal-btn-secondary:hover:not(:disabled) {
  background: #d1d5db;
}

.ai-modal-btn.loading {
  position: relative;
  color: transparent;
}

.ai-modal-btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-right-color: transparent;
  animation: ai-modal-spin 0.6s linear infinite;
}

@keyframes ai-modal-spin {
  to {
    transform: rotate(360deg);
  }
}

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

/* 平板端 (640-767px) */
@media (max-width: 767px) {
  .ai-modal-overlay {
    padding: 16px;
  }
  
  .ai-modal-container {
    max-height: 95vh;
    border-radius: 12px;
  }
  
  .ai-modal-header {
    padding: 16px;
  }
  
  .ai-modal-title {
    font-size: 16px;
  }
  
  .ai-modal-body {
    padding: 16px;
  }
  
  .ai-modal-footer {
    padding: 12px 16px;
  }
}

/* 移动端 (<640px) */
@media (max-width: 639px) {
  .ai-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  
  .ai-modal-container {
    max-height: 95vh;
    border-radius: 12px 12px 0 0;
    max-width: 100% !important;
  }
  
  .ai-modal-footer {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
  }
  
  .ai-modal-btn {
    flex: 1;
    min-width: 0;
  }
  
  .ai-modal-step-content {
    padding-left: 0;
    padding: 12px;
  }
}

/* ===== 可访问性增强 ===== */
.ai-modal-overlay:focus-visible {
  outline: none;
}

.ai-modal-btn:focus-visible {
  outline: 2px solid var(--theme-primary, #667eea);
  outline-offset: 2px;
}

.ai-modal-close:focus-visible {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* ===== 打印样式 ===== */
@media print {
  .ai-modal-overlay {
    display: none;
  }
}

