/* QuengasBot Control Panel — "Estúdio Noturno" Design System */

:root {
  --bg: #0f1013;
  --surface: #17181c;
  --raised: #202227;
  --raised-hover: #282b32;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f2f3f5;
  --muted: #a3a8b0;
  --onair: #f5a524;
  --onair-bg: rgba(245, 165, 36, 0.14);
  --live: #ef4444;
  --live-bg: rgba(239, 68, 68, 0.14);
  --brand: #5865f2;
  --brand-hover: #4752c4;
  --brand-bg: rgba(88, 101, 242, 0.16);
  --ok: #22c55e;
  --ok-bg: rgba(34, 197, 94, 0.14);
  --warn: #eab308;
  --warn-bg: rgba(234, 179, 8, 0.14);
  --radius: 10px;
  --radius-pad: 14px;
  --dock-h: 76px;
}

[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --raised: #eef0f3;
  --raised-hover: #e3e6ec;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.16);
  --text: #16181d;
  --muted: #5b616b;
  --onair: #c97d00;
  --onair-bg: rgba(201, 125, 0, 0.12);
  --live: #d92d2d;
  --live-bg: rgba(217, 45, 45, 0.12);
  --brand: #4752c4;
  --brand-hover: #3c45a5;
  --brand-bg: rgba(71, 82, 196, 0.12);
  --ok: #15803d;
  --ok-bg: rgba(21, 128, 61, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.tabnum { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); font-size: 12.5px; }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* Shell layout */
.app-shell {
  display: grid;
  grid-template-columns: 72px 240px 1fr;
  min-height: 100vh;
}
.app-shell.has-dock { padding-bottom: var(--dock-h); }

/* Guild Rail */
.guild-rail {
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.rail-btn {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: visible;
  transition: border-radius 140ms, border-color 140ms, transform 140ms;
}
.rail-btn img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.rail-btn:hover { border-radius: 12px; border-color: var(--line-strong); transform: translateY(-1px); }
.rail-btn.active { border-color: var(--onair); background: var(--onair-bg); }
.rail-btn.fleet.active { border-color: var(--brand); background: var(--brand-bg); }
.rail-sep { width: 32px; height: 1px; background: var(--line); }
.rail-dot {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg);
}
.rail-dot.call { background: var(--ok); }
.rail-dot.live { background: var(--live); }
.rail-star {
  position: absolute;
  left: -4px;
  top: -4px;
  font-size: 11px;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-header {
  padding: 4px 8px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.sidebar-guild-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-list { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.nav-item:hover { background: var(--raised); color: var(--text); }
.nav-item.active { background: var(--raised); color: var(--text); border-color: var(--line); font-weight: 600; }
.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.user-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--raised); flex-shrink: 0; }

/* Main content */
.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.top-banner {
  background: var(--live-bg);
  color: var(--live);
  border-bottom: 1px solid var(--live);
  padding: 10px 20px;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-title { font-size: 14px; font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-onair { background: var(--onair-bg); color: var(--onair); border: 1px solid var(--onair); }
.badge-live { background: var(--live-bg); color: var(--live); border: 1px solid var(--live); }
.badge-brand { background: var(--brand-bg); color: var(--brand); }
.badge-muted { background: var(--raised); color: var(--muted); }

@keyframes pulseGlow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  animation: pulseGlow 1.4s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .pulse-dot { animation: none; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, transform 80ms;
}
.btn:hover:not(:disabled) { background: var(--raised-hover); border-color: var(--brand); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.48; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: transparent; color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-onair { background: var(--onair-bg); border-color: var(--onair); color: var(--onair); }
.btn-danger { background: var(--live-bg); border-color: var(--live); color: var(--live); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Inputs */
.input, .select, .textarea {
  width: 100%;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--text);
  font-size: 13.5px;
}
.textarea { min-height: 76px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text); }

/* Toggle Switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.toggle-row:last-child { border-bottom: none; padding-bottom: 0; }
.switch {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--raised-hover);
  border: 1px solid var(--line-strong);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 140ms;
}
.switch.on { background: var(--onair); border-color: var(--onair); }
.switch:disabled { opacity: 0.4; cursor: not-allowed; }
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 140ms;
}
.switch.on::after { transform: translateX(18px); }

/* Queue rows */
.queue-list { display: flex; flex-direction: column; gap: 6px; }
.queue-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--raised);
  border: 1px solid transparent;
}
.queue-row.dragging { opacity: 0.5; border-color: var(--brand); }
.queue-row.drag-over { border-color: var(--onair); background: var(--onair-bg); }
.queue-thumb { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; background: var(--surface); flex-shrink: 0; }
.queue-info { flex: 1; min-width: 0; }
.queue-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Soundboard Pads */
.sound-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sound-pad {
  background: var(--raised);
  border: 1px solid var(--line);
  border-top: 3px solid var(--pad-accent, var(--onair));
  border-radius: var(--radius-pad);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 100ms, border-color 140ms;
}
.sound-pad:hover { border-color: var(--pad-accent, var(--onair)); transform: translateY(-1px); }
.pad-play {
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  padding: 2px 0;
  word-break: break-word;
}
.pad-actions { display: flex; gap: 5px; justify-content: flex-end; }

/* Progress & Bars */
.bar-track {
  height: 7px;
  border-radius: 999px;
  background: var(--raised);
  overflow: hidden;
  cursor: pointer;
}
.bar-fill { height: 100%; border-radius: 999px; background: var(--brand); transition: width 160ms linear; }
.bar-fill.ok { background: var(--ok); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.danger { background: var(--live); }

/* Chips */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12.5px;
}
.chip button { background: none; border: none; cursor: pointer; color: var(--muted); font-weight: 700; }
.chip button:hover { color: var(--live); }

/* Live Audio Dock */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--dock-h);
  background: var(--surface);
  border-top: 1px solid var(--line-strong);
  display: grid;
  grid-template-columns: minmax(200px, 1.2fr) minmax(240px, 1.5fr) minmax(180px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  z-index: 40;
}
.dock-track { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dock-cover {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--brand), var(--onair));
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.dock-center { display: flex; flex-direction: column; gap: 5px; }
.dock-buttons { display: flex; align-items: center; justify-content: center; gap: 8px; }
.dock-progress { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.dock-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  cursor: pointer;
  background: var(--raised);
}
.dropzone.active { border-color: var(--onair); background: var(--onair-bg); }

/* Login / Empty centered view */
.center-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--brand), var(--onair));
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 60;
}
.modal-box {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Toasts */
.toast-stack {
  position: fixed;
  right: 18px;
  bottom: calc(var(--dock-h) + 14px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 70;
  max-width: 360px;
}
.toast-item {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
}
.toast-item.ok { border-left-color: var(--ok); }
.toast-item.err { border-left-color: var(--live); }

/* Tables & Logs */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th, table.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
table.data-table th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }

.log-box {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  max-height: 320px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.log-err { color: var(--live); }
.log-warn { color: var(--onair); }

/* Mobile header & bottom tabs (hidden on desktop) */
.mobile-bar { display: none; }
.mobile-tabs { display: none; }

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; padding-bottom: 132px; }
  .guild-rail, .sidebar { display: none; }
  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 58px;
    background: var(--surface);
    border-top: 1px solid var(--line-strong);
    z-index: 45;
  }
  .mobile-tab {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
  }
  .mobile-tab.active { color: var(--onair); }
  .dock {
    bottom: 58px;
    height: auto;
    grid-template-columns: 1fr auto;
    padding: 8px 14px;
  }
  .dock-center { display: none; }
  .page-wrap { padding: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
