/* Rebirth Idle - componentes. Estados: default, hover, focus, active, disabled, loading, error, success. */

/* ---------- painel com moldura ---------- */
.panel {
  position: relative; background: var(--surface); color: var(--ink);
  border: 2px solid var(--frame-edge); outline: 1px solid var(--gold); outline-offset: -5px;
  border-radius: var(--radius); padding: var(--sp-5) var(--sp-4) var(--sp-4); box-shadow: var(--shadow-2);
}
.panel > .panel-title {
  display: flex; align-items: center; gap: var(--sp-2); justify-content: center;
  margin: calc(-1 * var(--sp-5)) calc(-1 * var(--sp-4)) var(--sp-4); padding: var(--sp-2) var(--sp-3);
  background: linear-gradient(var(--ribbon-1), var(--ribbon-2)); color: var(--ink-on-dark);
  border-bottom: 1px solid var(--gold); font: 600 var(--fs-md)/1.2 var(--font-title);
  text-transform: uppercase; letter-spacing: .04em; text-shadow: 0 1px 2px #000;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.card { background: var(--surface-raised); border: var(--border); border-radius: var(--radius); padding: var(--sp-3); }
.card.selectable { cursor: pointer; transition: box-shadow var(--dur-fast), transform var(--dur-fast); }
.card.selectable:hover { box-shadow: var(--shadow-1); }
.card.selectable[aria-pressed="true"], .card.selected { border-color: var(--rb-wine); box-shadow: inset 0 0 0 2px var(--rb-wine); }
.card[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--touch); min-width: var(--touch); padding: var(--sp-2) var(--sp-4);
  font: 600 var(--fs-sm)/1.2 var(--font-title); text-transform: uppercase; letter-spacing: .03em;
  color: #3D2414; background: linear-gradient(#FFF0BF, #DFBD79); border: 3px double #77501E;
  border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px #FFF0C7, var(--shadow-1);
  cursor: pointer; text-decoration: none; transition: filter var(--dur-fast), transform var(--dur-fast);
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); filter: brightness(.95); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; filter: grayscale(.4); transform: none; }
.btn.primary { color: var(--ink-on-dark); background: linear-gradient(var(--ribbon-1), var(--ribbon-2)); border-color: var(--gold); box-shadow: inset 0 0 0 1px #A8434F, var(--shadow-1); }
.btn.danger { color: #FFF; background: linear-gradient(#B4363A, #7A1A22); border-color: #4A0E14; }
.btn.ghost { background: transparent; border: 1px solid var(--gold-dark); box-shadow: none; color: inherit; }
.btn.small { min-height: 36px; padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); }
.btn.block { width: 100%; }
.btn[aria-busy="true"] { position: relative; color: transparent !important; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--gold-light) transparent var(--gold-light) transparent;
  animation: rb-spin .8s linear infinite;
}
@keyframes rb-spin { to { transform: rotate(360deg); } }

/* ---------- formulários ---------- */
.field { display: grid; gap: var(--sp-1); margin-bottom: var(--sp-3); }
.field label { font-weight: 600; font-size: var(--fs-sm); }
.field .hint { font-size: var(--fs-xs); color: var(--ink-mute); }
.input, select.input, textarea.input {
  min-height: var(--touch); padding: var(--sp-2) var(--sp-3); font: var(--fs-md)/1.4 var(--font-body);
  color: var(--ink); background: var(--surface-raised); border: 1px solid var(--gold-dark); border-radius: var(--radius-sm);
}
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.field .error { color: var(--danger); font-size: var(--fs-sm); }
.field .error::before { content: "⚠ "; }
.check { display: flex; gap: var(--sp-2); align-items: center; min-height: var(--touch); }
.check input { width: 20px; height: 20px; accent-color: var(--rb-wine); }
input[type="range"] { width: 100%; accent-color: var(--rb-wine); min-height: var(--touch); }

