/* ==========================================
   Image Color Palette Extractor
   ========================================== */

.palette-section {
  margin: 30px 0;
}

.palette-section h2 {
  margin-bottom: 20px;
  font-size: 24px;
  color: #2c3e50;
}

/* Upload Zone */
#upload-section {
  margin: 20px 0;
}

.upload-container {
  border: 2px dashed #d1d5db;
  border-radius: 20px;
  padding: 40px 20px;
  text-align: center;
  background: #fff;
  transition: all 0.2s ease;
  cursor: pointer;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-container:hover {
  border-color: #3984a7;
  background: #f0f8ff;
}

.upload-container.drag-over {
  border-color: #3984a7;
  background: #e6f3ff;
  border-style: solid;
}

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

.upload-icon {
  width: 40px;
  height: 40px;
  color: #666;
}

.upload-container p {
  margin: 0;
  color: #666;
  font-size: 16px;
  font-weight: 500;
}

/* ==========================================
   Top Section: Preview + Actions
   ========================================== */

.top-section {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 15px;
  margin: 20px 0;
}

.preview-card {
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: 24px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.preview-card .image-preview-img {
  display: block;
  max-width: 100%;
  max-height: 260px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0;
  margin-top: 0;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.actions-card {
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: 24px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.actions-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border: 2px solid;
  border-radius: 24px;
  font-weight: bold;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  box-sizing: border-box;
  min-height: 44px;
  gap: 8px;
  width: 100%;
  color: #ffffff;
}

.actions-btn:active {
  transform: scale(0.98);
}

.export-btn {
  background-color: #3984a7;
  border-color: #d1d5db;
}

.export-btn:hover {
  background-color: #2d6a89;
  border-color: #7fa8c0;
}

.clear-btn {
  background-color: #d32f2f;
  border-color: #e57373;
}

.clear-btn:hover {
  background-color: #b71c1c;
  border-color: #d32f2f;
}

/* ==========================================
   Export Modal
   ========================================== */

.export-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  animation: fadeIn 0.15s ease;
}

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

.export-modal {
  background: #ffffff;
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.export-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.export-modal-header h3 {
  font-size: 20px;
  font-weight: bold;
  color: #2c3e50;
  margin: 0;
}

.export-modal-close {
  background: #f3f4f6;
  border: none;
  cursor: pointer;
  color: #6b7280;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.export-modal-close:hover {
  background: #e5e7eb;
  color: #2c3e50;
}

.export-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.export-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  margin: 0;
}

.export-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 12px;
}

.export-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  background: #f3f4f6;
  border: 2px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #2c3e50;
  min-height: 90px;
}

.export-tile:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
}

.export-tile:active {
  transform: scale(0.96);
}

.export-tile.feedback-success {
  background: #e8f5e9;
  border-color: #4CAF50;
  color: #2e7d32;
}

.export-tile svg {
  flex-shrink: 0;
}

.export-tile span {
  font-size: 13px;
  font-weight: 600;
}

.export-setting {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0 0;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.export-setting-label {
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
}

.export-setting-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.swatch-size-input {
  width: 44px;
  padding: 4px 6px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: Consolas, 'Roboto Mono', 'SF Mono', Monaco, monospace;
  color: #2c3e50;
  text-align: center;
  outline: none;
  background: #fff;
  -moz-appearance: textfield;
}

.swatch-size-input::-webkit-outer-spin-button,
.swatch-size-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.swatch-size-input:focus {
  border-color: #3984a7;
}

.export-setting-unit {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
}

/* ==========================================
   Info Bar (inside preview card)
   ========================================== */

.info-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.info-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #e9ecef;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  font-family: Consolas, 'Roboto Mono', 'SF Mono', Monaco, 'Cascadia Code', 'Liberation Mono', 'Courier New', monospace;
  color: #2c3e50;
  font-weight: 600;
}

.info-chip-label {
  color: #6b7280;
  font-weight: 500;
  font-family: inherit;
}

/* ==========================================
   Slider
   ========================================== */

.slider-container {
  max-width: 500px;
  margin: 0 auto;
  text-align: center;
}

.slider-label {
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
  display: block;
  margin-bottom: 12px;
}

