/* PigmentMind — Stili principali + responsive + dark mode */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg-page: #f0f2f5;
  --bg-card: #fff;
  --bg-panel: #fafbfc;
  --text: #444;
  --text-strong: #222;
  --text-muted: #666;
  --text-dim: #888;
  --border: #eee;
  --border-input: #e0e0e0;
  --accent: #3366ff;
  --accent-text: #fff;
  --btn-bg: #fff;
  --btn-border: #e0e0e0;
  --tooltip-bg: #fff;
  --success: #22c55e;
  --header-bg: #fff;
}

[data-theme="dark"] {
  --bg-page: #1a1a1e;
  --bg-card: #25252a;
  --bg-panel: #2d2d33;
  --text: #e0e0e0;
  --text-strong: #f0f0f0;
  --text-muted: #b0b0b0;
  --text-dim: #888;
  --border: #3d3d45;
  --border-input: #4a4a52;
  --accent: #5b8def;
  --accent-text: #fff;
  --btn-bg: #2d2d33;
  --btn-border: #4a4a52;
  --tooltip-bg: #2d2d33;
  --success: #34d399;
  --header-bg: #25252a;
}

body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-page);
  line-height: 1.4;
  transition: background 0.2s ease, color 0.2s ease;
}

a:link { font-weight: 500; color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a.small { font-weight: normal; }

ul { padding: 0 0 0 16px; margin: 2px 0 0; }
li { margin: 0; padding: 2px 0 0; }

/* Main card container - larghezza contenuta */
.app-card {
  width: 92%;
  max-width: 880px;
  margin: 24px auto;
  background: var(--bg-card);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-wrap: wrap;
  transition: background 0.2s ease;
}

/* Header */
#Header {
  width: 100%;
  padding: 16px 24px;
  background: var(--header-bg);
  color: var(--text-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  transition: background 0.2s ease;
}

#Header .header-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

#Header .header-logo {
  display: block;
  height: 48px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

/* Toggle tema */
.theme-toggle {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border-input);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
  background: var(--border);
}

.theme-toggle svg {
  width: 22px;
  height: 22px;
}

.theme-toggle .icon-dark { display: none; }
.theme-toggle .icon-light { display: block; }

[data-theme="dark"] .theme-toggle .icon-dark { display: block; }
[data-theme="dark"] .theme-toggle .icon-light { display: none; }

#Header .header-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
}

#Header .headSmall {
  margin: 0;
  font-size: 13px;
  font-weight: normal;
  color: #666;
}

/* Left panel - Base color */
#ColorInput {
  width: 200px;
  min-width: 200px;
  border: none;
  border-right: 1px solid var(--border);
  padding: 20px;
  background: var(--bg-panel);
  font-size: 13px;
  color: var(--text);
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease;
}

#ColorInput .sideHead {
  display: none;
}

#ColorInput .currentBorder {
  border: none;
  margin: 0 0 12px;
  text-align: center;
}

#ColorInput .currentBorder:first-of-type {
  margin-bottom: 16px;
}

/* Large color swatch - rotondo */
#currentColor {
  width: 140px;
  height: 140px;
  margin: 0 auto;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: block;
}

/* Hex display - bold, prominent */
.hex-display {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: 0.02em;
  margin: 12px 0 4px;
}

/* Pulsante Copia (un solo bottone) */
.copy-row {
  margin-bottom: 16px;
}

.btn-copy-text {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-input);
  background: var(--btn-bg);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.btn-copy-text.copied {
  border-color: var(--success);
  color: var(--success);
}

.btn-copy-text.copied .copy-icon {
  color: var(--success);
}

/* Form inputs in left panel */
#ColorInput .navBox {
  border: none;
  padding: 0;
  background: transparent;
}

#ColorInput .rgbBox {
  width: 40px;
  font-size: 13px;
  color: var(--text);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  padding: 4px 6px;
  text-align: center;
  background: var(--btn-bg);
}

#ColorInput .hexBox {
  width: 72px;
  font-size: 13px;
  border: 1px solid var(--border-input);
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--btn-bg);
  color: var(--text);
}

