:root {
  --bg: #12141c;
  --bg-elevated: #1b1e2b;
  --border: #2e3346;
  --text: #e8e9f0;
  --text-muted: #9498ab;
  --accent: #7c5cff;
  --accent-hover: #6a4be0;
  --danger: #ff5c5c;
  --danger-hover: #e64a4a;
  --warning: #ffb84d;
  --success: #4dd68a;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

h1, h2 {
  margin: 0;
}

h1 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.centered-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.centered-view[hidden] {
  display: none;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 380px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
}

input, select, textarea {
  background: #12141c;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  min-width: 0;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: var(--accent-hover);
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

button.secondary:hover {
  background: var(--bg-elevated);
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: var(--danger-hover);
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
  min-height: 1em;
}

.hint-inline {
  font-size: 13px;
  color: var(--text-muted);
  display: block;
  min-height: 1em;
}

.discord-dm-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.discord-dm-actions button {
  flex: 1;
}

.dm-recipients-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dm-recipient-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #12141c;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
}

.dm-recipient-row .dm-recipient-name {
  font-weight: 600;
  color: var(--text);
}

.dm-recipient-row .dm-recipient-id {
  color: var(--text-muted);
  font-size: 12px;
}

.dm-recipient-add-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dm-recipient-add-row input {
  flex: 1;
  min-width: 120px;
  width: auto;
}

.hint-inline.success {
  color: var(--success);
}

.hint-inline.error {
  color: var(--danger);
}

.hint {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hint[hidden] {
  display: none;
}

.alert-banner {
  background: rgba(255, 184, 77, 0.12);
  border: 1px solid var(--warning);
  color: var(--warning);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

.alert-banner-danger {
  background: rgba(255, 92, 92, 0.12);
  border-color: var(--danger);
  color: var(--danger);
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
}

.toggle-switch {
  appearance: none;
  -webkit-appearance: none;
  width: 42px !important;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.toggle-switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease;
}

.toggle-switch:checked {
  background: var(--accent);
}

.toggle-switch:checked::before {
  transform: translateX(18px);
}

.toggle-switch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Barra lateral */
#app-view {
  display: flex;
  min-height: 100vh;
}

#app-view[hidden] {
  display: none;
}

.sidebar {
  flex: 0 0 240px;
  width: 240px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 12px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  font-size: 16px;
  font-weight: 700;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent);
  color: white;
}

.nav-item[hidden] {
  display: none;
}

/* Administração: encostada ao fundo, mesmo por cima da linha do rodapé. */
#nav-admin {
  margin-top: auto;
  margin-bottom: -8px;
}

#nav-admin:not([hidden]) + .sidebar-footer {
  margin-top: 0;
}

.nav-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.nav-emoji {
  width: 22px;
  text-align: center;
  font-size: 18px;
  line-height: 22px;
}

.user-email {
  padding: 0 12px 6px;
  color: var(--text-muted);
  font-size: 13px;
  word-break: break-word;
}

main {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

/* Barra superior (só em ecrãs pequenos) */
.mobile-topbar,
.sidebar-backdrop {
  display: none;
}

@media (max-width: 760px) {
  #app-view {
    flex-direction: column;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 10px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
  }

  .mobile-title {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    height: auto;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }

  #app-view.sidebar-open .sidebar {
    transform: none;
  }

  #app-view.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.5);
  }
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.character-group {
  margin-bottom: 24px;
}

.character-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 10px;
}

.section-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.character-header h3 {
  font-size: 15px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}

button.small {
  padding: 4px 10px;
  font-size: 12px;
}

.section-block {
  margin-bottom: 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.section-block.dragging {
  opacity: 0.4;
}

.section-block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  cursor: grab;
}

.section-block-header.muted {
  color: var(--text-muted);
  cursor: default;
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.drag-handle {
  color: var(--text-muted);
  cursor: grab;
}

.section-block-header .icon-btn.small {
  margin-left: auto;
  padding: 2px 8px;
  line-height: 1;
}

.section-dropzone {
  min-height: 20px;
  border-radius: var(--radius);
  transition: background 0.15s, outline 0.15s;
}

.section-dropzone.dropzone-active {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
  background: rgba(124, 92, 255, 0.06);
}

.combo {
  position: relative;
}

.combo input {
  padding-right: 38px;
}

.combo .combo-toggle {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 36px;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  border-radius: 0 6px 6px 0;
}

.combo .combo-toggle:hover {
  background: transparent;
  color: var(--text);
}

.combo-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  background: #12141c;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.combo-list[hidden] {
  display: none;
}

