/* ========== Color Converter Tool Page ========== */
.tool-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.tool-header {
  text-align: center;
  margin-bottom: 24px;
}

.tool-header h1 {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-heading);
  margin-bottom: 8px;
}

.tool-header .tool-desc {
  font-size: 16px;
  color: var(--color-muted);
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Color Preview Bar */
.color-preview-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  align-items: stretch;
}

.color-swatch-main {
  flex: 0 0 120px;
  border-radius: 12px;
  border: 2px solid var(--color-border);
  transition: background-color 0.15s;
  position: relative;
  min-height: 100px;
}

.color-values-panel {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.color-value-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.color-value-item:hover {
  border-color: var(--color-primary);
  background: var(--color-bg-active);
}

.color-value-item .cv-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  min-width: 40px;
}

.color-value-item .cv-value {
  font-size: 13px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  color: var(--color-text);
  word-break: break-all;
  flex: 1;
}

.color-value-item .cv-copy {
  font-size: 11px;
  color: var(--color-muted);
  opacity: 0;
  transition: opacity 0.15s;
}

.color-value-item:hover .cv-copy {
  opacity: 1;
}

/* Input section */
.color-input-section {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.color-input-section input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 12px 16px;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  font-size: 16px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
  color: #1e293b;
}

.color-input-section input[type="text"]:focus {
  border-color: var(--color-primary);
}

.color-input-section input[type="color"] {
  width: 48px;
  height: 48px;
  padding: 0;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  background: none;
}

.color-input-section .color-input-actions {
  display: flex;
  gap: 8px;
}

/* Buttons */
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tool-btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.tool-btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.tool-btn-secondary {
  background: #10b981;
  color: #fff;
}

.tool-btn-secondary:hover {
  background: #059669;
}

.tool-btn-purple {
  background: #8b5cf6;
  color: #fff;
}

.tool-btn-purple:hover {
  background: #7c3aed;
}

.tool-btn-danger {
  background: #ef4444;
  color: #fff;
}

.tool-btn-danger:hover {
  background: #dc2626;
}

/* Split layout */
.color-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.color-section-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
}

.color-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.color-section-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-heading);
}

/* Color Picker Canvas */
.color-picker-area {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.color-wheel-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  aspect-ratio: 1;
}

.color-wheel-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  cursor: crosshair;
}

/* Horizontal HSL sliders below color wheel, 3 columns side by side */
.color-sliders-horizontal {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  padding: 4px 0;
}

.color-sliders-horizontal .color-slider-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.color-sliders-horizontal .color-slider-wrap label {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-muted);
}

.color-sliders-horizontal input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 3px;
  cursor: pointer;
  outline: none;
  padding: 0;
  margin: 0;
}

.color-sliders-horizontal input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #333;
  cursor: pointer;
}

.color-sliders-horizontal .slider-val {
  font-size: 11px;
  font-family: monospace;
  color: var(--color-muted);
  min-width: 22px;
  text-align: center;
}

.color-slider-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-slider-wrap label {
  font-size: 12px;
  color: var(--color-muted);
  min-width: 16px;
}

.color-slider-wrap input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 3px;
  background: linear-gradient(to right, #000, #fff);
  outline: none;
  cursor: pointer;
}

.color-slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #333;
  cursor: pointer;
}

.slider-hue {
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%) !important;
}

.slider-sat {
  background: linear-gradient(to right, #808080, var(--slider-color)) !important;
}

.slider-lig {
  background: linear-gradient(to right, #000, var(--slider-color), #fff) !important;
}

/* Color Named Detection */
.color-named-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  background: #dbeafe;
  color: #1e40af;
  margin-top: 4px;
}

/* Tints & Shades */
.tints-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 12px;
}

.tints-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.tints-row-label {
  font-size: 11px;
  color: var(--color-muted);
  min-width: 36px;
  text-align: right;
  font-weight: 600;
}

.tint-block {
  flex: 1;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s;
  border: 1px solid rgba(0,0,0,0.08);
}

.tint-block:hover {
  transform: scaleY(1.2);
  z-index: 2;
}

.tint-block .tint-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  white-space: nowrap;
  z-index: 5;
}

.tint-block:hover .tint-tooltip {
  display: block;
}

/* Scheme section */
.scheme-section {
  padding: 12px;
}

.scheme-type-selector {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f3f4f6;
  border-radius: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.scheme-type-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  color: #6b7280;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.scheme-type-btn:hover {
  color: #374151;
}

.scheme-type-btn.active {
  background: #fff;
  color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.scheme-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.scheme-color-block {
  flex: 1;
  min-width: 60px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s;
  border: 2px solid transparent;
}

.scheme-color-block:hover {
  transform: scale(1.08);
  border-color: var(--color-primary);
}

.scheme-color-block .scheme-label {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  font-size: 11px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  text-align: center;
  font-family: monospace;
  word-break: break-all;
}

/* History */
.history-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  flex-wrap: wrap;
  align-items: center;
  min-height: 40px;
}

.history-bar-label {
  font-size: 12px;
  color: var(--color-muted);
  font-weight: 600;
  margin-right: 4px;
}

.history-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--color-border);
  transition: transform 0.1s;
}

.history-swatch:hover {
  transform: scale(1.2);
  border-color: var(--color-primary);
}

.history-swatch.selected {
  border: 2px solid var(--color-primary);
}

