/* ── Reset & Base ── */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --panel:     #161b22;
  --border:    #30363d;
  --text:      #e6edf3;
  --muted:     #8b949e;
  --accent:    #58a6ff;
  --green:     #3fb950;
  --red:       #f85149;
  --yellow:    #d29922;
  --purple:    #bc8cff;
  --radius:    12px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#header-left { display: flex; align-items: center; gap: 12px; }
#back-btn {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: color .2s, border-color .2s;
}
#back-btn:hover { color: var(--text); border-color: var(--accent); }

#header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

#header-badge {
  margin-left: 12px;
  font-size: 0.72rem;
  color: var(--muted);
  background: #21262d;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

#score-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #21262d;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 18px;
}

#score-label { font-size: 0.8rem; color: var(--muted); }
#score-val   { font-size: 1.1rem; font-weight: 700; color: var(--text); }
#score-pct   { font-size: 1rem; font-weight: 600; color: var(--green); }

/* ── Main layout (3 colunas) ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#main-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

/* ── Painéis genéricos ── */
#left-panel, #right-panel {
  padding: 20px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

#right-panel { border-right: none; }

/* ── Fruta card ── */
#fruit-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

#fruit-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

#fruit-emoji {
  font-size: 3.5rem;
  line-height: 1;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

#fruit-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#fruit-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Badge de modo ── */
.mode-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid;
  width: fit-content;
}
.mode-fruit    { color: #f85149; border-color: #f8514940; background: #f8514910; }
.mode-surprise { color: var(--purple); border-color: #bc8cff40; background: #bc8cff10; }
.mode-free     { color: var(--accent); border-color: #58a6ff40; background: #58a6ff10; }

/* ── Presets rápidos ── */
#preset-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.preset-label {
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
}

.preset-btn {
  flex: 1;
  min-width: 0;
  padding: 5px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #21262d;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preset-btn:hover  { border-color: var(--accent); color: var(--text); }
.preset-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(88,166,255,.12); }
.preset-free       { color: var(--accent) !important; border-color: #58a6ff40 !important; }
.preset-free.active { background: rgba(88,166,255,.18) !important; }

/* ── Sliders de features (sem preview ao lado) ── */
#sliders-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

/* ── Preview + chute lado a lado ── */
#guess-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 10px;
}

#fruit-preview-wrap {
  flex: 0 0 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#fruit-preview {
  width: 110px;
  height: 110px;
  display: block;
  border-radius: 12px;
  background: #0d1117;
  border: 1px solid var(--border);
}

#preview-hint {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

.slider-row {
  background: #21262d;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .2s;
}
.slider-row:hover { border-color: var(--accent); }

.slider-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slider-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}

.slider-val {
  font-size: 10px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  color: var(--accent);
  min-width: 80px;
  text-align: right;
}

/* Wrap para os markers ficarem abaixo do range */
.slider-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--bg);
  box-shadow: 0 0 0 2px rgba(255,255,255,.3), 0 2px 6px rgba(0,0,0,.4);
  cursor: grab;
  transition: transform .1s;
}
input[type=range]::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.2);
}

/* Markers: posição de cada fruta em cada eixo */
.slider-markers {
  position: relative;
  height: 14px;
}
.slider-mark {
  position: absolute;
  font-size: 10px;
  line-height: 1;
  top: 0;
  cursor: default;
  opacity: 0.7;
  transition: opacity .2s;
}
.slider-mark:hover { opacity: 1; }

.slider-desc {
  font-size: 9px;
  color: var(--muted);
  line-height: 1.4;
}

/* ── Conta ao vivo ── */
#conta-box {
  background: #21262d;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  margin-bottom: 10px;
}

.conta-title {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 3px;
  font-family: 'Segoe UI', sans-serif;
}

.conta-row {
  color: var(--muted);
  transition: color .15s, font-weight .15s;
  white-space: pre;
  font-size: 10.5px;
}

.conta-sep {
  height: 1px;
  background: var(--border);
  margin: 3px 0;
}

.conta-eq {
  font-size: 9.5px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
}

.conta-total {
  font-size: 11.5px;
  font-weight: 700;
  margin-top: 1px;
}

/* —— IA guess (agora no guess-row, ocupa o resto) —— */
#ia-guess-box {
  --conf-color: var(--border);
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: center;
  transition: border-color .3s, box-shadow .3s;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#ia-guess-box.conf-high {
  border-color: var(--conf-color);
  box-shadow: 0 0 14px color-mix(in srgb, var(--conf-color) 40%, transparent);
}
#ia-guess-box.conf-med {
  border-color: var(--conf-color);
  box-shadow: 0 0 8px rgba(210,153,34,.25);
}
#ia-guess-box.conf-low {
  border-color: #f8514950;
}

