/* Shared UI Components */

/* Buttons & Inputs */
.btn {
  height: 42px;
  padding: 0 18px;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  color: var(--text-main);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}

.btn-primary {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  border-color: #059669;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 10px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #059669 0%, #047857 100%);
  border-color: #047857;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: transparent;
  color: var(--text-main);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  gap: 6px;
}

.btn-lg {
  height: 48px;
  padding: 0 24px;
  font-size: 15px;
  border-radius: var(--radius-lg);
  font-weight: 600;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13.5px;
  padding: 10px 14px;
  outline: none;
  transition: all var(--transition-fast);
}

input:hover, select:hover, textarea:hover {
  border-color: var(--border-hover);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Range Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-hover);
  border-radius: 999px;
  outline: none;
  transition: all var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* Cards & Layout Grids */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--card-shadow);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
  border-color: var(--border-hover);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.flex-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-wrap {
  flex-wrap: wrap;
}

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* Drag & Drop File Zone */
.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl);
  padding: 56px 28px;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-card) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 4px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--bg-hover) 0%, var(--bg-card-hover) 100%);
  box-shadow: 0 0 30px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.dropzone-icon {
  width: 56px;
  height: 56px;
  color: var(--accent);
  transition: transform var(--transition-fast);
  filter: drop-shadow(0 4px 12px var(--accent-glow));
}

.dropzone:hover .dropzone-icon {
  transform: translateY(-4px) scale(1.05);
}

.dropzone-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.dropzone-sub {
  font-size: 13.5px;
  color: var(--text-muted);
}

:root.theme-light .dropzone {
  border-color: #cbd5e1;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

:root.theme-light .dropzone:hover,
:root.theme-light .dropzone.dragover {
  border-color: var(--accent);
  background: #f0fdf4;
}

/* Segmented Sub-tabs */
.subtabs {
  display: inline-flex;
  gap: 4px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}

.subtab-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.subtab-btn:hover {
  color: var(--text-main);
}

.subtab-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Stat Cards */
.stat-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-pill .stat-label {
  font-size: 11.5px;
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stat-pill .stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

/* Modern Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
  letter-spacing: 0.2px;
}

.badge-accent {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: rgba(16, 185, 129, 0.3);
}

/* Floating Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--accent);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transform: translateY(80px);
  opacity: 0;
  transition: all var(--transition-normal);
  z-index: 1000;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--modal-shadow);
  transform: scale(0.96);
  transition: transform var(--transition-fast);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* Header Cmd+K Shortcut Pill */
.cmd-k-pill {
  height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.cmd-k-pill:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  color: var(--text-main);
}

.cmd-k-icon {
  display: flex;
  align-items: center;
  color: var(--text-dim);
}

.cmd-kbd {
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  line-height: 1.4;
}

/* Universal Command Palette (Cmd+K) Modal */
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  padding-left: 16px;
  padding-right: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.cmd-palette-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.cmd-palette-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 620px;
  box-shadow: 0 24px 64px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(-8px) scale(0.98);
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.cmd-palette-backdrop.open .cmd-palette-modal {
  transform: translateY(0) scale(1);
}

.cmd-palette-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.cmd-palette-search-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.cmd-palette-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-main);
  font-family: inherit;
}

.cmd-palette-input::placeholder {
  color: var(--text-dim);
  font-size: 14px;
}

.cmd-palette-esc-badge {
  font-size: 10.5px;
  font-family: var(--font-mono, monospace);
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.cmd-palette-body {
  max-height: 380px;
  overflow-y: auto;
  padding: 8px;
}

.cmd-palette-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.12s ease;
  user-select: none;
}

.cmd-palette-item:hover,
.cmd-palette-item.selected {
  background: var(--bg-hover);
}

.cmd-palette-item.selected {
  outline: 1px solid var(--border-hover);
}

.cmd-palette-item-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--bg-surface);
}

.cmd-palette-item-icon svg {
  width: 22px;
  height: 22px;
}

.cmd-palette-item-text {
  flex: 1;
  min-width: 0;
}

.cmd-palette-item-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.cmd-palette-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-palette-item-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.cmd-palette-item-desc {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-palette-item-enter {
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.12s ease;
  flex-shrink: 0;
}

.cmd-palette-item.selected .cmd-palette-item-enter,
.cmd-palette-item:hover .cmd-palette-item-enter {
  opacity: 1;
  color: var(--accent);
}

.cmd-palette-empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--text-dim);
}

.cmd-palette-empty svg {
  margin-bottom: 10px;
  opacity: 0.6;
}

.cmd-palette-empty p {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.cmd-palette-empty span {
  font-size: 12px;
  color: var(--text-dim);
}

.cmd-palette-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 11.5px;
  color: var(--text-dim);
}

.cmd-palette-tip {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cmd-palette-tip kbd {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.cmd-palette-brand {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
