/**
 * Digi Idle — chrome HUD: conn-status + spellbar (tema Digivice)
 */

/* conn-status flutuante removido */
.conn-status,
.conn-status.dv-float-hud,
.conn-status.is-fab-ready,
.conn-status.dv-float-hud.is-fab-ready {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* —— Conn status (legado, oculto acima) —— */
.conn-status {
  position: fixed !important;
  top: 16px;
  right: calc(var(--bar-space, calc(var(--bar-h, 54px) + 16px)) + 12px);
  left: auto;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(72vw, 340px);
  padding: 7px 12px 7px 10px;
  border-radius: 12px;
  border: 1px solid rgba(79, 214, 255, 0.22);
  background:
    linear-gradient(135deg, rgba(255, 154, 46, 0.1), transparent 45%),
    linear-gradient(180deg, rgba(14, 22, 38, 0.94), rgba(8, 14, 24, 0.92));
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(0, 0, 0, 0.25) inset;
  color: #9fb0c8;
  font: 600 11px Rajdhani, system-ui, sans-serif;
  letter-spacing: 0.03em;
  backdrop-filter: blur(14px) saturate(1.15);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-sizing: border-box;
  /* some só após JS posicionar (evita flash na toolbar) */
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}
.conn-status.is-fab-ready,
.conn-status.dv-float-hud.is-fab-ready {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.conn-status.is-dragging {
  cursor: grabbing;
  border-color: rgba(255, 154, 46, 0.45);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 154, 46, 0.15) inset;
}
.conn-status.dv-float-hud {
  right: auto !important;
  bottom: auto !important;
}

.conn-dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #556;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.conn-dot.fresh {
  background: #48c96f;
  box-shadow: 0 0 8px rgba(72, 201, 111, 0.7);
}
.conn-dot.stale {
  background: #ffb04a;
  box-shadow: 0 0 8px rgba(255, 176, 74, 0.65);
}
.conn-dot.down {
  background: #e5484d;
  box-shadow: 0 0 8px rgba(229, 72, 77, 0.7);
  animation: barCritPulse 1.05s ease-in-out infinite;
}
.conn-dot.offline {
  background: #4fd6ff;
  box-shadow: 0 0 8px rgba(79, 214, 255, 0.6);
}

