/* ==========================================================================
   TRENCH BOT - STYLES/COMPONENTS.CSS
   Component Specific Styles: Buttons, Inputs, Switches, Segmented Controls,
   Badges, Modals & Shared UI Elements (Axiom / Linear Grade)
   ========================================================================== */

/* Layout Tab Content (Hide/Show) */
.tab-pane {
  display: none;
  animation: fadeIn 140ms ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   BUTTONS (Single Accent Indigo #5b6cff, Outline, Destructive)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-primary-border);
}

.btn-primary, .btn-brass {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

.btn-primary:hover, .btn-brass:hover {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-line);
}

.btn-outline:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-strong);
}

.btn-destructive {
  background: transparent;
  color: var(--semantic-down);
  border-color: rgba(255, 77, 109, 0.25);
}

.btn-destructive:hover {
  background: rgba(255, 77, 109, 0.1);
  border-color: var(--semantic-down);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.76rem;
  height: 28px;
}

.btn-xs {
  padding: 3px 7px;
  font-size: 0.70rem;
  height: 22px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed !important;
  pointer-events: none;
}

/* ==========================================================================
   FORM INPUTS & SUFFIX WRAPPERS
   ========================================================================== */
input:not([type="checkbox"]):not([type="radio"]),
input[type="text"],
input[type="number"],
input[type="search"],
input[type="password"],
textarea,
select,
.form-input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  background-color: var(--bg-surface) !important;
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-line) !important;
  border-radius: var(--radius-sm);
  color: var(--text-primary) !important;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
  outline: none;
  box-sizing: border-box;
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

/* Standard Checkbox Control */
input[type="checkbox"]:not(.switch-label input) {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent-primary, #5b6cff);
  -webkit-appearance: auto;
  appearance: auto;
  border-radius: 3px;
  vertical-align: middle;
}

.auto-scroll-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.auto-scroll-label:hover {
  color: var(--text-primary);
}

/* Chrome autofill dark background reset */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px #101012 inset !important;
  -webkit-text-fill-color: #f2f2f3 !important;
  caret-color: #f2f2f3 !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* Remove number input spinners in Axiom terminal */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

input:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus,
.form-input:focus {
  border-color: var(--accent-primary) !important;
  box-shadow: 0 0 0 1px var(--accent-primary) !important;
  background-color: var(--bg-surface-elevated) !important;
  background: var(--bg-surface-elevated) !important;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-dim) !important;
  opacity: 1;
}

textarea {
  height: auto;
  padding: 10px;
}

.input-with-suffix {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-with-suffix input {
  width: 100%;
  height: 34px;
  padding: 0 38px 0 10px !important;
  background-color: var(--bg-surface) !important;
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-line) !important;
  border-radius: var(--radius-sm);
  color: var(--text-primary) !important;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
  outline: none;
  box-sizing: border-box;
  color-scheme: dark;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-with-suffix input:focus {
  border-color: var(--accent-primary) !important;
  box-shadow: 0 0 0 1px var(--accent-primary) !important;
  background-color: var(--bg-surface-elevated) !important;
  background: var(--bg-surface-elevated) !important;
}

.input-suffix {
  position: absolute;
  right: 10px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  pointer-events: none;
  user-select: none;
}

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.field-helper {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
  line-height: 1.35;
}

.inline-warn {
  display: none;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--semantic-down);
  margin-top: 4px;
}

.inline-warn.visible {
  display: block;
}

/* ==========================================================================
   SWITCHES (Linear / iOS Style Toggles)
   ========================================================================== */
.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.switch-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  min-width: 0;
  min-height: 0;
  pointer-events: none;
}

.switch-slider {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  background: #232328;
  border-radius: 10px;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.switch-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.switch-label input[type="checkbox"]:checked + .switch-slider {
  background: var(--accent-primary);
}

.switch-label input[type="checkbox"]:checked + .switch-slider::after {
  transform: translateX(14px);
  background: #ffffff;
}

.switch-text {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--text-primary);
}

/* ==========================================================================
   SEGMENTED CONTROL (Presets, Timeframes, Filters)
   ========================================================================== */
.segmented-control {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.segmented-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.76rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
  line-height: 1.2;
}

.segmented-item:hover {
  color: var(--text-primary);
}

.segmented-item.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   STATUS BADGES & INDICATORS
   ========================================================================== */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.active, .status-dot.pass {
  background: var(--semantic-up);
}

.status-dot.warn {
  background: #e1aa32;
}

.status-dot.fail {
  background: var(--semantic-down);
}

.status-dot.muted {
  background: var(--text-dim);
}

.badge-subtle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.70rem;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-line);
}

.badge-subtle.pass {
  color: var(--semantic-up);
  border-color: rgba(47, 212, 138, 0.25);
  background: rgba(47, 212, 138, 0.08);
}

.badge-subtle.fail {
  color: var(--semantic-down);
  border-color: rgba(255, 77, 109, 0.25);
  background: rgba(255, 77, 109, 0.08);
}

/* ==========================================================================
   MODAL DIALOG (Wallet Import & Custom Actions)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 10, 11, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 120ms ease;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  max-width: 520px;
  width: 90%;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.7);
}

@media (max-width: 600px) {
  .modal-dialog {
    width: calc(100% - 20px);
    padding: 14px 16px;
    margin: 10px;
    border-radius: var(--radius-md);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--border-line);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}

.btn-icon:hover {
  color: var(--text-primary);
}

/* Micro Action Buttons (e.g. Table Row Edit Rules) */
.btn-edit-rules {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 20px !important;
  padding: 0 6px !important;
  background-color: var(--bg-surface-elevated) !important;
  background: var(--bg-surface-elevated) !important;
  border: 1px solid var(--border-line) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text-secondary) !important;
  font-family: var(--font-sans) !important;
  font-size: 0.70rem !important;
  font-weight: 500 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  outline: none !important;
  white-space: nowrap !important;
  transition: all var(--transition-fast) !important;
}

.btn-edit-rules:hover {
  background-color: var(--bg-surface-active) !important;
  background: var(--bg-surface-active) !important;
  border-color: var(--accent-primary) !important;
  color: var(--text-primary) !important;
}