#ia-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

#ia-guess-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

#ia-guess-emoji {
  font-size: 2.8rem;
  line-height: 1;
}

#ia-guess-right {
  text-align: left;
}

#ia-guess-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

#ia-conf-badge {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 2px;
  transition: color .3s;
}

/* barras de confiança */
#confidence-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.conf-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.conf-emoji { width: 22px; text-align: center; font-size: 0.9rem; }
.conf-track {
  flex: 1;
  height: 7px;
  background: #21262d;
  border-radius: 4px;
  overflow: hidden;
}

.conf-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.conf-fill.winner { height: 100%; filter: brightness(1.25); }

.conf-fill.apple      { background: #f85149; }
.conf-fill.banana     { background: #d29922; }
.conf-fill.watermelon { background: #3fb950; }

.conf-pct {
  width: 30px;
  text-align: right;
  color: var(--muted);
  font-size: 0.72rem;
}
.conf-pct-win {
  font-weight: 700;
  color: var(--text);
}

/* ── Feedback buttons ── */
#feedback-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.fb-btn {
  flex: 1;
  padding: 9px;
  border: none;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.fb-btn:active   { transform: scale(0.97); }
.fb-btn:disabled { opacity: 0.32; cursor: not-allowed; }
.fb-btn.correct  { background: rgba(63,185,80,.18);  color: var(--green); border: 1px solid var(--green); }
.fb-btn.wrong    { background: rgba(248,81,73,.18);  color: var(--red);   border: 1px solid var(--red); }

/* ── Modo livre: ensinar rótulo ── */
#teach-free {
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.teach-label {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

#teach-btns {
  display: flex;
  gap: 6px;
}

.teach-btn {
  flex: 1;
  padding: 8px 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #21262d;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.teach-btn:hover    { border-color: var(--accent); color: var(--text); background: rgba(88,166,255,.08); }
.teach-btn.teach-flash { background: rgba(63,185,80,.25); border-color: var(--green); color: var(--green); }

/* ── Action row ── */
#action-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

#btn-surprise, #btn-next {
  flex: 1;
  padding: 9px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border);
}
#btn-surprise {
  background: rgba(188,140,255,.12);
  color: var(--purple);
  border-color: rgba(188,140,255,.4);
}
#btn-next {
  background: rgba(88,166,255,.12);
  color: var(--accent);
  border-color: rgba(88,166,255,.4);
}
#btn-surprise:hover { background: rgba(188,140,255,.25); }
#btn-next:hover     { background: rgba(88,166,255,.25); }

/* ── Painel direito ── */
#training-stats {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

#stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.stats-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

#btn-reset {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #21262d;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
#btn-reset:hover { border-color: var(--red); color: var(--red); }

@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinning { animation: spin 0.5s linear; }

.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-child { border-bottom: none; }
.stat-icon  { font-size: 1.1rem; }
.stat-label { flex: 1; font-size: 0.85rem; color: var(--muted); }
.stat-val   { font-size: 1rem; font-weight: 700; color: var(--text); }

/* ── Como funciona ── */
#how-it-works {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.hw-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.hw-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.hw-step strong { color: var(--text); }

.step-num {
  background: var(--accent);
  color: #000;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Challenge / Overfitting ── */
#challenge-box, #overfitting-alert {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 12px;
}

#challenge-box strong, #overfitting-alert strong { color: var(--text); }

.challenge-list {
  margin: 8px 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.challenge-list li { line-height: 1.4; }

#overfitting-alert {
  border-color: var(--yellow);
  background: rgba(210, 153, 34, 0.08);
  color: var(--yellow);
  animation: pulse-border 1s ease-in-out 3;
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--yellow); }
  50% { border-color: transparent; }
}

/* ── Animação do emoji da fruta ── */
@keyframes pop-in {
  0%   { transform: scale(0.5); opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.fruit-pop { animation: pop-in 0.4s ease forwards; }

/* ── Destaque de acerto/erro ── */
@keyframes flash-green {
  0%, 100% { background: var(--panel); }
  40%       { background: rgba(63, 185, 80, 0.2); }
}

@keyframes flash-red {
  0%, 100% { background: var(--panel); }
  40%       { background: rgba(248, 81, 73, 0.2); }
}

.flash-correct { animation: flash-green 0.6s ease; }
.flash-wrong   { animation: flash-red   0.6s ease; }

/* ── Reset toast ── */
#reset-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: #1c2128;
  border: 1px solid var(--green);
  color: var(--green);
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: transform .35s ease, opacity .35s ease;
}
#reset-toast.toast-in {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
