/* wf-ui.css - Shell + shared components. Loaded after the legacy stylesheets. */

:root {
  --wf-bg: #0B0F17;
  --wf-surface: #111827;
  --wf-surface-2: #172033;
  --wf-line: #1F2A3D;
  --wf-line-strong: #2B3A52;
  --wf-text: #F1F5F9;
  --wf-text-2: #B6C2D3;
  --wf-text-3: #8492A6;
  --wf-accent: var(--theme-accent, #9B1B30);
  --wf-accent-hover: var(--theme-accent-hover, #B3243C);
  --wf-accent-soft: var(--theme-accent-light, rgba(155, 27, 48, 0.18));
  --wf-accent-line: var(--theme-accent-border, rgba(180, 35, 60, 0.5));
  --wf-ok: #34D399;
  --wf-warn: #FBBF24;
  --wf-err: #F87171;
  --wf-gold: #FBBF24;
  --wf-tank: #60A5FA;
  --wf-air: #22D3EE;
  --wf-missile: #FB923C;
  --wf-radius: 14px;
  --wf-radius-sm: 10px;
  --wf-header-h: 56px;
  --wf-bottom-h: 64px;
  --wf-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --wf-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --wf-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--wf-font);
  background: var(--wf-bg);
  color: var(--wf-text);
  min-height: 100vh;
  min-height: 100dvh;
}
body.wf-modal-open { overflow: hidden; }

.wf-skip {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--wf-accent); color: #fff; padding: 8px 12px; border-radius: 8px;
}
.wf-skip:focus { left: 8px; }

:focus-visible { outline: 2px solid var(--wf-accent-hover); outline-offset: 2px; }

.wf-icon { width: 20px; height: 20px; flex: none; }
.wf-icon-sm { width: 14px; height: 14px; }
.wf-mono { font-family: var(--wf-mono); }
.wf-muted { color: var(--wf-text-2); font-size: 14px; line-height: 1.55; margin: 0 0 12px; }
.wf-hint { color: var(--wf-text-3); font-size: 12.5px; line-height: 1.5; margin: 4px 0 0; }

/* ---------------------------------------------------------------- Header */
.wf-navbar, .wf-mobile-drawer, .wf-mobile-backdrop, #wf-scroll-top-btn { display: none !important; }

.wf-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--wf-header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
  background: rgba(11, 15, 23, 0.92);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--wf-line);
}
.wf-logo {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  color: var(--wf-text); text-decoration: none;
  font-family: var(--wf-display); font-weight: 700; letter-spacing: 0.06em; font-size: 15px;
}
.wf-logo img { filter: brightness(0) invert(1); }

.wf-alliance-chip {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 46vw;
  height: 34px; padding: 0 10px 0 12px;
  border-radius: 999px; border: 1px solid var(--wf-line-strong);
  background: var(--wf-surface); color: var(--wf-text);
  font-family: var(--wf-mono); font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em;
  cursor: pointer;
}
.wf-alliance-chip > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-alliance-chip:hover { border-color: var(--wf-accent-line); }
.wf-alliance-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--wf-ok); flex: none; }
.wf-alliance-chip.is-empty { border-style: dashed; color: var(--wf-warn); }
.wf-alliance-chip.is-empty .wf-alliance-dot { background: var(--wf-warn); }

