/* ═══════════════════════════════════════════════════════════════════════════
   ORDERS DASHBOARD — Reworked
   ═══════════════════════════════════════════════════════════════════════════ */

.orders-dashboard {
  max-width: var(--grid-max-width, 1400px);
  padding: var(--space-lg, 16px) var(--space-xl, 20px) var(--space-xl, 20px);
  margin: 0 auto;
}

/* ── Stats Strip ── */
.orders-stats-strip {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--bg-elevated, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg, 10px);
  padding: 0;
  margin-bottom: 16px;
  overflow: hidden;
}

.orders-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 12px;
  gap: 2px;
  transition: background 0.15s, box-shadow 0.15s;
  position: relative;
}

.orders-stat--clickable {
  cursor: pointer;
}

.orders-stat--clickable:hover {
  background: rgba(102, 126, 234, 0.06);
}

.orders-stat--clickable.active {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.08) 100%);
  box-shadow: inset 0 -3px 0 var(--color-primary);
}

.orders-stat-divider {
  width: 1px;
  background: var(--border-color);
  align-self: stretch;
  flex-shrink: 0;
}

.orders-stat-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.orders-stat--all .orders-stat-icon { color: #6b7280; }
.orders-stat--pending .orders-stat-icon { color: #d97706; }
.orders-stat--shipped .orders-stat-icon { color: #2563eb; }
.orders-stat--delivered .orders-stat-icon { color: #16a34a; }

.orders-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.1;
}

.orders-stat--all .orders-stat-value { color: #6b7280; }
.orders-stat--pending .orders-stat-value { color: #d97706; }
.orders-stat--shipped .orders-stat-value { color: #2563eb; }
.orders-stat--delivered .orders-stat-value { color: #16a34a; }

.orders-stat-label {
  font-size: 10px;
  color: var(--text-tertiary, #888);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* ── Toolbar: search + sort + result info ── */
.orders-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.orders-search-wrap {
  flex: 1;
  position: relative;
}

.orders-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #999;
  pointer-events: none;
}

.orders-search-input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg, 10px);
  background: var(--bg-elevated, #fff);
  color: var(--text-primary, #333);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.orders-search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.orders-search-input::placeholder {
  color: #aaa;
}

.orders-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.orders-result-info {
  font-size: 12px;
  color: var(--text-tertiary, #888);
  white-space: nowrap;
}

.order-sort-control {
  border: none;
  background: transparent;
  height: auto;
  padding: 0;
  gap: 6px;
}

.order-sort-control:hover {
  border-color: transparent;
}

.order-sort-control .sort-select {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 8px;
  color: var(--color-primary);
}

.order-sort-control .sort-order-toggle-inline {
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 6px;
}

/* ── Active Filter Chip ── */
.orders-active-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.orders-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 20px;
  background: rgba(102, 126, 234, 0.1);
  color: var(--color-primary);
  border: 1px solid rgba(102, 126, 234, 0.25);
}

.orders-filter-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(102, 126, 234, 0.15);
  color: var(--color-primary);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  border: none;
  padding: 0;
  transition: background 0.15s;
}

.orders-filter-chip-x:hover {
  background: rgba(102, 126, 234, 0.3);
}

/* ── Orders List ── */
.orders-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 10px;
}

/* ── Order Item — reworked card design ── */
.order-item {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--bg-elevated, #fafafa);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg, 10px);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.order-item:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

/* Status color stripe on the left */
.order-status-stripe {
  width: 4px;
  flex-shrink: 0;
}

.order-status-stripe--pending { background: #d97706; }
.order-status-stripe--shipped { background: #2563eb; }
.order-status-stripe--delivered { background: #16a34a; }
.order-status-stripe--cancelled { background: #dc2626; }

/* Body: fills remaining space */
.order-body {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
}

/* Headline row: badge + source + price */
.order-headline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.order-status-badge {
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}

.order-status-pending {
  background: #fef3c7;
  color: #92400e;
}
.order-status-shipped {
  background: #dbeafe;
  color: #1e40af;
}
.order-status-delivered {
  background: #dcfce7;
  color: #166534;
}
.order-status-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.order-source {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary, #333);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-total {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-primary);
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Meta row: date + card count + tags */
.order-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.order-date {
  font-size: 12px;
  color: var(--text-tertiary, #888);
  white-space: nowrap;
  flex-shrink: 0;
}

.order-card-count {
  font-size: 12px;
  color: var(--text-secondary, #666);
  white-space: nowrap;
  flex-shrink: 0;
}

.order-id {
  font-size: 11px;
  font-family: monospace;
  color: var(--text-tertiary, #888);
  font-weight: 400;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Inline tag chips for extras */
.order-tags {
  display: contents;
}

.order-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f0f0f0;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  flex-shrink: 1;
  min-width: 0;
}

.order-tag--seller {
  color: #555;
}
.order-tag--arrival {
  color: #0066cc;
  background: #e8f0fe;
}
.order-tag--tracking {
  color: #666;
  font-family: monospace;
  font-size: 10px;
}

/* Card thumbnails preview — larger, overlapping stack */
.order-cards-preview {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 8px 12px 8px 4px;
  margin-left: auto;
}

.order-card-thumb-link {
  display: inline-block;
  border-radius: 4px;
  transition: transform 0.15s ease;
}

.order-card-thumb-link:hover {
  transform: scale(1.12);
  z-index: 2;
}

.order-card-thumb {
  width: 42px;
  height: 59px;
  border-radius: 4px;
  object-fit: cover;
  border: 2px solid var(--bg-elevated, #fff);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  margin-left: -10px;
  position: relative;
  transition: transform 0.15s;
}

.order-card-thumb:first-child,
.order-card-thumb-link:first-child .order-card-thumb {
  margin-left: 0;
}

.order-card-more {
  width: 42px;
  height: 59px;
  border-radius: 4px;
  background: var(--bg-secondary, #e5e7eb);
  border: 2px solid var(--bg-elevated, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary, #888);
  margin-left: -10px;
}

/* ── Card names under thumbnails ── */
.order-card-names {
  font-size: 11px;
  color: var(--text-tertiary, #888);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  line-height: 1.3;
}

/* ── Quick-action advance button ── */
.order-quick-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  flex-shrink: 0;
  border: none;
  border-left: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  background: transparent;
  color: var(--text-tertiary, #999);
  padding: 0;
}

.order-quick-action:hover {
  color: #fff;
}

.order-quick-action--shipped {
  color: #2563eb;
}
.order-quick-action--shipped:hover {
  background: #2563eb;
  color: #fff;
}

.order-quick-action--delivered {
  color: #16a34a;
}
.order-quick-action--delivered:hover {
  background: #16a34a;
  color: #fff;
}

/* ── Empty / filtered states ── */
.orders-empty-filtered {
  text-align: center;
  padding: 40px;
  color: var(--text-tertiary, #888);
  font-style: italic;
  grid-column: 1 / -1;
}

.orders-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-tertiary, #888);
}

/* ═══════════════════════════════════════════════════════════════════════════
   ORDER DETAIL MODAL
   ═══════════════════════════════════════════════════════════════════════════ */

/* Order detail modal sits below the card modal so clicking a card opens on top */
#orderDetailModal {
  z-index: calc(var(--z-modal) - 1);
}

.order-detail-modal {
  max-width: 900px;
  max-height: 90vh;
}

.order-detail-modal .modal-body {
  display: block;
  padding: 20px;
}

.order-detail-id {
  font-family: monospace;
  font-size: 12px;
  color: #888;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--bg-secondary, #f8f9fa);
  border-radius: 4px;
  word-break: break-all;
}

.order-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.order-detail-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.order-detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.order-detail-label {
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
  font-weight: 500;
}

.order-detail-value {
  font-weight: 600;
  color: var(--text-primary, #333);
}

.order-detail-total {
  font-weight: 700;
  color: var(--color-primary);
}

.order-detail-section {
  margin-bottom: 16px;
}

.order-detail-section .order-detail-label {
  margin-bottom: 8px;
  display: block;
}

.order-detail-tracking {
  font-family: monospace;
  color: var(--text-primary, #333);
}

.order-detail-cards-list {
  max-height: 300px;
  overflow-y: auto;
}

.order-detail-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  background: var(--bg-secondary, #f8f9fa);
  border-radius: 8px;
  margin-bottom: 8px;
}

.order-detail-card:last-child {
  margin-bottom: 0;
}

.order-detail-card-image {
  width: 50px;
  height: 70px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.order-detail-card-info {
  min-width: 0;
  flex: 1;
}

.order-detail-card-name {
  font-weight: 600;
  color: var(--text-primary, #333);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-detail-card-set {
  font-size: 12px;
  color: #888;
}

.order-detail-card-meta {
  font-size: 12px;
  color: var(--color-primary);
  font-weight: 600;
  margin-top: 2px;
}

.order-detail-card-notes {
  font-size: 11px;
  color: #666;
  font-style: italic;
  margin-top: 2px;
}

.order-detail-notes {
  background: var(--bg-secondary, #f8f9fa);
  padding: 12px;
  border-radius: 8px;
  color: var(--text-primary, #333);
}

.order-detail-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 20px;
}

.order-deep-link {
  font-size: 0.85em;
  margin-left: 8px;
  text-decoration: none;
  color: var(--primary-color, #4a90d9);
  border-bottom: 1px dashed currentColor;
  padding-bottom: 1px;
}
.order-deep-link:hover {
  color: var(--primary-hover, #357abd);
  border-bottom-style: solid;
}

/* Order detail card link */
.order-detail-card-link {
  text-decoration: none;
  color: inherit;
  transition: background-color 0.15s ease;
  border-radius: 8px;
}
.order-detail-card-link:hover {
  background-color: rgba(102, 126, 234, 0.06);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .orders-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .orders-stats-strip {
    flex-wrap: wrap;
  }
  .orders-stat {
    min-width: calc(50% - 1px);
  }
  .orders-stat-divider:nth-child(4) {
    display: none;
  }
  .orders-toolbar {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }
  .orders-toolbar-right {
    justify-content: space-between;
  }
}