.conn-label {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #d7e3f5;
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conn-sep {
  margin: 0 5px 0 2px;
  color: rgba(79, 214, 255, 0.35);
}

.conn-status.alert {
  color: #ffe4e4;
  border-color: rgba(229, 72, 77, 0.45);
  background:
    linear-gradient(135deg, rgba(229, 72, 77, 0.16), transparent 50%),
    linear-gradient(180deg, rgba(58, 18, 22, 0.95), rgba(20, 8, 10, 0.92));
}
.conn-dot.alert {
  background: #e5484d;
  box-shadow: 0 0 8px rgba(229, 72, 77, 0.75);
}

.conn-status.conn-update {
  top: 56px;
  align-items: flex-start;
  max-width: min(74vw, 320px);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
  border-radius: 12px;
  font-weight: 600;
  color: #ffe2a0;
  background:
    linear-gradient(135deg, rgba(255, 176, 74, 0.14), transparent 50%),
    linear-gradient(180deg, rgba(48, 36, 10, 0.95), rgba(20, 14, 6, 0.92));
  border-color: rgba(242, 201, 74, 0.4);
}
.conn-status.conn-update .conn-dot {
  margin-top: 3px;
}
.conn-status.conn-update .conn-label {
  white-space: normal;
  color: #ffe2a0;
}

body[data-toolbar-pos="left"] .conn-status:not(.dv-float-hud) {
  right: 16px;
  left: auto;
}
body[data-toolbar-pos="right"] .conn-status:not(.dv-float-hud) {
  right: calc(var(--bar-space, calc(var(--bar-h, 54px) + 16px)) + 12px);
}

/* —— Spellbar (golpes) — tray azul —— */
.spellbar {
  --sb-scale: 0.7;
  --sb-slot: calc(46px * var(--sb-scale));
  --sb-gap: calc(5px * var(--sb-scale));
  --sb-pad-y: calc(6px * var(--sb-scale));
  --sb-pad-x: calc(7px * var(--sb-scale));
  --sb-radius: calc(14px * min(1.15, var(--sb-scale)));
  --sb-shell: #1a9ec4;
  --sb-shell-2: #0e6f95;
  --sb-shell-hi: #4fd6ff;
  --sb-cyan: #3ecfff;
  --sb-lcd: #07141a;
  --sb-text: #d7f4ff;
  --sb-muted: #6f93a3;
  --sb-warn: #ffc14d;
  --sb-ok: #5dffb0;
  --sb-font: "Rajdhani", "Segoe UI", system-ui, sans-serif;
  --sb-display: "Orbitron", "Rajdhani", system-ui, sans-serif;

  position: fixed;
  left: 50%;
  bottom: max(24px, calc(var(--bar-bottom, 0px) + 18px), calc(var(--ui-gutter-b, 8px) + 20px));
  transform: translateX(-50%);
  z-index: 29;
  display: flex;
  align-items: center;
  gap: var(--sb-gap);
  padding: var(--sb-pad-y) var(--sb-pad-x);
  max-width: min(
    96vw,
    calc(100vw - var(--hud-left, 0px) - var(--hud-right, 0px) - 32px)
  );
  overflow-x: auto;
  overscroll-behavior: contain;
  border-radius: var(--sb-radius);
  border: 2px solid #0a5a78;
  background:
    radial-gradient(120% 80% at 10% 0%, rgba(79, 214, 255, 0.35), transparent 45%),
    linear-gradient(165deg, var(--sb-shell-hi) 0%, var(--sb-shell) 42%, var(--sb-shell-2) 100%);
  box-shadow:
    0 0 0 1px rgba(200, 240, 255, 0.28) inset,
    0 0 0 3px rgba(0, 0, 0, 0.2) inset,
    0 12px 28px rgba(0, 0, 0, 0.5),
    0 0 22px rgba(62, 207, 255, 0.18);
  pointer-events: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  box-sizing: border-box;
  font-family: var(--sb-font);
}
.spellbar:active {
  cursor: grabbing;
}
.spellbar::-webkit-scrollbar {
  height: 2px;
}
.spellbar::-webkit-scrollbar-thumb {
  background: rgba(12, 32, 40, 0.45);
  border-radius: 99px;
}

body[data-toolbar-pos="bottom"] .spellbar {
  bottom: max(18px, calc(var(--bar-space, 70px) + 12px));
}
body[data-toolbar-pos="right"] .spellbar,
body[data-toolbar-pos="left"] .spellbar {
  max-width: min(
    96vw,
    calc(100vw - var(--hud-left, 0px) - var(--hud-right, 0px) - 40px)
  );
}

/* Slot = célula LCD */
.spell-slot {
  position: relative;
  flex-shrink: 0;
  width: var(--sb-slot, 46px);
  height: var(--sb-slot, 46px);
  border-radius: calc(10px * min(1.15, var(--sb-scale, 0.7)));
  background:
    radial-gradient(90% 80% at 50% 0%, rgba(62, 207, 255, 0.1), transparent 55%),
    linear-gradient(180deg, #0c1a22, var(--sb-lcd, #07141a));
  border: 1px solid rgba(62, 207, 255, 0.22);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35) inset,
    0 2px 0 rgba(200, 240, 255, 0.12);
  overflow: hidden;
  pointer-events: auto;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.spell-slot::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 42%);
  border-radius: inherit;
  z-index: 3;
}
.spell-slot:hover {
  border-color: rgba(79, 214, 255, 0.7);
  box-shadow:
    0 0 0 1px rgba(79, 214, 255, 0.18) inset,
    0 0 14px rgba(79, 214, 255, 0.28);
  transform: translateY(-1px);
}
.spell-slot-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  padding: calc(3px * var(--sb-scale, 0.7));
  box-sizing: border-box;
  transition: filter 0.12s linear;
}
.spell-slot.on-cooldown .spell-slot-icon,
.spell-slot.locked .spell-slot-icon {
  filter: grayscale(0.9) brightness(0.5);
}
.spell-slot-cd-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(4, 12, 18, 0.55), rgba(4, 12, 18, 0.82));
  border-bottom: 1px solid rgba(62, 207, 255, 0.2);
  transition: height 0.12s linear;
  pointer-events: none;
}
.spell-slot-cd-text {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-55%);
  z-index: 2;
  text-align: center;
  font: 700 calc(11px * var(--sb-scale, 0.7)) / 1 var(--sb-display, Orbitron, sans-serif);
  letter-spacing: 0.04em;
  color: #c8f0ff;
  text-shadow: 0 1px 3px #000, 0 0 8px rgba(79, 214, 255, 0.4);
  pointer-events: none;
}
.spell-slot-key {
  position: absolute;
  left: calc(3px * var(--sb-scale, 0.7));
  top: calc(2px * var(--sb-scale, 0.7));
  z-index: 2;
  min-width: calc(14px * var(--sb-scale, 0.7));
  padding: 1px calc(3px * var(--sb-scale, 0.7));
  border-radius: calc(4px * var(--sb-scale, 0.7));
  font: 700 calc(8px * var(--sb-scale, 0.7)) / 1 var(--sb-display, Orbitron, sans-serif);
  letter-spacing: 0.04em;
  color: #06202c;
  background: linear-gradient(180deg, #c8f4ff, #3ecfff);
  border: 1px solid #1a7a9a;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset;
  pointer-events: none;
}
.spell-slot-lock {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  font-size: calc(14px * var(--sb-scale, 0.7));
  line-height: 1;
  pointer-events: none;
  background: rgba(4, 10, 14, 0.45);
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.9));
}

