/* ==========================================================================
   Component Library Styles
   SellerCore B2B Marketplace Suite
   ========================================================================== */

/* Universal Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

a {
  color: var(--primary-600);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--primary-700);
}

button, input, select, textarea {
  font: inherit;
}

/* Accessible Focus Outlines */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  line-height: 1.25;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* Button Variants */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-700), var(--primary-800));
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
  color: #ffffff;
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-medium);
}
.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-surface-alt);
  border-color: var(--border-dark);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}
.btn-success:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
  color: #ffffff;
}

.btn-danger {
  background-color: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}
.btn-danger:hover:not(:disabled) {
  background-color: var(--error-solid);
  color: #ffffff;
  border-color: var(--error-solid);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(225, 29, 72, 0.25);
}
.btn-accent:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-700), #9f1239);
  color: #ffffff;
}

/* Button Sizes */
.btn-sm {
  padding: 5px 10px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  gap: 6px;
}
.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
  border-radius: var(--radius-md);
  gap: 10px;
}

.btn-icon-only {
  padding: 8px;
  border-radius: var(--radius-md);
  width: 36px;
  height: 36px;
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
}

.card:hover {
  border-color: var(--border-medium);
}

.card-interactive {
  cursor: pointer;
  transition: all var(--transition-fast);
}
.card-interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-focus);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   Dropzone (Modern Drag-and-Drop File Upload)
   ========================================================================== */
.dropzone {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  text-align: center;
  background-color: var(--bg-surface-alt);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary-500);
  background-color: var(--primary-50);
  transform: scale([1.002]);
}

[data-theme="dark"] .dropzone:hover, 
[data-theme="dark"] .dropzone.dragover {
  background-color: rgba(56, 189, 248, 0.05);
}

.dropzone-icon-wrap {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  color: var(--primary-600);
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition-fast);
}

.dropzone:hover .dropzone-icon-wrap {
  transform: translateY(-2px);
  color: var(--primary-500);
}

.dropzone h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.dropzone p {
  color: var(--text-muted);
  font-size: 0.875rem;
  max-width: 440px;
  margin-bottom: 12px;
}

.dropzone .dropzone-hints {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dropzone input[type="file"] {
  display: none;
}

/* ==========================================================================
   Badges & Status Tags
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-primary {
  background-color: var(--primary-50);
  color: var(--primary-700);
  border-color: var(--primary-200);
}
[data-theme="dark"] .badge-primary {
  background-color: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.badge-success {
  background-color: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.badge-warning {
  background-color: var(--warning-bg);
  color: var(--warning-text);
  border-color: var(--warning-border);
}

.badge-danger {
  background-color: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}

.badge-neutral {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  border-color: var(--border-medium);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot-active {
  background-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================================================
   Form Controls
   ========================================================================== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-field, .select-field, .textarea-field {
  width: 100%;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.input-field:focus, .select-field:focus, .textarea-field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  outline: none;
}

.textarea-field {
  resize: vertical;
  min-height: 140px;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  cursor: pointer;
  accent-color: var(--primary-600);
}

/* Segmented Control / Pill Chips */
.segmented-control {
  display: flex;
  background-color: var(--bg-surface-alt);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  gap: 4px;
}

.segment-btn {
  flex: 1;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

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

.segment-btn.active {
  background-color: var(--bg-surface);
  color: var(--primary-700);
  box-shadow: var(--shadow-xs);
}
[data-theme="dark"] .segment-btn.active {
  color: #38bdf8;
  background-color: var(--bg-surface-elevated);
}

/* ==========================================================================
   Data Tables
   ========================================================================== */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-xs);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.data-table th {
  background-color: var(--bg-surface-alt);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background-color: var(--bg-surface-alt);
}

.thumb-cell {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-medium);
  background-color: #000000;
  display: block;
}

/* ==========================================================================
   Action Bars & Toolbars
   ========================================================================== */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-top: 16px;
}

.action-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.action-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Progress Bar
   ========================================================================== */
.progress-container {
  width: 100%;
  margin-top: 14px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.progress-track {
  width: 100%;
  height: 8px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-600), #38bdf8);
  width: 0%;
  border-radius: var(--radius-pill);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   KPI Summary Metric Cards
   ========================================================================== */
.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-card.highlight .kpi-value {
  color: var(--primary-600);
}
[data-theme="dark"] .kpi-card.highlight .kpi-value {
  color: #38bdf8;
}

.kpi-card.warning .kpi-value {
  color: var(--warning-solid);
}

.kpi-card.success .kpi-value {
  color: var(--success-solid);
}

/* ==========================================================================
   Interactive Image Comparison Modal
   ========================================================================== */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.active {
  display: flex;
  opacity: 1;
}

.modal-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 920px;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(0.98);
  transition: transform var(--transition-normal);
}

.modal-backdrop.active .modal-card {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 18px 24px;
  background-color: var(--bg-surface-alt);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 16px 24px;
  background-color: var(--bg-surface-alt);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.compare-container {
  position: relative;
  width: 100%;
  height: 480px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background-color: #000000;
  border: 1px solid var(--border-light);
  user-select: none;
}

.compare-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.compare-overlay {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 50%;
  overflow: hidden;
  border-right: 2px solid #ffffff;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.4);
}

.slider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--primary-600);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.slider-handle::before {
  content: '↔';
  color: var(--primary-700);
  font-size: 16px;
  font-weight: 800;
}

.compare-tag {
  position: absolute;
  bottom: 14px;
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: var(--radius-pill);
  z-index: 5;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.compare-tag-left { left: 14px; }
.compare-tag-right { right: 14px; }

/* ==========================================================================
   Toast Notification System
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(16px);
  transition: all var(--transition-normal);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.toast-success { border-left: 4px solid var(--success-solid); }
.toast-error { border-left: 4px solid var(--error-solid); }
.toast-info { border-left: 4px solid var(--primary-600); }
.toast-warning { border-left: 4px solid var(--warning-solid); }

/* ==========================================================================
   Command Palette (Ctrl+K / Cmd+K Quick Launcher)
   ========================================================================== */
.cmd-palette-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 2000;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;
}

.cmd-palette-backdrop.active {
  display: flex;
}

.cmd-palette {
  width: 100%;
  max-width: 580px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.cmd-input-wrap {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  gap: 10px;
}

.cmd-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1rem;
}

.cmd-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
  list-style: none;
}

.cmd-item {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: background-color var(--transition-fast);
}

.cmd-item:hover, .cmd-item.selected {
  background-color: var(--bg-surface-alt);
  color: var(--primary-600);
}

.cmd-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cmd-shortcut {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-subtle);
  color: var(--text-muted);
}
