/* tools/color-converter/css/style.css */

/* ── Two-column layout ─────────────────────────────────────────── */
#color-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  flex: 1;
  min-height: 0;
}
#left-column {
  display: contents;
}
#right-column {
  display: contents;
}
#formats-section {
  grid-column: 1;
  grid-row: 1;
  border-right: 2px solid #45475a;
}
#contrast-section {
  grid-column: 2;
  grid-row: 1;
}
#palette-section {
  grid-column: 1 / -1;
  grid-row: 2;
}

/* ── Color Preview ─────────────────────────────────────────────── */
#preview-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px 16px;
  background: #181825;
  border-bottom: 2px solid #313244;
  gap: 12px;
}

#color-swatch {
  width: 100%;
  height: 100px;
  border-radius: 10px;
  border: 2px solid #45475a;
  background: #89b4fa;
  transition: background 0.1s;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

#preview-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

#color-picker {
  width: 0;
  height: 0;
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

#picker-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #313244;
  color: #cdd6f4;
  border: 1px solid #45475a;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
#picker-label:hover { background: #45475a; border-color: #89b4fa; }
#picker-icon { font-size: 16px; }

/* ── Sections shared ───────────────────────────────────────────── */
section {
  padding: 16px 24px;
  border-bottom: 2px solid #313244;
  background: #1e1e2e;
}

.section-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: #6c7086;
  text-transform: uppercase;
  margin-bottom: 14px;
}

/* ── Format Fields ─────────────────────────────────────────────── */
#formats-section {
  background: #1e1e2e;
}

.format-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.format-row:last-of-type { margin-bottom: 0; }

.format-label {
  width: 68px;
  font-size: 12px;
  font-weight: 600;
  color: #a6adc8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.format-input {
  flex: 1;
  background: #181825;
  color: #cdd6f4;
  border: 1px solid #45475a;
  border-radius: 5px;
  padding: 7px 12px;
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  max-width: 100%;
}
.format-input:focus { border-color: #89b4fa; }
.format-input[readonly] { color: #89b4fa; cursor: default; }
.format-input.invalid { border-color: #f38ba8; color: #f38ba8; }

.copy-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 6px 8px;
  border-radius: 4px;
  color: #6c7086;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.copy-btn:hover { color: #89b4fa; background: #313244; }
.copy-btn.copied { color: #a6e3a1; }

#copy-status {
  margin-top: 8px;
  font-size: 12px;
  color: #a6e3a1;
  min-height: 18px;
}

/* ── Contrast Checker ──────────────────────────────────────────── */
#contrast-section { background: #181825; }

#contrast-inputs {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.contrast-color-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.contrast-color-label {
  font-size: 11px;
  color: #6c7086;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.contrast-swatch-wrap {
  position: relative;
  width: 48px;
  height: 48px;
}

.contrast-swatch {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 2px solid #45475a;
  cursor: pointer;
  transition: border-color 0.15s;
}
.contrast-swatch:hover { border-color: #89b4fa; }

.contrast-picker {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border: none;
  padding: 0;
}

.contrast-hex-input {
  width: 80px;
  background: #1e1e2e;
  color: #cdd6f4;
  border: 1px solid #45475a;
  border-radius: 4px;
  padding: 4px 6px;
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 12px;
  outline: none;
  text-align: center;
  transition: border-color 0.15s;
}
.contrast-hex-input:focus { border-color: #89b4fa; }
.contrast-hex-input.invalid { border-color: #f38ba8; }

.contrast-on {
  font-size: 13px;
  color: #6c7086;
  padding-bottom: 28px;
  font-style: italic;
}

#contrast-ratio-display {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin-left: 12px;
  padding-bottom: 4px;
}

#contrast-ratio-value {
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 32px;
  font-weight: 700;
  color: #cdd6f4;
  line-height: 1;
}

#contrast-ratio-label {
  font-size: 16px;
  color: #6c7086;
}

#contrast-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.wcag-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid #45475a;
  color: #6c7086;
  background: #1e1e2e;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.wcag-badge.pass {
  background: #1e3a2a;
  border-color: #a6e3a1;
  color: #a6e3a1;
}
.wcag-badge.fail {
  background: #3a1e22;
  border-color: #f38ba8;
  color: #f38ba8;
}

/* WCAG badge tooltips (using child span to avoid conflict with ::after ✓/✗) */
.wcag-badge {
  position: relative;
  cursor: help;
}
.wcag-badge .badge-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: #11111b;
  color: #cdd6f4;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #45475a;
  white-space: normal;
  width: 220px;
  line-height: 1.5;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  pointer-events: none;
}
.wcag-badge:hover .badge-tooltip { display: block; }

.wcag-badge::after { content: ''; }
.wcag-badge.pass::after { content: ' ✓'; }
.wcag-badge.fail::after { content: ' ✗'; }

#contrast-preview {
  border-radius: 6px;
  padding: 14px 16px;
  border: 1px solid #45475a;
  transition: background 0.1s;
}

#contrast-preview-text {
  font-size: 14px;
  line-height: 1.6;
}

/* ── Palette ───────────────────────────────────────────────────── */
#palette-section { background: #1e1e2e; }

#palette-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.palette-tab {
  background: #313244;
  color: #a6adc8;
  border: 1px solid #45475a;
  border-radius: 4px;
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.palette-tab:hover { background: #45475a; color: #cdd6f4; }
.palette-tab.active {
  background: #89b4fa;
  color: #1e1e2e;
  border-color: #89b4fa;
  font-weight: 600;
}

#palette-swatches {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.palette-swatch {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  border: 2px solid #45475a;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  overflow: visible;
}
.palette-swatch:hover {
  transform: translateY(-3px);
  border-color: #cdd6f4;
}
.palette-swatch:hover .swatch-tooltip {
  opacity: 1;
  transform: translateY(-4px);
}

.swatch-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: #11111b;
  color: #cdd6f4;
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid #45475a;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 10;
}