.wf-nav { display: none; align-items: center; gap: 2px; margin: 0 auto; min-width: 0; }
.wf-nav-link {
  padding: 8px 10px; border-radius: 8px;
  color: var(--wf-text-2); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.wf-nav-link:hover { color: var(--wf-text); background: var(--wf-surface); }
.wf-nav-link[aria-current="page"] { color: var(--wf-text); background: var(--wf-accent-soft); box-shadow: inset 0 0 0 1px var(--wf-accent-line); }

.wf-leader-btn {
  margin-left: auto; flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--wf-line-strong); background: var(--wf-surface); color: var(--wf-text-2);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.wf-leader-btn:hover { color: var(--wf-text); border-color: var(--wf-accent-line); }
.wf-leader-btn.is-active { color: var(--wf-gold); border-color: rgba(251, 191, 36, 0.5); background: rgba(251, 191, 36, 0.08); }

@media (min-width: 1100px) {
  .wf-nav { display: flex; }
  .wf-leader-btn { margin-left: 0; }
}
@media (max-width: 420px) {
  .wf-logo span { display: none; }
  .wf-leader-text { display: none; }
  .wf-leader-btn { width: 34px; padding: 0; justify-content: center; }
  .wf-alliance-chip { max-width: none; flex: 1 1 auto; }
  .wf-header { gap: 10px; }
}

/* ---------------------------------------------------------- Bottom nav */
.wf-bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: var(--wf-bottom-h);
  padding-bottom: env(safe-area-inset-bottom);
  box-sizing: content-box;
  background: rgba(11, 15, 23, 0.96);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--wf-line);
}
.wf-bottom-nav a, .wf-bottom-nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--wf-text-3); text-decoration: none; background: none; border: 0;
  font-size: 11px; font-weight: 600; cursor: pointer;
}
.wf-bottom-nav [aria-current="page"] { color: var(--wf-text); }
.wf-bottom-nav [aria-current="page"] .wf-icon { color: var(--wf-accent-hover); }
.wf-bottom-nav .wf-icon { width: 22px; height: 22px; }
body { padding-bottom: calc(var(--wf-bottom-h) + env(safe-area-inset-bottom)); }
@media (min-width: 1100px) {
  .wf-bottom-nav { display: none; }
  body { padding-bottom: 0; }
}

.wf-footer {
  max-width: 1200px; margin: 32px auto 0; padding: 20px 16px 28px;
  border-top: 1px solid var(--wf-line);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  color: var(--wf-text-3); font-size: 12.5px;
}
.wf-footer p { margin: 0; }
.wf-page-advisor .wf-footer { display: none; }
.wf-theme-row { display: flex; align-items: center; gap: 10px; }
.wf-theme-row > span { font-size: 12.5px; color: var(--wf-text-3); margin-right: 2px; }
.wf-theme-dot { width: 22px !important; height: 22px !important; }

/* --------------------------------------------------------- Modals/sheets */
.wf-modal, .wf-sheet {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 12, 0.72);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.wf-modal[hidden], .wf-sheet[hidden] { display: none; }
.wf-modal-panel {
  width: 100%; max-width: 460px; max-height: calc(100dvh - 32px); overflow-y: auto;
  background: #0F1522; border: 1px solid var(--wf-line-strong); border-radius: 18px;
  padding: 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.wf-modal-sm { max-width: 400px; }
.wf-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.wf-modal-head h2 { margin: 0; font-family: var(--wf-display); font-size: 19px; font-weight: 700; }
.wf-icon-btn {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; color: var(--wf-text-2); cursor: pointer;
}
.wf-icon-btn:hover { background: var(--wf-surface); color: var(--wf-text); }

.wf-sheet { align-items: flex-end; padding: 0; }
.wf-sheet-panel {
  width: 100%; max-width: 560px;
  background: #0F1522; border: 1px solid var(--wf-line-strong); border-bottom: 0;
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
}
.wf-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.wf-more-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.wf-more-grid a {
  display: flex; align-items: center; gap: 10px; padding: 14px;
  border-radius: 12px; border: 1px solid var(--wf-line); background: var(--wf-surface);
  color: var(--wf-text); text-decoration: none; font-weight: 600; font-size: 14px;
}
.wf-more-grid a[aria-current="page"] { border-color: var(--wf-accent-line); background: var(--wf-accent-soft); }

.wf-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin-bottom: 16px; border-radius: 12px; background: #080C14; border: 1px solid var(--wf-line); }
.wf-tabs button { height: 36px; border-radius: 9px; border: 0; background: transparent; color: var(--wf-text-2); font-weight: 600; font-size: 14px; cursor: pointer; }
.wf-tabs button.is-active { background: var(--wf-surface-2); color: var(--wf-text); box-shadow: inset 0 0 0 1px var(--wf-line-strong); }

/* ---------------------------------------------------------------- Forms */
.wf-field { display: block; margin-bottom: 12px; }
.wf-field > span { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--wf-text-2); }
.wf-field > span em { font-style: normal; font-weight: 400; color: var(--wf-text-3); }
.wf-field-row { display: grid; grid-template-columns: 1fr 120px; gap: 10px; }
@media (max-width: 420px) { .wf-field-row { grid-template-columns: 1fr; } }
.wf-input, .wf-select, .wf-textarea {
  width: 100%; box-sizing: border-box;
  min-height: 44px; padding: 10px 12px;
  border-radius: var(--wf-radius-sm); border: 1px solid var(--wf-line-strong);
  background: #080C14; color: var(--wf-text);
  font: inherit; font-size: 16px; /* 16px stops iOS zoom on focus */
}
.wf-textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.wf-input:focus, .wf-select:focus, .wf-textarea:focus { outline: none; border-color: var(--wf-accent-hover); box-shadow: 0 0 0 3px var(--wf-accent-soft); }
.wf-input[readonly] { color: var(--wf-text-2); }
.wf-form-msg { min-height: 0; margin: 4px 0 10px; font-size: 13.5px; }
.wf-form-msg:empty { display: none; }
.wf-form-msg.is-error { color: var(--wf-err); }
.wf-form-msg.is-ok { color: var(--wf-ok); }
.wf-copy-row { display: flex; gap: 8px; }
.wf-copy-row .wf-input { font-family: var(--wf-mono); font-size: 13px; }
.wf-details { margin: 8px 0 12px; border: 1px solid var(--wf-line); border-radius: 12px; padding: 10px 12px; }
.wf-details summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--wf-text-2); }
.wf-details form { margin-top: 12px; }
.wf-invite-admin { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--wf-line); }