#ColorInput .button {
  height: 32px;
  min-width: 80px;
  margin: 4px 4px 4px 0;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border-input);
  background: var(--btn-bg);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

#ColorInput form.compact-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

#ColorInput .hex-label {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  color: var(--text);
}

#ColorInput .hex-label .hexBox {
  margin-left: 2px;
}

/* Right area - Wheel + palette: occupa tutto lo spazio restante */
.wheel-area {
  flex: 1 1 0;
  min-width: 0; /* permette alla griglia di riempire tutta la larghezza disponibile */
  padding: 20px 24px;
}

/* Section title + pills */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-strong);
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-title .info-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
}

.pills-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-btn {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-input);
  background: var(--bg-panel);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.pill-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* Harmony tabs */
.harmony-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.harmony-tab {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-input);
  background: var(--btn-bg);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.harmony-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* Wheel - grid of swatches */
#Wheel {
  position: relative;
  border: none;
  height: auto;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 0;
  margin: 0;
}

#Wheel .swatch {
  position: relative;
  padding: 0;
  width: 100%;
  text-align: center;
}

#Wheel .border {
  border: none;
  height: auto;
  width: 100%;
  margin: 0 auto;
}

#Wheel .color {
  aspect-ratio: 1;
  width: 100%;
  height: auto;
  max-width: 100px;
  margin: 0 auto;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: block;
}

#Wheel .rgb {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

#Wheel .hex {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-top: 2px;
}

/* Swatch positions - overridden by grid; keep IDs for JS */
#swatch0, #swatch1, #swatch2, #swatch3,
#swatch4, #swatch5, #swatch6, #swatch7,
#swatch8, #swatch9, #swatch10, #swatch11,
#swatchm1, #swatchm2, #swatchm3, #swatchm4 {
  position: relative;
  left: auto;
  top: auto;
}

/* Palette grid (bottom) */
#palette {
  position: relative;
  top: auto;
  left: auto;
  width: 100%;
  flex: 0 0 100%;
  padding: 0 24px 24px;
}

#palette table {
  border: none;
  border-spacing: 3px;
  background: transparent;
}

#palette td {
  height: 20px;
  width: 20px;
  border-radius: 6px;
  overflow: hidden;
}

#palette a {
  display: block;
  width: 100%;
  height: 100%;
}

#palette img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Context tooltip for "Usa come base" */
.swatch-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 8px 12px;
  background: var(--tooltip-bg);
  border: 1px solid var(--border-input);
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  color: var(--text);
  transition: opacity 0.2s;
}

.swatch:hover .swatch-tooltip {
  opacity: 1;
}

.swatch-tooltip .use-base {
  display: block;
  margin-top: 6px;
  padding: 4px 0;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .app-card {
    width: 100%;
    margin: 12px 0;
    border-radius: 0;
  }

  body {
    font-size: 15px;
  }

  #Header {
    padding: 12px 16px;
  }

  #Header .header-logo {
    height: 40px;
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
  }

  #ColorInput {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    justify-content: center;
  }

  #ColorInput .currentBorder {
    margin: 0;
    order: -1;
    width: 100%;
  }

  #currentColor {
    width: 100px;
    height: 100px;
  }

  #ColorInput .hex-display {
    margin: 0 8px 0 0;
    font-size: 18px;
  }

  .copy-row {
    margin: 0;
  }

  #ColorInput form.compact-form {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }

  .wheel-area {
    padding: 16px;
    min-width: 0;
  }

  #Wheel {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  #Wheel .color {
    max-width: 72px;
  }

  #Wheel .hex,
  #Wheel .rgb {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  #Header {
    padding: 10px 12px;
  }

  #Header .header-logo {
    height: 36px;
  }

  #ColorInput {
    padding: 12px;
    flex-direction: column;
  }

  #currentColor {
    width: 88px;
    height: 88px;
  }

  #ColorInput .hex-display {
    font-size: 16px;
  }

  .wheel-area {
    padding: 12px;
  }

  #Wheel {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  #Wheel .color {
    max-width: 100%;
  }
}