/* controle segmentado (posturas, filtros) */
.segmented { display: flex; border: 1px solid var(--gold-dark); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button {
  flex: 1; min-height: var(--touch); border: 0; border-right: 1px solid var(--gold-dark); background: var(--surface-raised);
  font: 600 var(--fs-sm)/1.2 var(--font-body); color: var(--ink); cursor: pointer;
}
.segmented button:last-child { border-right: 0; }
.segmented button[aria-checked="true"] { background: var(--rb-wine); color: var(--ink-on-dark); }

/* ---------- etapas (stepper) ---------- */
.steps { display: flex; gap: var(--sp-2); list-style: none; padding: 0; margin: 0 0 var(--sp-4); counter-reset: step; }
.steps li { flex: 1; display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--ink-mute); }
.steps li::before {
  counter-increment: step; content: counter(step); display: grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--gold-dark); background: var(--surface-raised); font-weight: 700;
}
.steps li[aria-current="step"] { color: var(--ink); font-weight: 700; }
.steps li[aria-current="step"]::before { background: var(--rb-wine); color: var(--ink-on-dark); border-color: var(--gold); }
.steps li.done::before { content: "✓"; background: var(--ok); color: #FFF; border-color: var(--ok); }

/* ---------- abas ---------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 2px solid var(--gold-dark); margin-bottom: var(--sp-3); overflow-x: auto; }
.tabs [role="tab"] {
  min-height: var(--touch); padding: var(--sp-2) var(--sp-4); border: 1px solid transparent; border-bottom: 0;
  background: transparent; font: 600 var(--fs-sm)/1 var(--font-body); color: var(--ink-mute); cursor: pointer; white-space: nowrap;
}
.tabs [role="tab"][aria-selected="true"] { background: var(--surface-raised); color: var(--ink); border-color: var(--gold-dark); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }

/* ---------- selos ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1); padding: 2px var(--sp-2); border-radius: 999px;
  font: 700 var(--fs-xs)/1.4 var(--font-body); border: 1px solid currentColor; white-space: nowrap;
}
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.danger { color: var(--danger); background: var(--danger-bg); }
.badge.info { color: var(--info); background: var(--info-bg); }
.badge.neutral { color: var(--ink-mute); background: var(--surface-raised); }

/* ---------- barras (sempre com número; padrão listrado no estado baixo) ---------- */
.meter { display: grid; gap: 2px; }
.meter .meter-label { display: flex; justify-content: space-between; font-size: var(--fs-xs); }
.meter .track { height: 10px; background: #1B1512; border: 1px solid var(--frame-edge); border-radius: var(--radius-sm); overflow: hidden; }
.meter .fill { height: 100%; background: var(--hp-ok); transition: width var(--dur-slow) var(--ease-out); }
.meter.mana .fill { background: var(--mana); }
.meter.xp .fill { background: var(--xp); }
.meter.mid .fill { background: var(--hp-mid); }
.meter.low .fill { background: repeating-linear-gradient(45deg, var(--hp-low) 0 6px, #7A1E1E 6px 12px); }
.meter.stamina .fill { background: var(--stamina); }
.meter.stamina.orange .fill { background: repeating-linear-gradient(45deg, var(--stamina-orange) 0 6px, #8F4A0C 6px 12px); }

/* ---------- slots de item e equipamento ---------- */
.slot {
  position: relative; display: grid; place-items: center; width: 52px; height: 52px;
  background: #1B1512; border: 2px solid var(--frame-edge); outline: 1px solid var(--gold-dark); outline-offset: -4px;
}
.slot img { width: 32px; height: 32px; image-rendering: pixelated; }
.slot .count { position: absolute; right: 3px; bottom: 1px; font: 700 var(--fs-xs)/1 var(--font-num); color: #FFF; text-shadow: 1px 1px 0 #000; }
.slot.empty::after { content: attr(data-slot); font-size: 9px; color: var(--ink-on-dark-mute); text-transform: uppercase; }
.equip-grid { display: grid; grid-template-columns: repeat(3, 52px); gap: var(--sp-2); }

/* ---------- cartão de criatura ---------- */
.creature { display: grid; grid-template-columns: 64px 1fr; gap: var(--sp-3); align-items: center; }
.creature .art { width: 64px; height: 64px; background: #1C1712; border: 1px solid var(--gold-dark); display: grid; place-items: end center; }
.creature .art img { width: 64px; height: 64px; image-rendering: pixelated; }
.creature .name { font: 700 var(--fs-md)/1.2 var(--font-title); }
.creature .meta { font-size: var(--fs-xs); color: var(--ink-mute); }

/* ---------- tabela ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: var(--sp-2); border-bottom: 1px solid var(--surface-sunken); text-align: left; }
.table th { font: 700 var(--fs-xs)/1.2 var(--font-body); text-transform: uppercase; color: var(--ink-mute); }
.table td.n, .table th.n { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: var(--surface-raised); }
.pos { color: var(--ok); } .neg { color: var(--danger); }

/* ---------- avisos e estados de tela ---------- */
.alert { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3); border-radius: var(--radius); border: 1px solid; font-size: var(--fs-sm); }
.alert .icon { font-size: var(--fs-lg); line-height: 1; }
.alert.ok { color: var(--ok); background: var(--ok-bg); }
.alert.warn { color: var(--warn); background: var(--warn-bg); }
.alert.danger { color: var(--danger); background: var(--danger-bg); }
.alert.info { color: var(--info); background: var(--info-bg); }
.state { display: grid; place-items: center; gap: var(--sp-3); text-align: center; padding: var(--sp-6) var(--sp-4); color: var(--ink-mute); }
.state .state-icon { font-size: 2rem; }
.state h3 { color: var(--ink); }
.skeleton { background: linear-gradient(90deg, var(--surface-sunken) 0%, var(--surface-raised) 50%, var(--surface-sunken) 100%); background-size: 200% 100%; animation: rb-shimmer 1.4s ease-in-out infinite; border-radius: var(--radius-sm); min-height: 1em; }
@keyframes rb-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- diálogo, gaveta, toast, tooltip ---------- */
dialog.dialog {
  border: 2px solid var(--frame-edge); outline: 1px solid var(--gold); outline-offset: -5px; border-radius: var(--radius);
  padding: var(--sp-5); background: var(--surface); color: var(--ink); max-width: min(92vw, 480px); box-shadow: var(--shadow-2);
}
dialog.dialog::backdrop { background: rgba(10, 6, 6, .65); }
dialog.dialog[open] { animation: rb-pop var(--dur) var(--ease-out); }
.dialog-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-4); flex-wrap: wrap; }
@keyframes rb-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.drawer {
  position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: var(--z-drawer);
  background: var(--surface-dark); color: var(--ink-on-dark); transform: translateX(-100%);
  transition: transform var(--dur) var(--ease-out); box-shadow: var(--shadow-2); overflow-y: auto;
}
.drawer[data-open="true"] { transform: none; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: calc(var(--z-drawer) - 1); opacity: 0; pointer-events: none; transition: opacity var(--dur); }
.scrim[data-open="true"] { opacity: 1; pointer-events: auto; }

.toasts { position: fixed; z-index: var(--z-toast); right: var(--sp-4); bottom: var(--sp-4); display: grid; gap: var(--sp-2); max-width: min(92vw, 380px); }
.toast { display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-3) var(--sp-4); background: var(--surface-dark); color: var(--ink-on-dark); border: 1px solid var(--gold); border-radius: var(--radius); box-shadow: var(--shadow-2); animation: rb-toast var(--dur-slow) var(--ease-out); }
.toast.ok { border-color: var(--hp-ok); } .toast.danger { border-color: var(--hp-low); }
@keyframes rb-toast { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.tip { position: relative; }
.tip [role="tooltip"] {
  position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); z-index: 5; min-width: 180px;
  padding: var(--sp-2) var(--sp-3); background: var(--surface-dark); color: var(--ink-on-dark); border: 1px solid var(--gold);
  border-radius: var(--radius-sm); font-size: var(--fs-xs); opacity: 0; pointer-events: none; transition: opacity var(--dur-fast);
}
.tip:hover [role="tooltip"], .tip:focus-within [role="tooltip"], .tip[data-open="true"] [role="tooltip"] { opacity: 1; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-header); display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); background: linear-gradient(#2A2220, var(--surface-dark)); color: var(--ink-on-dark);
  border-bottom: 2px solid var(--gold-dark); min-height: 60px;
}
.topbar .brand { display: flex; align-items: center; gap: var(--sp-2); color: var(--ink-on-dark); text-decoration: none; font: 700 var(--fs-md)/1 var(--font-title); letter-spacing: .06em; }
.topbar .brand img { width: 32px; height: 32px; }
.topbar .hero-head { display: flex; align-items: center; gap: var(--sp-3); margin-left: auto; min-width: 0; }
.topbar .hero-head .who { font: 700 var(--fs-sm)/1.2 var(--font-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .hero-head .meters { display: grid; gap: 2px; width: 140px; }
.topbar .hero-head .meter .meter-label { color: var(--ink-on-dark-mute); }
.topbar .gold { font: 700 var(--fs-sm)/1 var(--font-num); color: var(--gold-light); white-space: nowrap; }
.topbar .menu-btn { display: inline-grid; place-items: center; width: var(--touch); height: var(--touch); background: transparent; border: 1px solid var(--gold-dark); color: var(--ink-on-dark); border-radius: var(--radius-sm); cursor: pointer; font-size: 1.3rem; }
.nav { list-style: none; margin: 0; padding: var(--sp-3) 0; }
.nav .nav-group { padding: var(--sp-3) var(--sp-4) var(--sp-1); font: 700 var(--fs-xs)/1 var(--font-body); color: var(--ink-on-dark-mute); text-transform: uppercase; letter-spacing: .08em; }
.nav a {
  display: flex; align-items: center; gap: var(--sp-3); min-height: var(--touch); padding: 0 var(--sp-4);
  color: var(--ink-on-dark); text-decoration: none; border-left: 3px solid transparent; font-size: var(--fs-sm);
}
.nav a:hover { background: rgba(198, 160, 90, .1); }
.nav a[aria-current="page"] { background: rgba(104, 28, 40, .55); border-left-color: var(--gold); font-weight: 700; }
.nav .ico { width: 20px; text-align: center; }
.nav .count { margin-left: auto; }
.main { padding: var(--sp-4) var(--sp-3) calc(var(--sp-7) + 64px); max-width: var(--content-max); width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); color: var(--ink-on-dark); }
.page-head h1 { margin: 0; text-shadow: 0 2px 3px #000; }
.crumbs { font-size: var(--fs-xs); color: var(--ink-on-dark-mute); }
.crumbs a { color: var(--ink-on-dark-mute); }
.grid { display: grid; gap: var(--sp-4); }
.grid.cols-2 { grid-template-columns: 1fr; }
.grid.cols-3 { grid-template-columns: 1fr; }
.bottombar {
  position: fixed; inset: auto 0 0 0; z-index: var(--z-header); display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  background: var(--surface-dark); border-top: 2px solid var(--gold-dark);
}
.bottombar a { display: grid; place-items: center; gap: 2px; min-height: 58px; color: var(--ink-on-dark-mute); text-decoration: none; font-size: 11px; }
.bottombar a .ico { font-size: 1.25rem; }
.bottombar a[aria-current="page"] { color: var(--gold-light); background: rgba(104, 28, 40, .55); }
.sidenav { display: none; }
.view-enter { animation: rb-view var(--dur) var(--ease-out); }
@keyframes rb-view { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (min-width: 768px) {
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .main { padding: var(--sp-5) var(--sp-5) var(--sp-7); }
}
@media (min-width: 1100px) {
  .shell { grid-template-columns: var(--shell-nav) 1fr; }
  .shell > .topbar { grid-column: 1 / -1; }
  .sidenav { display: block; background: var(--surface-dark); border-right: 2px solid var(--gold-dark); position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; }
  .bottombar, .topbar .menu-btn { display: none; }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .main { padding-bottom: var(--sp-7); }
}
@media (max-width: 520px) {
  .topbar .hero-head .meters { width: 92px; }
  .topbar .brand span { display: none; }
}
