/* ===== HEX EXTRACTOR - CLEAN EDITION ===== */
/* Dreamweaver Safe • UTF-8 Only • No .btn class • Proper Spacing */

:root {
  --primary: #1EB6DE;
  --primary-dark: #1892B2;
  --light-bg: #F8FCFF;
  --border: #e1e5f1;
  --text: #1e293b;
  --text-light: #475569;
  --card-bg: #ffffff;
  --toast-bg: #2c3e50;
  --danger: #e53e3e;
  --success: #2c7a4d;
  --grid-gap: 10px;
  --swatch-size: 56px;
}

[data-theme="dark"] {
  --primary: #1EB6DE;
  --primary-dark: #1892B2;
  --light-bg: #292b32;
  --border: #4a4a5a;
  --text: #f1f5f9;
  --text-light: #cbd5e1;
  --card-bg: #1e1f28;
  --toast-bg: #111827;
  --danger: #f56565;
  --success: #48bb78;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }
input[type="file"] { display: none; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ===== BUTTONS (No .btn class) ===== */
button, .upload-label {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--light-bg);
  color: var(--text);
  border: 1px solid var(--border);
  min-height: 34px;
  white-space: nowrap;
  text-shadow: none;
  flex-shrink: 0;
  max-width: 100%;
  padding: 0 14px;
}
button:hover, .upload-label:hover {
  border-color: var(--primary) !important;
  background: rgba(30, 182, 222, 0.1);
  color: var(--text);
}
button:active { background: rgba(30, 182, 222, 0.15); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--primary); border-color: var(--primary); color: white; }
button.primary:hover { background: var(--primary-dark); }
button.secondary { background: var(--light-bg); border: 1px solid var(--border); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }

/* ===== MAIN LAYOUT ===== */
.container-custom {
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: 5px;
  box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border);
  overflow: hidden;
  width: 100%;
}
.tool-header { padding: 20px 24px 0 24px; border-bottom: 1px solid var(--border); }
.tool-header-content { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.tool-title { margin: 0; color: var(--primary); font-size: 1.4rem; display: flex; align-items: center; gap: 10px; }
.tool-subtitle { margin: 4px 0 0 0; color: var(--text-light); font-size: 0.9rem; }

.hex-tool-grid { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 20px; 
  padding: 20px 24px; 
  width: 100%; 
}
@media (min-width: 900px) { 
  .hex-tool-grid { grid-template-columns: 320px 1fr; align-items: start; } 
}
.input-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; width: 100%; }
.preview-panel { display: flex; flex-direction: column; gap: 8px; min-width: 0; width: 100%; }

/* ===== INPUT PANEL ===== */
.input-group { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.label-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; font-weight: 500; color: var(--text-light); flex-wrap: wrap; gap: 4px; }
.label-row .error-msg { font-size: 0.75rem; font-weight: 600; color: var(--danger); white-space: nowrap; }
.format-hint { font-size: 0.7rem; color: var(--text-light); opacity: 0.9; }

.text-input {
  width: 100%;
  min-height: 140px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--light-bg);
  color: var(--text);
  font-family: 'SF Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.4;
  resize: vertical;
}
.text-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(30, 182, 222, 0.15); }
.text-input::placeholder { color: var(--text-light); opacity: 0.8; }

/* ===== DROP ZONE ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 5px;
  padding: 32px 24px;
  text-align: center;
  background: var(--light-bg);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--primary); background: rgba(30, 182, 222, 0.08); }
.drop-zone-icon { font-size: 40px; margin: 0 auto 12px auto; display: block; color: var(--primary); opacity: 0.9; }
.drop-zone-title { font-size: 16px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.drop-zone-subtitle { color: var(--text-light); font-size: 13px; }

.drop-zone-filename {
  display: none;
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
  margin-top: 8px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drop-zone-filename.show { display: block; }

/* ===== ACTIONS & STATS ===== */
.actions-row { display: flex; justify-content: flex-end; gap: 8px; }
.stats-section { display: flex; gap: 16px; padding: 8px 0; border-top: 1px dashed var(--border); }
.stat-item { display: flex; gap: 4px; font-size: 0.85rem; }
.stat-label { color: var(--text-light); }
.stat-value { font-weight: 600; color: var(--text); }

/* ===== PREVIEW PANEL ===== */
.preview-panel { min-height: 400px; }
.section-title-custom { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }

/* ===== COLOR GRID (for flat extraction) ===== */
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--swatch-size), 1fr));
  gap: var(--grid-gap);
  width: 100%;
  padding: 4px 0;
}
.grid-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-light);
  text-align: center;
  gap: 12px;
}
.grid-empty i { font-size: 2rem; opacity: 0.6; }
.grid-empty p { font-size: 0.9rem; margin: 0; }