.palette-size-input {
  width: 42px;
  padding: 2px 4px;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  font-family: Consolas, 'Roboto Mono', 'SF Mono', Monaco, 'Cascadia Code', 'Liberation Mono', 'Courier New', monospace;
  color: #3984a7;
  text-align: center;
  outline: none;
  background: #ffffff;
  -moz-appearance: textfield;
  transition: border-color 0.2s ease;
}

.palette-size-input::-webkit-outer-spin-button,
.palette-size-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.palette-size-input:focus {
  border-color: #3984a7;
}

.palette-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #e9ecef;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  margin: 12px 0;
}

.palette-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #3984a7;
  cursor: pointer;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.palette-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #3984a7;
  cursor: pointer;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.slider-markers {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #9ca3af;
  padding: 0 2px;
}

/* ==========================================
   Sort Dropdown
   ========================================== */

.sort-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.sort-label {
  font-size: 15px;
  font-weight: 600;
  color: #2c3e50;
  white-space: nowrap;
}

.sort-select {
  padding: 10px 16px;
  border: 2px solid #d1d5db;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 600;
  color: #2c3e50;
  background: #ffffff;
  cursor: pointer;
  outline: none;
  width: 100%;
  transition: border-color 0.2s ease;
}

.sort-select:hover {
  border-color: #3984a7;
}

.sort-select:focus {
  border-color: #3984a7;
}

/* ==========================================
   Palette Results: Donut Chart + Color List
   ========================================== */

.palette-results {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 30px;
  align-items: flex-start;
}

.donut-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}

.donut-chart {
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-chart svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.color-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.color-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 16px;
  position: relative;
}

.color-row:hover {
}

.color-row.highlighted {
}

.color-row.dimmed {
  opacity: 0.5;
}

.color-row-percentage {
  font-family: Consolas, 'Roboto Mono', 'SF Mono', Monaco, 'Cascadia Code', 'Liberation Mono', 'Courier New', monospace;
  font-size: 15px;
  font-weight: bold;
  min-width: 60px;
}

.color-row-hex {
  font-family: Consolas, 'Roboto Mono', 'SF Mono', Monaco, 'Cascadia Code', 'Liberation Mono', 'Courier New', monospace;
  font-size: 15px;
  flex: 1;
  text-align: center;
}

.color-row-name {
  font-size: 14px;
  text-align: right;
  min-width: 80px;
}

.color-row-copy-icon {
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.color-row:hover .color-row-copy-icon {
  opacity: 1;
}

/* ==========================================
   Responsive
   ========================================== */

@media (max-width: 768px) {
  .top-section {
    grid-template-columns: 1fr;
    gap: 20px;
    margin: 20px 0;
  }

  .palette-results {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .donut-column {
    order: -1;
  }

  .donut-chart {
    justify-content: center;
  }

  .upload-container {
    padding: 30px 16px;
    min-height: 200px;
  }
}

@media (max-width: 480px) {
  .top-section {
    margin: 15px 0;
  }

  .preview-card,
  .actions-card {
    padding: 16px;
  }

  .image-preview-img {
    max-height: 220px;
  }

  .color-row {
    padding: 10px 12px;
    gap: 8px;
  }

  .color-row-percentage {
    font-size: 13px;
    min-width: 45px;
  }

  .color-row-hex {
    font-size: 13px;
  }

  .color-row-name {
    font-size: 12px;
    min-width: 50px;
  }

  .actions-btn {
    font-size: 14px;
    padding: 10px 12px;
  }

  .export-modal {
    padding: 20px;
    max-width: 100%;
  }

  .export-modal-grid {
    gap: 10px;
  }

  .export-tile {
    padding: 12px 6px;
    min-height: 80px;
  }

  .export-tile svg {
    width: 28px;
    height: 28px;
  }

  .export-tile span {
    font-size: 12px;
  }
}

@media (max-width: 270px) {
  .color-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .color-row-percentage {
    min-width: auto;
  }

  .color-row-hex {
    flex: none;
  }

  .color-row-name {
    min-width: auto;
    text-align: left;
  }

  .color-row-copy-icon {
    position: absolute;
    top: 10px;
    right: 12px;
  }
}
