/* =========================================================================
   ROBERIX STUDY — components.css
   Botões, inputs, badges, modais, alternativas, barras de progresso, toasts.
   ========================================================================= */

/* Botões -------------------------------------------------------------- */

.btn {
  appearance: none;
  background: var(--panel-hi);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 500;
  letter-spacing: .01em;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}
.btn:hover { background: #2f2f2f; border-color: #4a4a4a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.btn.primary {
  background: #f4f4f4;
  color: #0a0a0a;
  border-color: #f4f4f4;
}
.btn.primary:hover { background: #ffffff; }

.btn.ghost {
  background: transparent;
  border-color: var(--line);
}
.btn.ghost:hover { background: var(--panel); }

.btn.danger { color: #ffd3d3; border-color: #6b3a3a; }
.btn.danger:hover { background: #2a1313; }

.btn.sm { padding: 6px 10px; min-height: 32px; font-size: .9rem; }
.btn.lg { padding: 14px 22px; min-height: 52px; font-size: 1.05rem; }

.btn-link {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:hover { color: var(--text); }

/* Input / textarea ---------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .9rem; color: var(--text-dim); }

.input, .textarea, .select {
  background: #121212;
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: #f4f4f4;
  background: #161616;
}
.textarea {
  resize: vertical;
  min-height: 220px;
  font-family: var(--font);
  line-height: 1.6;
}

.field .hint { font-size: .8rem; color: var(--text-mute); }
.field .err { font-size: .85rem; color: #ffb6b6; }

/* Badges -------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #222;
  color: var(--text-dim);
  border: 1px solid var(--line);
  font-size: .78rem;
  font-family: var(--font-mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.badge.good { background: var(--good-bg); color: var(--good); border-color: #2a4a2a; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: #4a2a2a; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #4a432a; }
.badge.solid { background: #f4f4f4; color: #0a0a0a; border-color: #f4f4f4; }

/* Barra de progresso -------------------------------------------------- */

.progress {
  height: 10px;
  width: 100%;
  background: #121212;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6f6f6f, #ffffff);
  width: 0%;
  transition: width var(--t-slow) ease;
}
.progress.thin { height: 6px; }

.xp-bar { display: flex; align-items: center; gap: 10px; }
.xp-bar .progress { flex: 1; }
.xp-bar .label { font-size: .85rem; color: var(--text-mute); font-family: var(--font-mono); min-width: 110px; text-align: right; }

/* Alternativas (questão) ---------------------------------------------- */

.alts { display: flex; flex-direction: column; gap: 10px; }
.alt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #141414;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  text-align: left;
  width: 100%;
  color: var(--text);
}
.alt:hover { background: #1c1c1c; border-color: var(--line-2); }
.alt .letter {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #222;
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 600;
  flex-shrink: 0;
}
.alt.selected { border-color: #f4f4f4; background: #1f1f1f; }
.alt.right { border-color: #2a4a2a; background: #14241a; }
.alt.right .letter { background: #2a4a2a; color: #c4f5c4; }
.alt.wrong { border-color: #4a2a2a; background: #241414; }
.alt.wrong .letter { background: #4a2a2a; color: #f5c4c4; }
.alt:disabled { cursor: default; }

/* Modal --------------------------------------------------------------- */

.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 16px;
}
.modal-root[hidden] { display: none; }
.modal {
  width: min(540px, 100%);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  animation: fadeUp var(--t-mid) ease both;
}
.modal h3 { margin-bottom: 6px; }
.modal p { color: var(--text-dim); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* Toast --------------------------------------------------------------- */

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: #181818;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: fadeUp var(--t-mid) ease both;
  max-width: 360px;
  pointer-events: auto;
}
.toast.good { border-color: #2a4a2a; }
.toast.bad { border-color: #4a2a2a; }
.toast.achv {
  background: linear-gradient(180deg, #1d1d1d, #161616);
  border-color: #555;
}
.toast .title { font-weight: 600; }
.toast .sub { color: var(--text-mute); font-size: .85rem; }

/* Mapa de fases ------------------------------------------------------- */

.phases {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.phase {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: transform var(--t-fast), border-color var(--t-fast), background var(--t-fast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 110px;
}
.phase:hover { background: var(--panel-2); border-color: var(--line-2); transform: translateY(-1px); }
.phase .pid { font-family: var(--font-mono); font-size: 11px; color: var(--text-mute); }
.phase .ptitle { font-weight: 600; }
.phase .pmeta { font-size: .82rem; color: var(--text-mute); }
.phase.done { border-color: #2a4a2a; }
.phase.done::after {
  content: "OK";
  position: absolute;
  top: 10px;
  right: 12px;
  background: #2a4a2a;
  color: #c4f5c4;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .14em;
  padding: 2px 6px;
  border-radius: 4px;
}
.phase.locked { opacity: .55; cursor: not-allowed; }
.phase.locked:hover { transform: none; }
.phase.boss {
  border-style: dashed;
  border-color: #5a5a5a;
  background: linear-gradient(180deg, #1c1c1c, #161616);
}
.phase.boss::before {
  content: "CHEFÃO";
  position: absolute;
  top: -10px;
  left: 12px;
  background: #f4f4f4;
  color: #0a0a0a;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .2em;
  padding: 2px 8px;
  border-radius: 4px;
}

/* Conquistas ---------------------------------------------------------- */

.achievement {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.achievement .icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #232323;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid var(--line-2);
}
.achievement.locked .icon { opacity: .35; }
.achievement.locked .name { color: var(--text-mute); }
.achievement .name { font-weight: 600; }
.achievement .desc { color: var(--text-mute); font-size: .9rem; margin-top: 2px; }

/* Lista de erros ------------------------------------------------------ */

.error-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.error-row .topic { font-size: .8rem; color: var(--text-mute); font-family: var(--font-mono); letter-spacing: .08em; }
.error-row .q { color: var(--text); margin-top: 2px; }

/* Editor de redação --------------------------------------------------- */

.essay-editor {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
}
@media (max-width: 900px) { .essay-editor { grid-template-columns: 1fr; } }

.essay-side .stat {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--text-dim);
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}
.essay-side .stat:last-child { border-bottom: none; }

.score-pill {
  display: inline-grid;
  place-items: center;
  background: #f4f4f4;
  color: #0a0a0a;
  font-weight: 700;
  font-size: 1.5rem;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  font-family: var(--font-mono);
}
.score-pill.bad { background: #4a2a2a; color: #f5c4c4; }
.score-pill.warn { background: #4a432a; color: #f5e8c4; }

/* Menu lateral -------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0;
  min-height: 100vh;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.sidebar {
  background: #0d0d0d;
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
}
@media (max-width: 900px) {
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; }
}
.sidebar .brand-mini { font-family: var(--font-mono); font-size: 12px; color: var(--text-mute); letter-spacing: .18em; padding: 6px 10px 14px; }
.sidebar a, .sidebar button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .95rem;
  white-space: nowrap;
}
.sidebar a:hover, .sidebar button:hover { background: #161616; color: var(--text); }
.sidebar a.active, .sidebar button.active { background: #1c1c1c; color: var(--text); border-color: var(--line); }

/* Cabeçalhos de tela -------------------------------------------------- */

.page-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 18px;
}
.page-header .row { gap: 18px; }

/* Avatar / ícone ------------------------------------------------------ */

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2a2a2a, #4a4a4a);
  border: 1px solid var(--line-2);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: .04em;
}

/* Dica / bloco de explicação ----------------------------------------- */

.tip {
  background: #131313;
  border-left: 3px solid #6e6e6e;
  padding: 12px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim);
}
.tip.good { border-left-color: #79b779; }
.tip.bad { border-left-color: #b77979; }
.tip.warn { border-left-color: #b7a979; }
.tip strong { color: var(--text); }

.kbd {
  font-family: var(--font-mono);
  background: #222;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .82rem;
}

/* Resultado / boss ---------------------------------------------------- */

.boss-stage {
  background: linear-gradient(180deg, #131313, #0c0c0c);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.boss-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(80% 50% at 50% 100%, rgba(255,255,255,.06), transparent 70%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.02) 0 1px, transparent 1px 6px);
  pointer-events: none;
}
.hp-bar {
  height: 14px;
  background: #1a1a1a;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  overflow: hidden;
}
.hp-bar > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, #f4f4f4, #888);
  width: 100%;
  transition: width var(--t-slow) ease;
}

/* Loja / itens ------------------------------------------------------- */
.shop-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.shop-item .preview {
  height: 90px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #222, #444);
  margin-bottom: 10px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--text-dim);
}