.color-swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  position: relative;
  transition: opacity 0.15s;
}
.color-swatch:hover { opacity: 0.9; }
.color-swatch::after {
  content: attr(data-hex);
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  font-family: monospace;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  white-space: nowrap;
}
.color-swatch:hover::after { opacity: 1; }
.color-swatch.light-text::after { color: #0f172a; text-shadow: 0 1px 2px rgba(255,255,255,0.9); }





/* ===== SIMPLIFIED PALETTE DISPLAY ===== */
/* Dreamweaver Safe • No .btn class • UTF-8 Only • No hex labels below */

/* Palette row container */
.palette-row {
  display: block;
  width: 100%;
  margin-bottom: 5px;
  padding: 0 4px;
}
.palette-row:last-child { margin-bottom: 0; }

/* Palette title - NO ICON */
.palette-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  padding: 0 4px;
  /* Removed: display:flex, gap, icon styling */
}

/* Palette bar - horizontal swatch strip */
.palette-bar {
  display: flex;
  gap: 0;
  border-radius: 4px;
  overflow: hidden;
  height: 44px;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--light-bg);
}

/* Individual swatch */
.swatch {
  flex: 1;
  min-width: 28px;
  height: 100%;
  cursor: pointer;
  position: relative;
  transition: flex 0.25s ease;
  border: none;
  padding: 0;
  background: transparent;
  border-radius: 0;
  will-change: auto;
  backface-visibility: hidden;
}
.swatch:hover {
  flex: 1.5;
  z-index: 2;
}
.swatch:first-child { border-radius: 3px 0 0 3px; }
.swatch:last-child { border-radius: 0 3px 3px 0; }

/* Center bullet on hover/active */
.swatch:hover::after,
.swatch.active::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  z-index: 3;
  pointer-events: none;
}
.swatch:hover.light-bullet::after,
.swatch.active.light-bullet::after { background: #0f172a; }
.swatch:hover.dark-bullet::after,
.swatch.active.dark-bullet::after { background: #ffffff; }

/* ✅ REMOVED: .palette-hexes and .hex-label styles */
/* (Hex labels below palette are no longer rendered) */

/* Responsive */
@media (max-width: 600px) {
  .palette-bar { height: 36px; }
  .swatch:hover { flex: 1.3; }
}





/* Quick Sample Examples */
.sample-examples {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 0.8rem;
}
.sample-label {
  color: var(--text-light);
  font-weight: 500;
}
.he-sample-btn {
  font-size: 0.8rem;
  min-height: 28px;
  padding: 0 10px;
  background: var(--light-bg);
}
.he-sample-btn:hover {
  background: rgba(30, 182, 222, 0.1);
  border-color: var(--primary);
}
@media (max-width: 600px) {
  .sample-examples { flex-direction: column; align-items: flex-start; gap: 6px; }
  .he-sample-btn { width: 100%; justify-content: center; }
}






/* ===== EXPORT DROPDOWN ===== */
.export-wrapper-custom { position: relative; display: inline-block; }
.export-menu-custom {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  min-width: 210px;
  z-index: 1000;
  display: none;
  padding: 6px;
}
.export-wrapper-custom.open .export-menu-custom { display: block !important; }

.export-menu-item {
  display: flex !important;
  justify-content: flex-start !important;
  align-items: center;
  text-align: left !important;
  width: 100%;
  padding: 8px 12px;
  margin: 2px 0;
  background: transparent !important;
  border: none !important;
  border-radius: 4px;
  color: var(--text) !important;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  gap: 10px;
  min-height: auto !important;
  box-shadow: none !important;
  transition: background 0.15s, color 0.15s;
}
.export-menu-item:hover { background: var(--light-bg) !important; color: var(--primary) !important; }
.export-menu-item i { width: 16px; text-align: center; color: var(--text-light); }
.export-menu-item:hover i { color: var(--primary) !important; }
.export-wrapper-custom.open #heExportBtn .fa-chevron-down { transform: rotate(180deg); transition: transform 0.2s; }

/* ===== TOAST ===== */
#heToastContainer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  max-width: calc(100% - 40px);
}
.toast {
  background: var(--toast-bg);
  color: white;
  padding: 10px 16px;
  border-radius: 5px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  pointer-events: auto;
  max-width: 300px;
  border-left: 4px solid var(--primary);
  animation: toastSlideUp 0.25s ease, toastFadeOut 0.25s ease 2.5s forwards;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--info); }
@keyframes toastSlideUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastFadeOut { to { opacity: 0; transform: translateY(8px); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 899px) {
  .hex-tool-grid { padding: 16px; }
  .color-grid { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
  .btn-group { width: 100%; justify-content: center; }
  .btn-group button { flex: 1; }
}
@media (max-width: 600px) {
  .container-custom { border-radius: 0; }
  .tool-header { padding: 16px 12px 0 12px; }
  .tool-header-content { flex-direction: column; align-items: stretch; }
  .hex-tool-grid { padding: 12px; gap: 16px; }
  .color-grid { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
  .palette-bar { height: 36px; }
  .hex-label { font-size: 0.6rem; padding: 3px 1px; }
  #heToastContainer { left: 12px; right: 12px; bottom: 12px; width: auto; }
  .toast { max-width: none; width: 100%; }
}