/* ============================================
   ORQUESTRADOR DASHBOARD — APPLE LIGHT
   ============================================ */

:root {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --bg-hover: #f0f0f2;
  --bg-input: #f0f0f2;
  --border: #d2d2d7;
  --border-light: #e5e5ea;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;

  --green: #34c759;
  --green-bg: #eafbf0;
  --blue: #007aff;
  --blue-bg: #e8f2ff;
  --orange: #ff9500;
  --orange-bg: #fff5e6;
  --red: #ff3b30;
  --red-bg: #ffeceb;
  --purple: #af52de;
  --purple-bg: #f5ecfb;
  --gray: #8e8e93;
  --gray-bg: #f2f2f7;
  --teal: #5ac8fa;
  --teal-bg: #eaf8ff;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.04);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.noise-overlay { display: none; }

/* ---- HEADER ---- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 52px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 0.5px solid var(--border-light);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: linear-gradient(180deg, #007aff, #005ec4);
  color: white;
}

.logo svg { width: 18px; height: 18px; }

.header-title h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.1px;
}

.header-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--bg-input);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.connection-status.connected { background: var(--green-bg); }
.connection-status.connected .status-dot { background: var(--green); }
.connection-status.connected .status-text { color: #248a3d; }

.connection-status.disconnected { background: var(--red-bg); }
.connection-status.disconnected .status-dot { background: var(--red); }
.connection-status.disconnected .status-text { color: var(--red); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.dry-run-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--orange-bg);
  color: #c25700;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ---- MAIN ---- */
.main {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 28px 60px;
}

/* ---- STATS GRID ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 0.5px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.stat-synced .stat-icon { background: var(--green-bg); color: var(--green); }
.stat-with-label .stat-icon { background: var(--blue-bg); color: var(--blue); }
.stat-waiting .stat-icon { background: var(--orange-bg); color: var(--orange); }
.stat-processing .stat-icon { background: var(--teal-bg); color: var(--teal); }
.stat-error .stat-icon { background: var(--red-bg); color: var(--red); }
.stat-total .stat-icon { background: var(--gray-bg); color: var(--gray); }
.stat-canceled .stat-icon { background: var(--purple-bg); color: var(--purple); }

.stat-content { display: flex; flex-direction: column; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
}

.stat-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.2;
}

/* ---- ORDERS SECTION ---- */
.orders-section {
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 0.5px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.orders-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 0.5px solid var(--border-light);
}

.orders-header h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.orders-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-tertiary);
}

.search-box:focus-within { outline: 2px solid var(--blue); outline-offset: -1px; }

.search-box input {
  border: none;
  background: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  width: 180px;
}

.search-box input::placeholder { color: var(--text-tertiary); }

.filter-pills {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 2px;
}

.pill {
  padding: 5px 12px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover { color: var(--text); }
.pill.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 0.5px 1px rgba(0,0,0,0.06);
}

/* ---- TABLE ---- */
.table-container { overflow-x: auto; }

.orders-table {
  width: 100%;
  border-collapse: collapse;
}

.orders-table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 0.5px solid var(--border-light);
  background: var(--bg);
}

.orders-table tbody tr {
  border-bottom: 0.5px solid var(--border-light);
  transition: background 0.1s ease;
  cursor: pointer;
}

.orders-table tbody tr:last-child { border-bottom: none; }
.orders-table tbody tr:hover { background: var(--bg); }

.orders-table td {
  padding: 12px 16px;
  font-size: 13px;
  vertical-align: middle;
}