.combo-option {
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.combo-option:hover,
.combo-option.active {
  background: var(--accent);
  color: white;
}

.insertion-marker {
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  margin: 2px 0;
  box-shadow: 0 0 6px 0 var(--accent);
}

.sections-container.dropzone-active {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius);
  background: rgba(124, 92, 255, 0.06);
}

.empty-hint {
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  padding: 8px 4px;
  margin: 0;
}

.costume-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  cursor: grab;
}

.costume-card.warning {
  border-color: var(--warning);
}

.costume-card.danger {
  border-color: var(--danger);
}

.costume-card.expired {
  border-color: var(--danger);
  opacity: 0.75;
}

.costume-card.dragging {
  opacity: 0.4;
}

.costume-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.costume-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text);
  letter-spacing: 0.03em;
}

.badge.body { background: #3a4a7c; }
.badge.weapon { background: #7c3a3a; }
.badge.head { background: #3a7c5c; }
.badge.pet { background: #7c5a3a; }

.costume-desc {
  color: var(--text-muted);
  font-size: 13px;
}

.costume-time {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}

.remaining {
  font-weight: 700;
  font-size: 15px;
}

.remaining.warning { color: var(--warning); }
.remaining.danger { color: var(--danger); }
.remaining.expired { color: var(--danger); }
.remaining.ok { color: var(--success); }

.end-date {
  font-size: 12px;
  color: var(--text-muted);
}

.costume-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--danger);
  padding: 6px 10px;
}

.icon-btn:hover {
  background: var(--danger);
  color: white;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 0;
}

.users-list table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.users-list th, .users-list td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.users-list th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}

.users-list tr:last-child td {
  border-bottom: none;
}

.tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
}

.tag.disabled {
  background: var(--border);
  color: var(--text-muted);
}

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
  color: var(--text);
  width: 100%;
  max-width: 380px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}

fieldset legend {
  color: var(--text-muted);
  font-size: 13px;
  padding: 0 6px;
}

.renew-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.field-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: -6px;
}

.type-picker {
  display: flex;
  gap: 10px;
}

.type-option {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: #12141c;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.type-option img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.type-option:hover {
  background: #12141c;
  border-color: var(--accent);
  color: var(--text);
}

.type-option.selected {
  border-color: var(--accent);
  background: rgba(124, 92, 255, 0.15);
  color: var(--text);
}

.type-icon {
  width: 52px;
  height: 64px;
  object-fit: contain;
  border-radius: 6px;
  background: #12141c;
  border: 1px solid var(--border);
  padding: 3px;
}

.time-inputs {
  display: flex;
  gap: 10px;
  min-width: 0;
}

.time-inputs label {
  flex: 1;
  min-width: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 600px) {
  .costume-card {
    flex-direction: column;
    align-items: stretch;
  }
  .costume-time {
    text-align: left;
  }
}

/* Registos Meley / Balathor */
.registry-boxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.registry-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Imagem com tamanho fixo e igual nos dois cartões, centrada. */
.registry-image {
  flex: 0 0 130px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.registry-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.registry-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.registry-body h4 {
  margin: 0 0 4px;
  font-size: 16px;
}

.registry-body button {
  margin-top: 8px;
}

.registry-line {
  margin: 0;
  font-size: 14px;
}

.registry-line.muted {
  color: var(--text-muted);
}

.registry-line.ready {
  color: var(--success);
}

.registry-status {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 1em;
}

.badge.bio { background: #3a6a7c; }

.remaining.ready {
  color: var(--success);
}

.costume-card.ready {
  border-color: var(--success);
}

#bio-subtype-label[hidden] {
  display: none;
}

#bio-collect-delete[hidden] {
  display: none;
}

/* Administração: só as colunas Personagens, Trajes, Pets e Estado ficam centradas. */
.users-list th:nth-child(n+3):nth-child(-n+6),
.users-list td:nth-child(n+3):nth-child(-n+6) {
  text-align: center;
}

/* Faixa "há uma nova versão" */
.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 600;
}

.update-banner button {
  background: white;
  color: var(--accent);
  padding: 4px 12px;
}

.update-banner button:hover {
  background: #eee;
}

.dm-delay-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.dm-delay-hint[hidden] {
  display: none;
}

/* Bolinha vermelha com o número de avisos de cada menu */
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.nav-badge[hidden] {
  display: none;
}

/* Bolinha amarela (aviso), à esquerda da vermelha */
.nav-badge-warning {
  background: var(--warning);
  color: #1b1e2b;
}

/* O gap do botão (10px) já separa as duas; -4px deixa 6px entre elas. */
.nav-badge-warning:not([hidden]) + .nav-badge {
  margin-left: -4px;
}
