/* ==========================================================================
   Veyra app shell — dashboard, admin, status, login
   Built on top of css/style.css (shared tokens, buttons, nav, cards).
   ========================================================================== */

body { overflow-x: initial; }

/* ---- App shell layout ---- */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.app-sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.app-sidebar .brand { padding: 6px 8px 22px; }
.app-sidebar .brand img { height: 32px; }
.app-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.app-nav-link:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.app-nav-link.is-active { background: var(--card-hover); color: var(--text); }
.app-nav-link .icon { width: 17px; height: 17px; flex-shrink: 0; }
.app-sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.app-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}
.app-user img { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.app-user__name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-main { padding: 36px 40px 60px; max-width: 1100px; }
.app-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.app-header h1 { font-size: 26px; font-weight: 800; }
.app-breadcrumb { font-size: 13.5px; color: var(--text-faint); margin-bottom: 8px; }
.app-breadcrumb a { color: var(--text-faint); }
.app-breadcrumb a:hover { color: var(--text-muted); }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar { display: flex; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 12px; }
  .app-sidebar .brand, .app-sidebar-footer { display: none; }
  .app-main { padding: 24px 18px 48px; }
}

/* ---- Guild picker grid ---- */
.guild-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.guild-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.guild-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.guild-card__head { display: flex; align-items: center; gap: 12px; }
.guild-card__icon { width: 44px; height: 44px; border-radius: 12px; background: var(--bg-elevated); object-fit: cover; flex-shrink: 0; }
.guild-card__icon-fallback {
  width: 44px; height: 44px; border-radius: 12px; background: var(--grad-soft); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0;
}
.guild-card__name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild-card__status { font-size: 12.5px; color: var(--text-faint); display: flex; align-items: center; gap: 6px; }
.status-pill { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.status-pill--on { background: #3ddc84; }
.status-pill--off { background: #6b7284; }

/* ---- Module list ---- */
.module-list { display: flex; flex-direction: column; gap: 14px; }
.module-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
}
.module-row__top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.module-row__info h3 { font-size: 16.5px; margin-bottom: 3px; }
.module-row__info p { font-size: 13.5px; color: var(--text-muted); }
.module-row__badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 3px 8px; border-radius: var(--r-full); background: rgba(245, 177, 66, 0.12); color: #f5b142; margin-left: 8px;
}
.module-row__config { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); display: none; }
.module-row.is-enabled .module-row__config { display: block; }

/* ---- Toggle switch ---- */
.toggle { display: inline-flex; align-items: center; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle__track {
  width: 42px; height: 24px; border-radius: var(--r-full); background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-strong); position: relative; cursor: pointer; transition: background 0.2s var(--ease);
  flex-shrink: 0;
}
.toggle__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform 0.2s var(--ease);
}
.toggle input:checked + .toggle__track { background: var(--grad-brand); border-color: transparent; }
.toggle input:checked + .toggle__track::after { transform: translateX(18px); }
.toggle input:focus-visible + .toggle__track { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.field input[type="text"],
.field textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--border-strong); }

/* ---- Tables ---- */
.app-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.app-table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint); padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.app-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.app-table tr:last-child td { border-bottom: none; }
.app-table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; overflow-x: auto; }

/* ---- Stat tiles ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; }
.stat-tile__label { font-size: 12.5px; color: var(--text-faint); margin-bottom: 6px; }
.stat-tile__value { font-size: 26px; font-weight: 800; }

/* ---- Status page ---- */
.status-banner {
  display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-radius: var(--r-lg);
  border: 1px solid var(--border-strong); margin-bottom: 32px; font-weight: 700; font-size: 16px;
}
.status-banner--operational { background: rgba(61, 220, 132, 0.08); color: #3ddc84; }
.status-banner--degraded { background: rgba(245, 177, 66, 0.1); color: #f5b142; }
.status-banner--major_outage { background: rgba(240, 90, 90, 0.1); color: #f05a5a; }
.status-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.status-row:last-child { border-bottom: none; }
.status-badge { font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: var(--r-full); }
.status-badge--operational { background: rgba(61, 220, 132, 0.12); color: #3ddc84; }
.status-badge--down { background: rgba(240, 90, 90, 0.12); color: #f05a5a; }

/* ---- Login page ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  max-width: 400px; width: 100%; text-align: center; background: var(--card);
  border: 1px solid var(--border-strong); border-radius: var(--r-xl); padding: 48px 36px; box-shadow: var(--shadow-lg);
}
.login-card img { height: 54px; margin: 0 auto 22px; }
.login-card h1 { font-size: 22px; margin-bottom: 10px; }
.login-card p { color: var(--text-muted); font-size: 14.5px; margin-bottom: 28px; }
.login-error { background: rgba(240, 90, 90, 0.1); color: #f08080; border: 1px solid rgba(240, 90, 90, 0.3); border-radius: var(--r-sm); padding: 10px 14px; font-size: 13.5px; margin-bottom: 20px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty-state h3 { color: var(--text-muted); font-size: 17px; margin-bottom: 8px; }

/* ---- Custom select (see public/js/select.js) ---- */
.vselect { position: relative; }
.vselect__native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.vselect__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s var(--ease);
}
.vselect__trigger:hover { border-color: var(--border-strong); }
.vselect.is-open .vselect__trigger { border-color: var(--cyan); }
.vselect__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vselect__chevron { width: 15px; height: 15px; color: var(--text-faint); flex-shrink: 0; transition: transform 0.2s var(--ease); }
.vselect.is-open .vselect__chevron { transform: rotate(180deg); color: var(--cyan); }

.vselect__list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  max-height: 260px;
  overflow-y: auto;
  display: none;
}
.vselect.is-open .vselect__list { display: block; }
.vselect__option {
  padding: 9px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  outline: none;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.vselect__option:hover, .vselect__option:focus { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.vselect__option[aria-selected="true"] { color: var(--text); background: var(--grad-soft); font-weight: 600; }
