/* dashboard.css — GamerPapaBot dashboard.
   Self-contained: system font stack only, no @import, no external assets,
   no inline styles anywhere (CSP-friendly). Light + dark via
   prefers-color-scheme. */

:root {
  color-scheme: light dark;

  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --text: #1a1d22;
  --text-muted: #5b6270;
  --border: #d5dae2;
  --border-strong: #b9c0cc;

  --accent: #4059c8;
  --accent-hover: #33489f;
  --accent-text: #ffffff;

  --ok: #1c7c4a;
  --ok-bg: #e6f4ec;
  --warn: #8a5a10;
  --warn-bg: #fbf1de;
  --danger: #b02a2a;
  --danger-hover: #8d2020;
  --danger-bg: #fbeaea;
  --info-bg: #e8ecfb;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 20, 28, 0.08), 0 4px 12px rgba(16, 20, 28, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --surface: #1c1f26;
    --surface-2: #23272f;
    --text: #e7e9ee;
    --text-muted: #a0a7b4;
    --border: #313743;
    --border-strong: #454d5c;

    --accent: #6f86ee;
    --accent-hover: #8497f1;
    --accent-text: #10131a;

    --ok: #62d09a;
    --ok-bg: #16301f;
    --warn: #e6bd6a;
    --warn-bg: #33290f;
    --danger: #f08a8a;
    --danger-hover: #f5a3a3;
    --danger-bg: #35191a;
    --info-bg: #1e2437;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}

h2 {
  font-size: 1.25rem;
}

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

a {
  color: var(--accent);
}

.noscript {
  margin: 0;
  padding: 1rem;
  background: var(--warn-bg);
  color: var(--warn);
  text-align: center;
}

/* ---------- layout ---------- */

/* View roots are toggled with the hidden attribute, never inline styles. */
.view {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.view-center {
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.content {
  width: 100%;
  max-width: 1040px;
  flex: 1 1 auto;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.stack > * + * {
  margin-top: 1rem;
}

.spinner-line {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  color: var(--text-muted);
}

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}

/* ---------- login ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.card-login {
  width: 100%;
  max-width: 24rem;
  text-align: center;
}

.card-login > * + * {
  margin-top: 0.9rem;
}

.brand-title {
  font-size: 1.6rem;
}

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.topbar-user {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  min-width: 0;
}

.user-name {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 700;
}

.avatar-guild {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  width: 2.25rem;
  height: 2.25rem;
}

.footer {
  padding: 1rem;
  text-align: center;
  font-size: 0.8rem;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn:focus-visible,
.tab:focus-visible,
.input:focus-visible,
.guild-btn:focus-visible,
.panel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-bg);
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

/* ---------- notices ---------- */

.notice {
  margin: 0;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.92rem;
}

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

.notice-loading {
  color: var(--text-muted);
}

.notice-ok {
  background: var(--ok-bg);
  border-color: var(--ok);
  color: var(--ok);
}

.notice-warn {
  background: var(--warn-bg);
  border-color: var(--warn);
  color: var(--warn);
}

.notice-error {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

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

.small {
  font-size: 0.8rem;
}

.strong {
  font-weight: 600;
}

.block {
  display: block;
}

.nowrap {
  white-space: nowrap;
}

.id {
  color: var(--text-muted);
  word-break: break-all;
}

/* ---------- guild picker ---------- */

.guild-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}

.guild-item {
  display: block;
}

.guild-btn {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  padding: 0.75rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.guild-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.guild-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  background: var(--surface-2);
}

.guild-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.guild-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* ---------- tabs ---------- */

.guild-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.current-guild {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.tab {
  padding: 0.45rem 0.85rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tab-active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.panels {
  margin-top: 1rem;
}

.panel {
  outline-offset: 4px;
}

.tab-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: baseline;
  justify-content: space-between;
}

.tab-head > * {
  margin: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.toolbar-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ---------- forms ---------- */

.config-form {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.3rem;
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.field-invalid {
  border-color: var(--danger);
}

.field-label {
  font-weight: 600;
}

.field-help {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.field-error {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--danger);
}

.input {
  width: 100%;
  max-width: 30rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.input-inline {
  width: auto;
  max-width: 18rem;
}

/* roleList fields: a checkbox group instead of <select multiple>, so a role can
   be unticked with one click and the whole set emptied deliberately. */
.role-picker {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 30rem;
}

.role-options {
  display: flex;
  flex-direction: column;
  max-height: 14rem;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.role-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
}

.role-option + .role-option {
  border-top: 1px solid var(--border);
}

.role-option:hover {
  background: var(--surface-2);
}

.role-option-box {
  flex: none;
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.role-option-box:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.role-picker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.role-picker-summary {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.form-status {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.form-status-ok {
  color: var(--ok);
  font-weight: 600;
}

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  min-width: 46rem;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.table th,
.table td {
  padding: 0.6rem 0.7rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--surface-2);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.cell-action {
  text-align: right;
  white-space: nowrap;
}

/* ---------- badges / dots ---------- */

.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-open,
.badge-ok {
  background: var(--ok-bg);
  border-color: var(--ok);
  color: var(--ok);
}

.badge-started {
  background: var(--info-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.badge-expired {
  background: var(--warn-bg);
  border-color: var(--warn);
  color: var(--warn);
}

.badge-cancelled {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.badge-off {
  color: var(--text-muted);
}

.badge-action {
  background: var(--info-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}

.dot-ok {
  background: var(--ok);
}

.dot-bad {
  background: var(--danger);
}

/* ---------- status ---------- */

.ready-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.ready-text {
  font-weight: 600;
}

.stat-grid {
  margin-top: 1rem;
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* ---------- audit ---------- */

.audit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.audit-item {
  padding: 0.7rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.audit-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.audit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.audit-details {
  margin-top: 0.4rem;
  font-size: 0.85rem;
}

.audit-details summary {
  cursor: pointer;
  color: var(--accent);
}

.code-block {
  margin: 0.4rem 0 0;
  padding: 0.6rem;
  overflow-x: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  word-break: break-word;
}

.tab-body > * + * {
  margin-top: 0.75rem;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 10;
  max-width: min(92vw, 30rem);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}

.toast-ok {
  border-color: var(--ok);
  background: var(--ok-bg);
  color: var(--ok);
}

/* ---------- phone ---------- */

@media (max-width: 30rem) {
  body {
    font-size: 15px;
  }

  .content {
    padding: 1rem 0.75rem 2.5rem;
  }

  .card {
    padding: 1.25rem;
  }

  .user-name {
    max-width: 7rem;
  }

  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .tab {
    white-space: nowrap;
  }

  .table {
    min-width: 38rem;
  }
}