/* -------------------------------------------------------------- Buttons */
.wf-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--wf-line-strong); background: var(--wf-surface-2); color: var(--wf-text);
  font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.wf-btn:hover { border-color: #3A4C68; background: #1C2740; }
.wf-btn:active { transform: translateY(1px); }
.wf-btn:disabled, .wf-btn.is-busy { opacity: 0.6; cursor: progress; }
.wf-btn-primary { background: var(--wf-accent); border-color: var(--wf-accent-hover); color: #fff; }
.wf-btn-primary:hover { background: var(--wf-accent-hover); border-color: var(--wf-accent-hover); }
.wf-btn-danger { background: transparent; border-color: rgba(248, 113, 113, 0.4); color: #FCA5A5; }
.wf-btn-danger:hover { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.7); }
.wf-btn-ghost { background: transparent; border-color: transparent; color: var(--wf-text-2); }
.wf-btn-ghost:hover { background: var(--wf-surface); color: var(--wf-text); }
.wf-btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.wf-btn-block { width: 100%; margin-top: 8px; }

.wf-chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.wf-chip-row:empty { display: none; }
.wf-chip {
  height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--wf-line-strong); background: var(--wf-surface); color: var(--wf-text-2);
  font-family: var(--wf-mono); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.wf-chip:hover, .wf-chip.is-active { color: var(--wf-text); border-color: var(--wf-accent-line); background: var(--wf-accent-soft); }

/* --------------------------------------------------------------- Toasts */
#wf-toasts {
  position: fixed; z-index: 80; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--wf-bottom-h) + 16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none;
}
@media (min-width: 1100px) { #wf-toasts { bottom: 24px; } }
.wf-toast {
  padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.4;
  background: #182235; color: var(--wf-text); border: 1px solid var(--wf-line-strong);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: wf-toast-in 0.18s ease-out;
}
.wf-toast-ok { border-color: rgba(52, 211, 153, 0.45); }
.wf-toast-error { border-color: rgba(248, 113, 113, 0.55); }
.wf-toast-out { opacity: 0; transform: translateY(6px); transition: all 0.4s; }
@keyframes wf-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------- Page parts */
.container-main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 8px; box-sizing: border-box; }
@media (min-width: 768px) { .container-main { padding: 28px 24px 8px; } }