/* WCAG */
.wcag-section {
  padding: 12px;
}

.wcag-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #fff;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--color-border);
}

.wcag-bg-preview {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid #ddd;
  flex-shrink: 0;
}

.wcag-fg-preview {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}

.wcag-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.wcag-badge-aaa {
  background: #d1fae5;
  color: #065f46;
}

.wcag-badge-aa {
  background: #dbeafe;
  color: #1e40af;
}

.wcag-badge-fail {
  background: #fef2f2;
  color: #991b1b;
}

/* Favorites */
.favorites-section {
  padding: 12px;
}

.favorites-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.fav-swatch {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--color-border);
  transition: transform 0.1s;
  position: relative;
}

.fav-swatch:hover {
  transform: scale(1.1);
}

.fav-swatch .fav-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 10px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.fav-swatch:hover .fav-del {
  display: flex;
}

.fav-value {
  font-size: 10px;
  color: var(--color-muted);
  font-family: monospace;
}

/* Status */
.status-box {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  display: none;
}

.status-box.show {
  display: block;
}

.status-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #16a34a;
}

.status-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
}

.status-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

/* Info section */
.tool-info {
  margin-top: 32px;
  padding: 24px;
  background: var(--color-bg-card);
  border-radius: 12px;
  border: 1px solid var(--color-border);
}

.tool-info h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-heading);
  margin-bottom: 16px;
}

.tool-info h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-heading);
  margin: 20px 0 12px;
}

.tool-info p {
  font-size: 15px;
  color: var(--color-text);
  line-height: 1.8;
  margin-bottom: 12px;
}

.tool-info ul {
  margin: 0 0 16px 0;
  padding-inline-start: 24px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--color-text);
}

.tool-info li {
  margin-bottom: 6px;
}

.tool-info code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  color: #be185d;
}

.tool-info .info-tip {
  padding: 12px 16px;
  background: #eff6ff;
  border-radius: 8px;
  color: #1e40af;
  margin-top: 16px;
}

/* Two column responsive layout */
.two-col-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.color-picker-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.color-picker-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
}

.color-picker-right::-webkit-scrollbar {
  width: 4px;
}

.color-picker-right::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

/* Right column compact styles */
.color-picker-right .color-section-card {
  margin-bottom: 0;
}

/* 2×2 values grid for right column */
.color-values-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.color-values-2x2 .color-value-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.color-values-2x2 .color-value-item:hover {
  border-color: var(--color-primary);
  background: var(--color-bg-active);
}

.color-values-2x2 .color-value-item .cv-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  min-width: 36px;
}

.color-values-2x2 .color-value-item .cv-value {
  font-size: 11px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  color: var(--color-text);
  word-break: break-all;
  flex: 1;
}

.color-values-2x2 .color-value-item .cv-copy {
  font-size: 10px;
  color: var(--color-muted);
  opacity: 0;
  transition: opacity 0.15s;
}

.color-values-2x2 .color-value-item:hover .cv-copy {
  opacity: 1;
}

/* Standalone color swatch (small) */
.color-swatch-small {
  width: 100%;
  height: 60px;
  border-radius: 10px;
  border: 2px solid var(--color-border);
  transition: background-color 0.15s;
}

/* Favorites section in right column */
.color-picker-right .favorites-section {
  padding: 12px;
}

.color-picker-right .favorites-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* History section in right column - stacked vertically */
.history-section-inner {
  padding: 8px 12px;
}

/* Responsive */
@media (max-width: 960px) {
  .two-col-layout {
    grid-template-columns: 1fr;
  }
  .color-picker-right {
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
  }
  .color-sliders-horizontal {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 960px) and (min-width: 601px) {
  .color-picker-area {
    flex-direction: column;
    align-items: center;
  }
  .color-sliders-horizontal {
    grid-template-columns: 1fr 1fr 1fr;
    width: 100%;
  }
  .color-sliders-horizontal input[type="range"] {
    height: 6px;
    width: 100%;
  }
  .color-sliders-horizontal .color-slider-wrap {
    flex-direction: column;
    gap: 4px;
  }
  .color-values-2x2 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .tool-container {
    padding: 16px;
  }
  .tool-header h1 {
    font-size: 24px;
  }
  .color-values-panel {
    grid-template-columns: 1fr;
  }
  .tool-btn {
    padding: 6px 12px;
    font-size: 12px;
  }
  .color-picker-area {
    flex-direction: column;
    align-items: center;
  }
  .color-sliders-horizontal {
    grid-template-columns: 1fr 1fr 1fr;
    width: 100%;
  }
  .color-sliders-horizontal input[type="range"] {
    height: 6px;
    width: 100%;
  }
  .color-sliders-horizontal .color-slider-wrap {
    flex-direction: column;
    gap: 4px;
  }
  .color-values-2x2 {
    grid-template-columns: 1fr;
  }
  .color-swatch-small {
    height: 48px;
  }
}
/* ===== RTL fix (Arabic) ===== */
/* Force LTR for color value inputs/displays to avoid bidi scrambling */
#inputColor,
#wcagBgInput,
#wcagFgInput,
.color-values-2x2 .color-value-item .cv-value,
.tint-block .tint-tooltip,
.scheme-color-block .scheme-label,
.fav-value {
  direction: ltr;
  unicode-bidi: isolate;
}
