/* =============================================================
   WARZONE ROULETTE — Tailwind/shadcn-like UI
   Light + dark via [data-theme]
   ============================================================= */

:root {
  /* Light theme (default) */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: #dbeafe;
  --primary-fg: #ffffff;

  --secondary: #10b981;
  --secondary-hover: #059669;
  --secondary-soft: #d1fae5;

  --warn: #f59e0b;
  --warn-soft: #fef3c7;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-soft: #fee2e2;
  --danger-fg: #ffffff;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  --t: 0.15s ease;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1f2937;
  --border: #1f2937;
  --border-strong: #374151;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --primary-soft: rgba(59, 130, 246, 0.18);
  --primary-fg: #0b1120;

  --secondary: #34d399;
  --secondary-hover: #10b981;
  --secondary-soft: rgba(16, 185, 129, 0.18);

  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.18);
  --danger: #f87171;
  --danger-hover: #ef4444;
  --danger-soft: rgba(248, 113, 113, 0.18);
  --danger-fg: #0b1120;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background var(--t), color var(--t);
}

::selection { background: var(--primary-soft); color: var(--text); }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; }
.muted { color: var(--text-muted); }

/* ===================== TOPBAR ===================== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.2px;
}
.brand-mark { font-size: 20px; }
.nav {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.navbtn {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--r-sm);
  transition: all var(--t);
}
.navbtn:hover { color: var(--text); }
.navbtn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.topbar-actions {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
}

/* ===================== BADGES ===================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--r-full);
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid transparent;
}
.badge-muted {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--border);
}
.badge.online {
  background: var(--secondary-soft);
  color: var(--secondary);
}
.badge.online::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--secondary);
  border-radius: 50%;
  display: inline-block;
}

/* ===================== ICON BUTTON ===================== */
.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 16px;
  color: var(--text-muted);
  transition: all var(--t);
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
#theme-toggle .theme-icon-light { display: none; }
#theme-toggle .theme-icon-dark { display: inline; }
[data-theme="dark"] #theme-toggle .theme-icon-light { display: inline; }
[data-theme="dark"] #theme-toggle .theme-icon-dark { display: none; }

/* ===================== MAIN ===================== */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 100px;
}
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===================== HERO ===================== */
.hero {
  margin-bottom: 32px;
  padding: 8px 0 16px;
}
.hero h1 {
  font-size: clamp(28px, 4.5vw, 44px);
  letter-spacing: -1px;
  margin-bottom: 12px;
}
.hero p { font-size: 17px; max-width: 600px; }