.wf-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.wf-page-head h1 { margin: 0; font-family: var(--wf-display); font-size: clamp(24px, 4vw, 32px); font-weight: 700; letter-spacing: -0.01em; }
.wf-page-head p { margin: 6px 0 0; color: var(--wf-text-2); font-size: 15px; max-width: 60ch; }
.wf-page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.wf-eyebrow { font-family: var(--wf-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--wf-text-3); }

.wf-card { background: var(--wf-surface); border: 1px solid var(--wf-line); border-radius: var(--wf-radius); padding: 16px; }
.wf-card + .wf-card { margin-top: 16px; }
.wf-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.wf-card-head h2, .wf-card-head h3 { margin: 0; font-size: 16px; font-weight: 700; }

.wf-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
@media (min-width: 900px) { .wf-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.wf-stat { background: var(--wf-surface); border: 1px solid var(--wf-line); border-radius: var(--wf-radius); padding: 14px 16px; min-width: 0; }
.wf-stat-label { font-size: 12.5px; color: var(--wf-text-3); font-weight: 600; }
.wf-stat-value { margin-top: 4px; font-family: var(--wf-display); font-size: 26px; font-weight: 700; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-stat-sub { margin-top: 4px; font-size: 12.5px; color: var(--wf-text-2); }

.wf-badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.02em; border: 1px solid var(--wf-line-strong); color: var(--wf-text-2); background: #0D1322; white-space: nowrap; }
.wf-badge-tank { color: var(--wf-tank); border-color: rgba(96, 165, 250, 0.35); }
.wf-badge-air { color: var(--wf-air); border-color: rgba(34, 211, 238, 0.35); }
.wf-badge-missile { color: var(--wf-missile); border-color: rgba(251, 146, 60, 0.35); }
.wf-badge-warn { color: var(--wf-warn); border-color: rgba(251, 191, 36, 0.4); }
.wf-badge-ok { color: var(--wf-ok); border-color: rgba(52, 211, 153, 0.4); }

.wf-gate { text-align: center; max-width: 440px; margin: 24px auto; padding: 28px 20px; border: 1px dashed var(--wf-line-strong); border-radius: 18px; background: var(--wf-surface); }
.wf-gate h2 { margin: 0 0 6px; font-family: var(--wf-display); font-size: 20px; }
.wf-gate p { margin: 0 0 16px; color: var(--wf-text-2); font-size: 14.5px; line-height: 1.55; }
.wf-gate-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.wf-empty { text-align: center; color: var(--wf-text-2); padding: 28px 16px; font-size: 14.5px; }
.wf-empty strong { display: block; color: var(--wf-text); font-size: 16px; margin-bottom: 4px; }
.wf-empty-page { text-align: center; padding: 64px 16px; }
.wf-empty-page h1 { font-family: var(--wf-display); margin: 0 0 8px; }
.wf-empty-page p { color: var(--wf-text-2); margin: 0 0 20px; }

.wf-banner { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; border: 1px solid var(--wf-line-strong); background: var(--wf-surface); color: var(--wf-text-2); margin-bottom: 16px; }
.wf-banner strong { color: var(--wf-text); }
.wf-banner-warn { border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.06); }
.wf-banner-info { border-color: rgba(96, 165, 250, 0.3); background: rgba(96, 165, 250, 0.06); }

/* Leader-only / member-only content */
.wf-leader-only { display: none !important; }
html.wf-is-leader .wf-leader-only { display: revert !important; }
html.wf-is-leader .wf-hide-for-leader { display: none !important; }

/* Tables */
.wf-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--wf-line); border-radius: var(--wf-radius); }
.wf-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.wf-table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--wf-text-3); padding: 10px 12px; border-bottom: 1px solid var(--wf-line); white-space: nowrap; background: #0D1322; position: sticky; top: 0; }
.wf-table td { padding: 10px 12px; border-bottom: 1px solid var(--wf-line); vertical-align: middle; }
.wf-table tr:last-child td { border-bottom: 0; }
.wf-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
