/* ============================================================
   GWM V2 — Views CSS
   Attendance · Audit · Theme Editor · Tweaks Drawer
   ============================================================ */

/* ── ATTENDANCE ──────────────────────────────────────────── */
.att-table-wrap {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--r); overflow: hidden;
}
.att-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.att-table thead tr {
  background: var(--bg-deep); border-bottom: 1px solid var(--line-soft);
}
.att-table th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 500; color: var(--fg-3);
  letter-spacing: 0.02em; white-space: nowrap;
}
.att-table tbody tr {
  border-bottom: 1px solid var(--line-soft);
  transition: background .1s; cursor: pointer;
}
.att-table tbody tr:last-child { border-bottom: none; }
.att-table tbody tr:hover { background: var(--panel-2); }
.att-table td { padding: 12px 14px; vertical-align: middle; }

/* War name cell */
.war-name { font-weight: 600; font-size: 13px; }
.war-date { font-size: 12px; color: var(--fg-3); margin-top: 2px; }

/* Result pill */
.result-pill {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.03em; text-transform: uppercase;
}
.result-pill.victory {
  background: color-mix(in oklch, var(--ready) 18%, var(--panel));
  color: var(--ready);
  border: 1px solid color-mix(in oklch, var(--ready) 35%, transparent);
}
.result-pill.defeat {
  background: color-mix(in oklch, var(--absent) 18%, var(--panel));
  color: var(--absent);
  border: 1px solid color-mix(in oklch, var(--absent) 35%, transparent);
}
.result-pill.pending {
  background: var(--panel-2); color: var(--fg-3);
  border: 1px solid var(--line-soft);
}

/* Turnout bar */
.turnout-wrap { display: flex; align-items: center; gap: 10px; }
.turnout-text { font-family: 'Geist Mono', monospace; font-size: 12px; font-weight: 500; white-space: nowrap; }
.turnout-bar {
  flex: 1; height: 6px; border-radius: 3px;
  background: var(--panel-3); overflow: hidden; min-width: 80px;
}
.turnout-bar > i {
  display: block; height: 100%; border-radius: 3px;
  transition: width .3s ease;
}
.turnout-bar .high { background: linear-gradient(90deg, var(--ready), color-mix(in oklch, var(--ready) 80%, var(--accent))); }
.turnout-bar .mid  { background: linear-gradient(90deg, var(--late), color-mix(in oklch, var(--late) 80%, var(--gold))); }
.turnout-bar .low  { background: linear-gradient(90deg, var(--absent), color-mix(in oklch, var(--absent) 80%, var(--crimson))); }

/* Log war modal */
.log-war-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.result-picker { display: flex; gap: 8px; }
.result-btn {
  flex: 1; padding: 10px; border-radius: var(--r-sm); text-align: center;
  border: 1.5px solid var(--line-soft); cursor: pointer;
  font-weight: 600; font-size: 13px; transition: all .14s;
}
.result-btn:hover { border-color: var(--line); }
.result-btn.victory.on { border-color: var(--ready); background: color-mix(in oklch, var(--ready) 14%, var(--panel)); color: var(--ready); }
.result-btn.defeat.on  { border-color: var(--absent); background: color-mix(in oklch, var(--absent) 14%, var(--panel)); color: var(--absent); }

/* ── AUDIT LOG ───────────────────────────────────────────── */
.audit-wrap {
  background: var(--bg-deep); border: 1px solid var(--line-soft);
  border-radius: var(--r); overflow: hidden;
  font-family: 'Geist Mono', monospace; font-size: 12px;
}
.audit-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--panel);
  border-bottom: 1px solid var(--line-soft);
}
.audit-head .dots { display: flex; gap: 6px; }
.audit-head .dots i { width: 10px; height: 10px; border-radius: 50%; display: block; }
.audit-head .dots i:nth-child(1) { background: #ff5f57; }
.audit-head .dots i:nth-child(2) { background: #ffbd2e; }
.audit-head .dots i:nth-child(3) { background: #28ca42; }
.audit-head .path { color: var(--fg-3); }
.audit-blink { color: var(--ready); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.audit-list {
  max-height: 600px; overflow-y: auto; padding: 6px 0;
}
.audit-entry {
  display: flex; gap: 10px; padding: 5px 14px; line-height: 1.5;
  transition: background .1s;
}
.audit-entry:hover { background: var(--panel); }
.audit-ts { color: var(--fg-3); flex: none; width: 110px; white-space: nowrap; }
.audit-user { color: var(--accent); flex: none; width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-action {
  flex: none; width: 90px; font-weight: 600; text-transform: uppercase;
  font-size: 10px; letter-spacing: 0.04em;
}
.audit-action.ADD    { color: var(--ready); }
.audit-action.DELETE { color: var(--absent); }
.audit-action.UPDATE { color: var(--late); }
.audit-action.ASSIGN { color: var(--azure); }
.audit-action.STATUS { color: var(--gold); }
.audit-action.ZONE_UPDATE  { color: var(--accent); }
.audit-action.ZONE_DELETE  { color: var(--absent); }
.audit-action.ZONE_CLEAR   { color: var(--late); }
.audit-action.WAR_LOG      { color: var(--ready); }
/* RENAME — highlighted: gold text + soft gold tint on the whole row so admins
   can spot identity changes at a glance amid generic UPDATE noise. */
.audit-action.RENAME       { color: var(--gold); font-weight: 700; }
.audit-entry:has(.audit-action.RENAME) {
  background: color-mix(in oklch, var(--gold) 7%, transparent);
}
.audit-detail { color: var(--fg-2); flex: 1; }

/* ── TWEAKS DRAWER ───────────────────────────────────────── */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 700;
  background: rgba(0,0,0,.4); backdrop-filter: blur(2px);
  animation: fadeIn .12s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 701;
  width: 340px; max-width: 90vw;
  background: var(--panel); border-left: 1px solid var(--line-soft);
  box-shadow: -8px 0 30px rgba(0,0,0,.4);
  display: flex; flex-direction: column;
  animation: slideIn .18s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: none; } }

.drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--line-soft); flex: none;
}
.drawer-head h3 { font-size: 15px; font-weight: 600; flex: 1; }
.drawer-body {
  flex: 1; overflow-y: auto; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 20px;
}

/* Drawer sections */
.drawer-section { display: flex; flex-direction: column; gap: 10px; }
.drawer-section-title {
  font-size: 11px; font-weight: 500; color: var(--fg-3);
  letter-spacing: 0.03em; text-transform: uppercase;
  padding-bottom: 4px; border-bottom: 1px solid var(--line-soft);
}

/* Theme swatches in drawer */
.theme-row {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.theme-btn {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  border: 2px solid transparent; cursor: pointer;
  transition: transform .12s, border-color .12s;
  position: relative;
}
.theme-btn:hover { transform: scale(1.1); }
.theme-btn.on { border-color: var(--fg); }
.theme-btn .th-check {
  position: absolute; inset: 0; display: grid; place-items: center;
  opacity: 0; background: rgba(0,0,0,.3); border-radius: 6px;
}
.theme-btn.on .th-check { opacity: 1; }
.theme-btn .th-check svg { width: 14px; height: 14px; color: #fff; }

/* Density toggle in drawer */
.density-row { display: flex; gap: 6px; }
.density-btn {
  flex: 1; padding: 8px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-soft); background: var(--panel-2);
  font-size: 12px; font-weight: 500; color: var(--fg-3);
  cursor: pointer; transition: all .12s; text-align: center;
}
.density-btn:hover { border-color: var(--line); color: var(--fg-2); }
.density-btn.on {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-dim);
}

/* Toggle switch */
.toggle-switch {
  width: 40px; height: 22px; border-radius: 11px; padding: 2px;
  background: var(--panel-3); border: 1px solid var(--line-soft);
  cursor: pointer; transition: background .14s, border-color .14s;
  display: flex; align-items: center; flex: none;
}
.toggle-switch.on { background: var(--accent); border-color: var(--accent); }
.toggle-knob {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--fg-3); transition: transform .14s, background .14s;
}
.toggle-switch.on .toggle-knob { transform: translateX(18px); background: var(--accent-ink); }