.order-id-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.order-number {
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.order-channel {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.status-badge.completed { background: var(--green-bg); color: #248a3d; }
.status-badge.canceled { background: var(--purple-bg); color: #8944ab; }
.status-badge.waiting_label { background: var(--orange-bg); color: #c25700; }
.status-badge.error { background: var(--red-bg); color: #d70015; }
.status-badge.retrying { background: var(--teal-bg); color: #0071a4; }
.status-badge.sending,
.status-badge.transforming,
.status-badge.fetching_order,
.status-badge.fetching_label {
  background: var(--blue-bg);
  color: #0055b3;
}
.status-badge.pending { background: var(--gray-bg); color: var(--text-secondary); }

.label-indicator {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 500;
}

.label-indicator.has-label { color: #248a3d; }
.label-indicator.no-label { color: var(--text-tertiary); }

.products-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sku-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--blue-bg);
  color: #0055b3;
  font-size: 11px;
  font-weight: 500;
  font-family: 'SF Mono', Menlo, monospace;
}

.time-ago {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 0.5px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.action-btn.retry-btn:hover {
  background: var(--blue-bg);
  color: var(--blue);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 20px;
  color: var(--text-tertiary);
}

.empty-state svg { color: var(--text-tertiary); opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* ---- PAGINATION ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 12px 16px;
  border-top: 0.5px solid var(--border-light);
}

.page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.1s ease;
}

.page-btn:hover:not(:disabled) { background: var(--bg-input); }

.page-btn.active {
  background: var(--blue);
  color: white;
  font-weight: 600;
}

.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
  width: 90vw;
  max-width: 640px;
  max-height: 85vh;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.2s ease;
}

@keyframes modal-in {
  from { transform: scale(0.97); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 0.5px solid var(--border-light);
}

.modal-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.detail-section { margin-bottom: 20px; }

.detail-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 0.5px solid var(--border-light);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.detail-item.full-width { grid-column: 1 / -1; }

.detail-key {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.detail-value {
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
}

.detail-value a {
  color: var(--blue);
  text-decoration: none;
}

.detail-value a:hover { text-decoration: underline; }

.json-block {
  background: var(--bg);
  border: 0.5px solid var(--border-light);
  border-radius: 8px;
  padding: 10px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11px;
  color: var(--text-secondary);
  overflow-x: auto;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.modal-actions {
  display: flex;
  gap: 8px;
  padding-top: 16px;
  border-top: 0.5px solid var(--border-light);
  margin-top: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}

.btn-primary {
  background: var(--blue);
  color: white;
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-outline {
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover { background: var(--bg); }

/* ---- TOAST ---- */
.toast-container {
  position: fixed;
  top: 64px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow-md);
  animation: toast-in 0.25s ease;
  max-width: 340px;
}

.toast.success .toast-icon { color: var(--green); }
.toast.error .toast-icon { color: var(--red); }
.toast.info .toast-icon { color: var(--blue); }

.toast-icon { flex-shrink: 0; }

@keyframes toast-in {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toast-out {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-8px); opacity: 0; }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 700px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .orders-controls { flex-direction: column; align-items: stretch; }
  .search-box input { width: 100%; }
  .filter-pills { overflow-x: auto; flex-wrap: nowrap; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .header { padding: 0 16px; }
  .main { padding: 16px; }
  .detail-grid { grid-template-columns: 1fr; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ============================================
   AURA THEME - GLOBAL OVERRIDES
   ============================================ */

:root {
  --aura-text: #0f172a;
  --aura-text-soft: #475569;
  --aura-glass: rgba(255, 255, 255, 0.6);
  --aura-border: rgba(148, 163, 184, 0.28);
  --aura-shadow: 0 8px 30px rgba(15, 23, 42, 0.12);
  --aura-accent: #6366f1;
}

body {
  font-family: Inter, "Geist Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(110% 110% at 0% 0%, rgba(99, 102, 241, 0.12), transparent 56%),
    radial-gradient(120% 120% at 100% 100%, rgba(132, 204, 22, 0.1), transparent 58%),
    #f8fafc;
}

.noise-overlay {
  display: block;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.22;
  background-image: radial-gradient(rgba(15, 23, 42, 0.09) 0.7px, transparent 0.7px);
  background-size: 8px 8px;
}

.header,
.orders-section,
.stat-card,
.modal,
.toast,
.search-box,
.filter-pills,
.action-btn,
.page-btn,
.json-block {
  background-color: var(--aura-glass) !important;
  border-color: var(--aura-border) !important;
  backdrop-filter: blur(20px) saturate(1.14);
  -webkit-backdrop-filter: blur(20px) saturate(1.14);
  box-shadow: var(--aura-shadow) !important;
}

.header {
  height: 62px;
  border-bottom-width: 1px;
}

.header-title h1 {
  background: linear-gradient(180deg, #0f172a, #64748b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 16px;
}

.main {
  position: relative;
  z-index: 1;
}

.stats-grid {
  gap: 16px;
}

.stat-card {
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 220ms ease;
}

.stat-card:hover {
  transform: translateY(-3px) scale(1.01);
}

.orders-section {
  border-radius: 18px;
}

.orders-header h2 {
  font-size: 17px;
  color: var(--aura-text);
}

.pill.active {
  background: rgba(255, 255, 255, 0.88);
}

.action-btn,
.btn,
.pill,
.page-btn {
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1), background-color 180ms ease, box-shadow 180ms ease;
}

.action-btn:hover,
.btn:hover,
.pill:hover,
.page-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.92), rgba(79, 70, 229, 0.88));
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.25);
}

.orders-table thead th {
  background: rgba(255, 255, 255, 0.48);
}

.orders-table tbody tr {
  transition: background 140ms ease, transform 140ms ease;
}

.orders-table tbody tr:hover {
  transform: translateY(-1px);
  background: rgba(241, 245, 249, 0.7);
}

.modal-overlay {
  background: rgba(15, 23, 42, 0.28);
}

.toast {
  border-radius: 12px;
}

.main > * {
  animation: aura-fade-up 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.main > *:nth-child(2) { animation-delay: 70ms; }
.main > *:nth-child(3) { animation-delay: 120ms; }
.main > *:nth-child(4) { animation-delay: 170ms; }

@keyframes aura-fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #e5e7eb;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border: rgba(148, 163, 184, 0.35);
    --border-light: rgba(148, 163, 184, 0.24);
    --bg: #020617;
    --bg-card: rgba(15, 23, 42, 0.64);
    --bg-input: rgba(15, 23, 42, 0.62);
    --aura-text: #e2e8f0;
    --aura-text-soft: #94a3b8;
    --aura-glass: rgba(15, 23, 42, 0.58);
    --aura-border: rgba(255, 255, 255, 0.16);
    --aura-shadow: 0 8px 30px rgba(0, 0, 0, 0.34);
  }

  body {
    color: var(--aura-text);
    background:
      radial-gradient(120% 120% at 0% 0%, rgba(99, 102, 241, 0.2), transparent 56%),
      radial-gradient(120% 120% at 100% 100%, rgba(132, 204, 22, 0.12), transparent 60%),
      #020617;
  }

  .noise-overlay {
    opacity: 0.3;
    background-image: radial-gradient(rgba(148, 163, 184, 0.16) 0.7px, transparent 0.7px);
  }

  .header-title h1 {
    background: linear-gradient(180deg, #f8fafc, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .orders-table thead th,
  .pill.active,
  .search-box,
  .filter-pills,
  .json-block {
    background: rgba(15, 23, 42, 0.5) !important;
    color: #cbd5e1;
  }

  .stat-value,
  .stat-label,
  .orders-header h2,
  .order-number,
  .detail-value,
  .modal-header h3,
  .toast,
  .page-btn,
  .pill,
  .search-box input {
    color: #e2e8f0 !important;
  }

  .stat-desc,
  .order-channel,
  .time-ago,
  .detail-key,
  .header-subtitle,
  .search-box input::placeholder {
    color: #94a3b8 !important;
  }

  .orders-table td,
  .orders-table thead th {
    border-color: rgba(148, 163, 184, 0.24);
  }

  .status-badge.waiting_label {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.22);
  }

  .status-badge.error {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.22);
  }

  .status-badge.completed {
    color: #86efac;
    background: rgba(34, 197, 94, 0.2);
  }

  .sku-tag {
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.22);
  }

  .orders-table tbody tr:hover {
    background: rgba(30, 41, 59, 0.45);
  }

  .btn-outline {
    color: #cbd5e1;
  }
}
