/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #e91e63;
  --primary-hover: #c2185b;
  --primary-light: #fce4ec;
  --secondary-color: #9c27b0;
  --text-primary: #333;
  --text-secondary: #666;
  --text-light: #999;
  --bg-primary: #fff;
  --bg-secondary: #f8f9fa;
  --border-color: #e0e0e0;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #fce4ec 0%, #f3e5f5 100%);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 30px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.logo-icon {
  font-size: 2.5rem;
}

.header h1 {
  font-size: 2rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Main Content */
.main-content {
  max-width: 800px;
  margin: 0 auto;
}

.design-panel > section {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 30px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.design-panel h2 {
  font-size: 1.25rem;
  margin-bottom: 20px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.design-panel h2::before {
  content: '';
  width: 4px;
  height: 20px;
  background: var(--primary-color);
  border-radius: 2px;
}

/* Upload Section */
.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.upload-area:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

.upload-area.dragover {
  border-color: var(--primary-color);
  background: var(--primary-light);
  transform: scale(1.02);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.upload-icon {
  width: 64px;
  height: 64px;
  stroke: var(--text-light);
  stroke-width: 1.5;
}

.upload-placeholder p {
  color: var(--text-primary);
  font-size: 1.1rem;
}

.upload-hint {
  color: var(--text-light);
  font-size: 0.85rem;
}

.preview-container {
  display: none;
  position: relative;
  max-width: 100%;
}

.preview-container.active {
  display: block;
}

#previewImage {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius-md);
  object-fit: contain;
}

.remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(0,0,0,0.6);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.remove-btn:hover {
  background: var(--primary-color);
  transform: scale(1.1);
}

.remove-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

/* Analyze Button Container */
.analyze-btn-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.analyze-btn {
  padding: 12px 24px;
  border: none;
  background: linear-gradient(135deg, #9c27b0, #673ab7);
  color: white;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.analyze-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.analyze-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.analysis-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.spinner-small {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Hand Analysis Result Section */
.hand-analysis-result-section {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.4s ease-out;
}

.hand-analysis-result-section h2 {
  font-size: 1.15rem;
  margin-bottom: 16px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.hand-analysis-result-section h2::before {
  content: '✓';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #4caf50;
  color: white;
  border-radius: 50%;
  font-size: 0.9rem;
}

#handAnalysisBoxResult {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px;
}

#handAnalysisBoxResult .analysis-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

#handAnalysisBoxResult .analysis-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#handAnalysisBoxResult .analysis-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

#handAnalysisBoxResult .analysis-value {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 600;
}

#handAnalysisBoxResult .analysis-value.highlight {
  color: var(--primary-color);
}

/* Hand Description Section */
#handDescriptionInput {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.3s ease;
}

#handDescriptionInput:focus {
  outline: none;
  border-color: var(--primary-color);
}

#handDescriptionInput::placeholder {
  color: var(--text-light);
}

/* Requirement Section */
#requirementInput {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.3s ease;
}

#requirementInput:focus {
  outline: none;
  border-color: var(--primary-color);
}

#requirementInput::placeholder {
  color: var(--text-light);
}

.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  align-items: center;
}

.tag-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.tag-btn {
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.tag-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: var(--primary-light);
}

/* Action Section */
.generate-btn {
  width: 100%;
  padding: 18px 32px;
  border: none;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.generate-btn .btn-icon {
  font-size: 1.3rem;
}

/* Result Section */
.result-content {
  min-height: 200px;
}

.loading-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 16px;
}

.result-display {
  display: none;
  text-align: center;
}

.result-display.active {
  display: block;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--primary-light);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-detail {
  color: var(--text-light);
  font-size: 0.9rem;
}

#resultImage {
  max-width: 100%;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.download-btn,
.retry-btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.download-btn {
  background: var(--primary-color);
  color: white;
}

.download-btn:hover {
  background: var(--primary-hover);
}

.retry-btn {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.retry-btn:hover {
  background: var(--border-color);
}

.download-btn svg,
.retry-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.error-state {
  display: none;
  color: var(--text-secondary);
}

.error-state.active {
  display: flex;
}

.error-icon {
  width: 48px;
  height: 48px;
  stroke: #f44336;
}

.error-message {
  color: #f44336;
}

/* Hand Analysis Box */
.hand-analysis-box {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
  text-align: left;
}

.hand-analysis-box h3 {
  font-size: 1.1rem;
  color: var(--primary-color);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hand-analysis-box h3::before {
  content: '📊';
  font-size: 1.2rem;
}

.analysis-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.analysis-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.analysis-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.analysis-value {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 600;
}

/* Footer */
.footer {
  text-align: center;
  padding: 30px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    padding: 30px 15px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .design-panel > section {
    padding: 20px;
  }

  .upload-area {
    padding: 30px 20px;
  }

  .result-actions {
    flex-direction: column;
  }

  .download-btn,
  .retry-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.design-panel > section {
  animation: fadeIn 0.4s ease-out;
}