/* Alça de redimensionar (injetada / sincronizada via JS) */
#spellbar-resize-handle {
  position: fixed;
  z-index: 30;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 5px 0 10px 0;
  cursor: nwse-resize;
  touch-action: none;
  pointer-events: auto;
  background:
    linear-gradient(135deg, transparent 42%, rgba(12, 32, 40, 0.55) 43% 52%, transparent 53%),
    linear-gradient(135deg, transparent 58%, rgba(12, 32, 40, 0.7) 59% 68%, transparent 69%),
    linear-gradient(135deg, transparent 74%, rgba(200, 244, 255, 0.9) 75%);
  box-shadow: 0 0 0 1px rgba(10, 90, 120, 0.55);
  opacity: 0.72;
  transition: opacity 0.12s ease, filter 0.12s ease;
}
#spellbar-resize-handle:hover,
#spellbar-resize-handle.is-dragging {
  opacity: 1;
  filter: brightness(1.08);
}
#spellbar-resize-handle[hidden] {
  display: none !important;
}
.spell-slot.casting {
  border-color: rgba(79, 214, 255, 0.9);
  box-shadow:
    0 0 0 2px rgba(79, 214, 255, 0.35),
    0 0 16px rgba(79, 214, 255, 0.45),
    0 0 0 1px rgba(200, 240, 255, 0.2) inset;
  animation: spellCastPulse 0.7s ease-in-out infinite;
}
@keyframes spellCastPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}

@media (max-width: 640px) {
  .conn-status {
    max-width: min(88vw, 300px);
    padding: 6px 10px;
    font-size: 10px;
  }
  .spellbar {
    bottom: max(16px, calc(var(--bar-bottom, 0px) + 14px));
  }
  #spellbar-resize-handle {
    width: 20px;
    height: 20px;
  }
}

@media (max-height: 520px) and (min-width: 641px) {
  .spellbar {
    bottom: max(12px, calc(var(--bar-bottom, 0px) + 10px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .spell-slot.casting {
    animation: none;
  }
}