/* ===================== CARDS ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t), box-shadow var(--t);
}

/* ===================== SLOTS ===================== */
.slots-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 760px) {
  .slots-grid { grid-template-columns: 1fr; }
}
.slot { display: flex; flex-direction: column; }
.slot-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.slot-head h3 { font-size: 14px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

.slot-display {
  flex: 1;
  min-height: 200px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 28px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
}
.slot-empty {
  color: var(--text-faint);
  font-size: 14px;
}
.slot-display.spinning {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.slot[data-type="weapon"] .slot-display.spinning {
  background: var(--secondary-soft);
  border-color: var(--secondary);
}
.spin-text {
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.5px;
}
.slot[data-type="weapon"] .spin-text { color: var(--secondary); }

.result { animation: pop 0.3s ease; width: 100%; }
@keyframes pop {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}
.result-title {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 10px;
}
.result-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 14px;
  max-width: 38ch;
  margin-left: auto; margin-right: auto;
}
.result-meta {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.result-meta.facile { background: var(--secondary-soft); color: var(--secondary); border-color: transparent; }
.result-meta.normal { background: var(--surface-2); color: var(--text-muted); }
.result-meta.difficile { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.result-meta.extreme { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  transition: all var(--t);
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.btn:active { transform: translateY(1px); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn-block { display: flex; width: 100%; padding: 12px 18px; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--primary-fg);
  border-color: var(--secondary);
}
.btn-secondary:hover {
  background: var(--secondary-hover);
  border-color: var(--secondary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

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

.btn-mega {
  padding: 18px;
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #ffffff;
  border: none;
  box-shadow: var(--shadow);
}
.btn-mega:hover {
  filter: brightness(1.05);
  box-shadow: var(--shadow-lg);
}

/* ===================== ADMIN — LOGIN ===================== */
.login-card {
  max-width: 440px;
  margin: 40px auto;
}
.login-card h2 {
  font-size: 24px;
  margin-bottom: 6px;
}
.login-card .muted { margin-bottom: 24px; }

.form-stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
  width: 100%;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}

/* ===================== ADMIN — PANEL ===================== */
.admin-panel { animation: fadeIn 0.25s ease; }
.admin-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}
.admin-head h2 { font-size: 24px; margin-bottom: 4px; }

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--t);
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-color: var(--primary);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.2s ease; }

.add-form {
  display: grid;
  gap: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.add-form-ch { grid-template-columns: 2fr 3fr 1.2fr auto auto; }
.add-form-wp { grid-template-columns: 2fr 2fr auto auto; }
@media (max-width: 800px) {
  .add-form-ch, .add-form-wp { grid-template-columns: 1fr; }
}

.list-card { padding: 0; overflow: hidden; }
.list-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
}
.list-head .muted { margin-left: auto; }

.list { display: flex; flex-direction: column; }
.list-item {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-2); }
.list-item.disabled { opacity: 0.5; }
.list-item.selected { background: var(--primary-soft); }
.list-item.selected:hover { background: var(--primary-soft); }
.list-item.removing {
  animation: itemRemove 0.18s ease forwards;
  pointer-events: none;
}
@keyframes itemRemove {
  to { opacity: 0; transform: translateX(-8px); height: 0; padding: 0; border: 0; }
}

.item-id {
  font-size: 12px;
  color: var(--text-faint);
  min-width: 36px;
  font-variant-numeric: tabular-nums;
}
.item-main strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.item-main small {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
}
.item-meta {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.item-meta.facile { background: var(--secondary-soft); color: var(--secondary); border-color: transparent; }
.item-meta.normal { background: var(--surface-2); color: var(--text-muted); }
.item-meta.difficile { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.item-meta.extreme { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

.item-actions { display: flex; gap: 4px; }
.item-actions .icon-btn {
  width: 32px; height: 32px;
  font-size: 14px;
}
.item-actions .icon-btn.toggle.on { color: var(--secondary); border-color: var(--secondary); background: var(--secondary-soft); }
.item-actions .icon-btn.delete:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ===================== CHECKBOX ===================== */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text);
}
.checkbox input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox-box {
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  display: inline-flex;
  align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--t);
}
.checkbox-box::after {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--primary-fg);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
  transform: scale(0);
  transition: transform 0.1s ease;
}
.checkbox input:checked + .checkbox-box {
  background: var(--primary);
  border-color: var(--primary);
}
.checkbox input:checked + .checkbox-box::after { transform: scale(1); }
.checkbox input:focus + .checkbox-box {
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ===================== BULK BAR ===================== */
.bulk-bar {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  animation: bulkSlide 0.2s ease;
  max-width: calc(100vw - 32px);
}
@keyframes bulkSlide {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
.bulk-bar-inner {
  padding: 8px 8px 8px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.bulk-bar-count {
  font-size: 14px;
  color: var(--text);
}
.bulk-bar-count strong {
  font-size: 16px;
  color: var(--primary);
  margin-right: 2px;
}

@media (max-width: 600px) {
  .bulk-bar-inner { flex-wrap: wrap; padding: 12px; }
  .bulk-bar-inner .btn { flex: 1; }
}

/* ===================== MODAL ===================== */
.modal {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease;
}
[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.7);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.97) translateY(-6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 18px; font-weight: 600; }
.modal-close {
  margin-left: auto;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--text-muted);
  transition: all var(--t);
}
.modal-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-help {
  font-size: 14px;
  color: var(--text-muted);
}
.modal-format {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
}
.modal-format summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-muted);
  list-style: none;
  user-select: none;
}
.modal-format summary::-webkit-details-marker { display: none; }
.modal-format summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform var(--t);
  color: var(--text-faint);
}
.modal-format[open] summary::before { transform: rotate(90deg); }
.modal-format > div {
  padding: 0 14px 14px;
  color: var(--text-muted);
  white-space: pre-wrap;
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
}

#import-textarea {
  resize: vertical;
  min-height: 200px;
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}
.modal-feedback {
  font-size: 13px;
  color: var(--text-muted);
  min-height: 18px;
}
.modal-feedback.ready { color: var(--secondary); }
.modal-feedback.warn { color: var(--warn); }
.modal-feedback.error { color: var(--danger); }

.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}

body.modal-open { overflow: hidden; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 18px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: toastIn 0.2s ease;
  max-width: calc(100vw - 32px);
}
.toast[hidden] { display: none; }
.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}
.toast.success {
  border-color: var(--secondary);
}
.toast.success::before {
  content: '✓';
  color: var(--secondary);
  font-weight: 700;
}
.toast.error::before {
  content: '✕';
  font-weight: 700;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.toast-action {
  background: var(--primary);
  color: var(--primary-fg);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: none;
  transition: background var(--t);
}
.toast-action:hover { background: var(--primary-hover); }

/* ===================== FOOTER ===================== */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  font-size: 13px;
  color: var(--text-muted);
}
.footer .sep { color: var(--text-faint); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 640px) {
  .topbar-inner { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .brand-name { display: none; }
  .nav { order: 3; flex: 1; justify-content: center; }
  .topbar-actions { order: 2; }
  main { padding: 28px 16px 100px; }
  .admin-head { flex-direction: column; align-items: flex-start; }
  .list-item {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
  .list-item .item-id { display: none; }
  .list-item .item-main { flex: 1 1 100%; order: 2; }
  .list-item .checkbox { order: 1; }
  .list-item .item-meta { order: 3; }
  .list-item .item-actions { order: 4; margin-left: auto; }
  .modal { padding: 12px; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}