/* Tweak toggle row */
.tweak-toggle-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}
.tweak-info { flex: 1; }
.tweak-label { font-size: 13px; font-weight: 500; color: var(--fg); display: block; }
.tweak-desc { font-size: 11px; color: var(--fg-3); display: block; margin-top: 2px; }

/* War Schedule card (in Attendance) */
.war-sched-card {
  display: flex; gap: 20px; align-items: center; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: 12px 16px; margin-bottom: 14px;
}
.war-sched-item {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
}
.war-sched-item .ws-label { color: var(--fg-3); font-size: 12px; }
.war-sched-item .ws-value {
  font-family: 'Geist Mono', monospace; font-weight: 600; font-size: 13px;
}

/* Guild info in drawer */
.guild-info-card {
  background: var(--bg-deep); border: 1px solid var(--line-soft);
  border-radius: var(--r-sm); padding: 12px; display: flex; gap: 12px; align-items: center;
}
.guild-info-card .gi-crest {
  width: 44px; height: 44px; border-radius: var(--r-sm); flex: none;
  display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
}
.guild-info-card .gi-crest img { width: 100%; height: 100%; object-fit: cover; }
.guild-info-card .gi-name { font-weight: 600; font-size: 14px; }
.guild-info-card .gi-slug { font-size: 11px; color: var(--fg-3); font-family: 'Geist Mono', monospace; margin-top: 2px; }

/* Logo change button */
.logo-change-row {
  display: flex; align-items: center; gap: 10px;
}
.logo-change-row .current-logo {
  width: 48px; height: 48px; border-radius: var(--r-sm); flex: none;
  display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  border: 1px solid var(--line-soft);
}
.logo-change-row .current-logo img { width: 100%; height: 100%; object-fit: cover; }

/* ── Audit toolbar (filter + search) ─────────────────────── */
.audit-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.audit-fchip { padding: 2px 10px; border-radius: 99px; font-size: 10.5px; letter-spacing: .04em; font-family: inherit; cursor: pointer; background: transparent; color: var(--fg-3); border: 1px solid color-mix(in oklch, var(--fg-3) 35%, transparent); }
.audit-fchip:hover { color: var(--fg-1); border-color: var(--fg-3); }
.audit-fchip.on { color: var(--accent); border-color: var(--accent); background: color-mix(in oklch, var(--accent) 12%, transparent); }
.audit-search { margin-left: auto; min-width: 180px; padding: 4px 10px; font-size: 11.5px; background: transparent; border: 1px solid var(--line); border-radius: 6px; color: var(--fg-1); }
/* ════════════════════════════════════════════════════════════
   MOBILE (≤640px): Audit log rows → stacked cards
   Fixed ts/user/action widths drop; detail wraps full-width.
   ════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .audit-list { max-height: none; }
  .audit-entry {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 3px 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-sm);
    line-height: 1.45;
  }
  .audit-entry:hover { background: transparent; }
  .audit-ts     { width: auto; grid-column: 1; }
  .audit-action { width: auto; grid-column: 2; justify-self: end; }
  .audit-user   { width: auto; max-width: 100%; grid-column: 1 / -1; }
  .audit-detail { grid-column: 1 / -1; white-space: normal; overflow-wrap: anywhere; }
  .audit-blink  { display: none; }
}
