/* ═══════════════════════════════════════════════════════════════════════════
   TetroWars – Dialog Builder Styles
   ═══════════════════════════════════════════════════════════════════════════ */

.db-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.db-backdrop.db-visible { opacity: 1; }

/* Outer wrap = clip-path border */
.db-dialog-wrap {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 2001;
  background: rgba(255, 255, 255, 0.12);
  clip-path: polygon(16px 0, calc(100% - 16px) 0, 100% 16px, 100% calc(100% - 16px), calc(100% - 16px) 100%, 16px 100%, 0 calc(100% - 16px), 0 16px);
  padding: 1px;
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.db-dialog-wrap.db-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Inner dialog = content */
.db-dialog {
  background: var(--card-bg);
  clip-path: polygon(16px 0, calc(100% - 16px) 0, 100% 16px, 100% calc(100% - 16px), calc(100% - 16px) 100%, 16px 100%, 0 calc(100% - 16px), 0 16px);
  padding: 32px;
  max-height: 85vh;
  overflow-y: auto;
}

/* ─── Title / Subtitle ─────────────────────────────────────────────────── */

.db-title {
  font-family: var(--font-primary);
  font-size: var(--font-xl);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.db-subtitle {
  font-size: var(--font-sm);
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ─── Error ────────────────────────────────────────────────────────────── */

.db-error {
  background: rgba(255, 51, 102, 0.1);
  color: var(--accent-secondary);
  font-size: var(--font-sm);
  padding: 8px 12px;
  margin-bottom: 12px;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
}

/* ─── Tabs ─────────────────────────────────────────────────────────────── */

.db-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 8px;
}

/* Active tab overrides btn-secondary */
.db-tab--active {
  color: var(--accent-primary) !important;
  border-color: var(--accent-primary) !important;
}

.db-tab-pane { display: none; }
.db-tab-pane--active { display: block; }

/* ─── Fields ───────────────────────────────────────────────────────────── */

.db-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.db-field label {
  display: block;
  font-family: var(--font-primary);
  font-size: var(--font-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.db-field input[type="text"],
.db-field input[type="email"],
.db-field input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-primary);
  font-size: var(--font-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  outline: none;
  transition: border-color 0.2s;
}

.db-field input:focus {
  border-color: var(--accent-primary);
}

.db-field select {
  border: 1.5px solid rgba(255, 255, 255, 0.2);
}

.db-field select {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-primary);
  font-size: var(--font-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  outline: none;
  cursor: pointer;
  appearance: none;
}

.db-field select option {
  background: var(--bg-primary);
}

/* ─── Toggle ───────────────────────────────────────────────────────────── */

.db-field--toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.db-field--toggle:last-child { border-bottom: none; }

.db-field--toggle label { margin-bottom: 0; }

/* Toggle buttons use global .btn .btn-primary / .btn-secondary — fixed width */
.db-toggle-btn {
  min-width: 70px;
  text-align: center;
  justify-content: center;
}

/* ─── Slider ───────────────────────────────────────────────────────────── */

.db-field--slider {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: center;
}

.db-field--slider label { margin-bottom: 0; }

.db-slider-val {
  font-family: var(--font-primary);
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--accent-primary);
  min-width: 45px;
  text-align: right;
}

.db-field input[type="range"] {
  width: 100%;
  height: 4px;
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  cursor: pointer;
}

.db-field input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
}

/* ─── Keybind ──────────────────────────────────────────────────────────── */

.db-keybind {
  font-family: var(--font-primary);
  font-size: var(--font-sm);
  font-weight: 600;
  padding: 6px 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  min-width: 100px;
  text-align: center;
}

.db-keybind--listening {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  animation: keybind-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes keybind-pulse {
  from { border-color: var(--accent-primary); }
  to { border-color: transparent; }
}

/* ─── Divider / Heading ────────────────────────────────────────────────── */

/* ─── Columns ──────────────────────────────────────────────────────────── */

.db-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.db-column .db-field-heading {
  margin-bottom: 12px;
}

@media (max-width: 500px) {
  .db-columns { grid-template-columns: 1fr; }
}

/* ─── Control Row (Label | KB | Gamepad) ───────────────────────────────── */

.db-control-header,
.db-control-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.db-control-header {
  font-family: var(--font-primary);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 4px;
}

.db-control-header span:first-child { color: var(--text-muted); }

.db-control-row {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.db-control-row:last-of-type { border-bottom: none; }

.db-control-row label {
  font-family: var(--font-primary);
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0;
}

.db-control-row .db-keybind {
  font-size: var(--font-xs);
  padding: 6px 8px;
  width: 100%;
}

.db-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin: 4px 0;
}

.db-field-heading {
  font-family: var(--font-primary);
  font-size: var(--font-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-primary);
  margin: 4px 0 0;
}

/* ─── Buttons ──────────────────────────────────────────────────────────── */

.db-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ─── Centered variant (for alerts/confirmations) ─────────────────────── */

.dialog-centered {
  text-align: center;
}

.dialog-centered .db-title {
  text-align: center;
}

.dialog-centered .db-buttons {
  justify-content: center;
}

/* ─── Scrollbar ────────────────────────────────────────────────────────── */

.db-dialog::-webkit-scrollbar { width: 4px; }
.db-dialog::-webkit-scrollbar-track { background: transparent; }
.db-dialog::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 2px; }
