/* Hair Color  Generator styles */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #f4f6f8;
  color: #1f2937;
  line-height: 1.6;
}

/* ---------- Two-pane layout: 25% sidebar + 75% main ---------- */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 25%;
  min-width: 230px;
  background-color: #ffffff;
  border-right: 1px solid #e5e7eb;
  padding: 20px 16px;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-title {
  font-size: 1.05rem;
  margin-bottom: 2px;
}

.sidebar-hint {
  color: #6b7280;
  font-size: 0.82rem;
  margin-bottom: 14px;
}

.main-area {
  flex: 1;
  padding: 24px 32px 48px;
  max-width: 900px;
}

header h1 {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.subtitle {
  color: #6b7280;
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.key-link {
  display: inline-block;
  margin-left: 8px;
  color: #2563eb;
  text-decoration: none;
  font-size: 0.88rem;
  transition: color 0.15s ease;
}

.key-link:hover {
  color: #1e40af;
  text-decoration: underline;
}

.card {
  background-color: #ffffff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 24px;
}

.card h2 {
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

/* ---------- Color swatch grid ---------- */

.selected-color-name {
  font-weight: 600;
  color: #2563eb;
  margin-left: 4px;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.color-category-label {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  margin-top: 10px;
}

.color-category-label:first-child {
  margin-top: 0;
}

.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.swatch-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.swatch:hover .swatch-circle {
  transform: scale(1.08);
}

.swatch.selected .swatch-circle {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25), inset 0 2px 6px rgba(0, 0, 0, 0.25);
  transform: scale(1.08);
}

.swatch-name {
  font-size: 0.6rem;
  line-height: 1.15;
  text-align: center;
  color: #4b5563;
  max-width: 60px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.swatch.selected .swatch-name {
  color: #2563eb;
  font-weight: 600;
}

/* ---------- Drop zone ---------- */

.drop-zone {
  border: 2px dashed #c7d2e0;
  border-radius: 12px;
  background-color: #fafbfc;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  padding: 24px;
  position: relative;
}

.drop-zone:hover {
  border-color: #9db4d0;
}

.drop-zone.dragover {
  border-color: #2563eb;
  background-color: #eff6ff;
}

.drop-emoji {
  font-size: 2.6rem;
  margin-bottom: 8px;
}

.drop-text {
  font-size: 1rem;
  color: #374151;
  font-weight: 500;
}

.drop-or {
  color: #9ca3af;
  font-size: 0.85rem;
  margin: 6px 0 10px;
}

.drop-chips {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.chip-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background-color: #ffffff;
  color: #374151;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.chip-btn:hover {
  background-color: #f3f4f6;
  border-color: #9ca3af;
}

.preview-wrap {
  position: relative;
  width: 100%;
}

#preview {
  max-height: 320px;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  display: block;
  margin: 0 auto;
}

.remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background-color: rgba(0, 0, 0, 0.55);
  color: #ffffff;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.remove-btn:hover {
  background-color: rgba(0, 0, 0, 0.75);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  padding: 10px 20px;
  font-size: 1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background-color 0.15s ease-in-out;
}

.btn-primary {
  background-color: #2563eb;
  color: #fff;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background-color: #1e40af;
}

.btn-primary:disabled {
  background-color: #93b4f8;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: #6b7280;
  color: #fff;
}

.btn-secondary:hover {
  background-color: #4b5563;
}

.selected-shade-note {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #6b7280;
  text-align: center;
}

.selected-shade-note span {
  color: #2563eb;
  font-weight: 600;
}

.actions {
  margin-top: 16px;
  text-align: center;
}

.download-hint {
  margin-top: 10px;
  font-size: 0.82rem;
  color: #9ca3af;
}

/* ---------- Status & error ---------- */

.status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  background-color: #dbeafe;
  color: #1e3a8a;
}

.error {
  padding: 12px 16px;
  border-radius: 8px;
  background-color: #fee2e2;
  color: #991b1b;
  white-space: pre-wrap;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(30, 58, 138, 0.25);
  border-top-color: #1e3a8a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* ---------- Result (single image) ---------- */

.result-container {
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background-color: #fafbfc;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.result-image {
  max-width: 100%;
  max-height: 640px;
  display: block;
  border-radius: 8px;
}

/* ---------- Carousel (legacy styles, container reused) ---------- */

.carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background-color: #fafbfc;
  scrollbar-width: none;              /* Firefox */
  -ms-overflow-style: none;           /* IE/Edge legacy */
}

.carousel::-webkit-scrollbar {
  display: none;                      /* Chrome/Safari */
}

.carousel-panel {
  flex: 0 0 100%;
  scroll-snap-align: center;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.carousel-panel img {
  max-width: 100%;
  max-height: 560px;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.panel-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background-color: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.panel-download {
  position: absolute;
  bottom: 10px;
  right: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  background-color: rgba(37, 99, 235, 0.9);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.panel-download:hover {
  background-color: #1e40af;
  transform: translateY(-1px);
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background-color: #d1d5db;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.carousel-dot.active {
  background-color: #2563eb;
  transform: scale(1.25);
}

/* ---------- API key modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal {
  background-color: #ffffff;
  border-radius: 14px;
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  animation: modalPop 0.25s ease;
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal h2 {
  font-size: 1.25rem;
  margin-bottom: 6px;
}

.modal-subtitle {
  color: #6b7280;
  font-size: 0.88rem;
  margin-bottom: 16px;
}

.modal input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal input[type="password"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.modal-hint {
  display: block;
  text-align: center;
  margin-top: 12px;
  font-size: 0.85rem;
  color: #2563eb;
  text-decoration: none;
}

.modal-hint:hover {
  text-decoration: underline;
}

/* ---------- Loading overlay (blob pulse) ---------- */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  animation: fadeIn 0.3s ease;
}

.blob {
  width: 90px;
  height: 90px;
  background: linear-gradient(135deg, #2563eb, #a855f7, #ec4899);
  border-radius: 50% 40% 60% 50%;
  filter: blur(4px);
  animation: blobPulse 1.6s ease-in-out infinite;
}

@keyframes blobPulse {
  0% {
    transform: rotate(0deg) scale(1);
    border-radius: 50% 40% 60% 50%;
    filter: blur(4px);
  }
  50% {
    transform: rotate(90deg) scale(1.15);
    border-radius: 45% 55% 40% 60%;
    filter: blur(8px);
  }
  100% {
    transform: rotate(180deg) scale(1.25);
    border-radius: 40% 60% 50% 60%;
    filter: blur(12px);
  }
}

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

.loading-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1f2937;
}

/* ---------- Result image ( download fallback) ---------- */

#resultImage {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  display: block;
}

footer {
  text-align: center;
  color: #9ca3af;
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

/* ---------- Responsive ---------- */

@media (max-width: 800px) {
  .layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    max-height: 40vh;
  }
  .main-area {
    padding: 16px;
  }
}
