/* ==========================================================================
   THE NIGHT CLUB — Student "My Orders" & Order Details (Phase 33)
   Multi-course orders, premium card design, dark/light theme support.
   Uses tokens.css variables and student-theme.css day/night overrides.
   Only adds/extends — does not duplicate site.css / student.css primitives.
   ========================================================================== */

/* ---- Filter pills -------------------------------------------------------- */

.orders-filters {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

.filter-pill {
  padding: 6px var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.filter-pill:hover {
  border-color: var(--color-accent-600);
  color: var(--color-text);
}

.filter-pill.is-active {
  background: var(--color-accent-500);
  border-color: var(--color-accent-500);
  color: var(--color-text-on-accent);
}

/* ---- Order list ---------------------------------------------------------- */

.order-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-2);
}

/* ---- Order card ---------------------------------------------------------- */

.order-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-4) var(--space-6);
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  transition: border-color var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}

.order-card:hover {
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 8px 32px rgba(124, 58, 237, 0.12);
}

/* Top row spans both columns: order meta + status badge */
.order-card-top {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.order-card-number {
  font-size: var(--font-size-base);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.order-card-date {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Course thumbnail strip */
.order-card-thumbs {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

.order-card-thumb {
  width: 52px;
  height: 34px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface-2);
  flex-shrink: 0;
  position: relative;
}

.order-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.order-card-thumb-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-accent-700);
  background: var(--color-accent-50);
}

.order-card-thumb-more {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.order-card-course-names {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-top: var(--space-2);
}

/* Right column: amount + action */
.order-card-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
}

.order-card-amount {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--color-text);
}

.order-card-count {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-align: right;
}

/* ---- Status badges — Order.status ---------------------------------------- */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: var(--space-1) 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-glyph { font-style: normal; }

/* Order status colors */
.status-PAID       { background: rgba(52, 211, 153, 0.12); color: var(--color-success, #34d399); border: 1px solid rgba(52, 211, 153, 0.35); }
.status-PENDING    { background: rgba(251, 191, 36, 0.10); color: #f59e0b; border: 1px solid rgba(251, 191, 36, 0.35); }
.status-FAILED     { background: rgba(248, 113, 113, 0.10); color: var(--color-danger, #f87171); border: 1px solid rgba(248, 113, 113, 0.35); }
.status-CANCELLED  { background: rgba(167, 159, 192, 0.10); color: var(--color-text-muted); border: 1px solid rgba(167, 159, 192, 0.3); }
.status-REFUNDED   { background: rgba(96, 165, 250, 0.10); color: #60a5fa; border: 1px solid rgba(96, 165, 250, 0.35); }

/* Payment status colors (payment sub-badges) */
.status-CAPTURED   { background: rgba(52, 211, 153, 0.12); color: var(--color-success, #34d399); border: 1px solid rgba(52, 211, 153, 0.35); }
.status-AUTHORIZED { background: rgba(96, 165, 250, 0.10); color: #60a5fa; border: 1px solid rgba(96, 165, 250, 0.35); }
.status-CREATED    { background: rgba(167, 159, 192, 0.10); color: var(--color-text-muted); border: 1px solid rgba(167, 159, 192, 0.3); }
.status-EXPIRED    { background: rgba(167, 159, 192, 0.10); color: var(--color-text-muted); border: 1px solid rgba(167, 159, 192, 0.3); }

/* Item fulfilment status */
.item-status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.item-status-FULFILLED    { background: rgba(52, 211, 153, 0.12); color: var(--color-success, #34d399); }
.item-status-ALREADY_OWNED { background: rgba(96, 165, 250, 0.10); color: #60a5fa; }
.item-status-PENDING      { background: rgba(251, 191, 36, 0.10); color: #f59e0b; }
.item-status-FAILED       { background: rgba(248, 113, 113, 0.10); color: var(--color-danger, #f87171); }
.item-status-CANCELLED    { background: rgba(167, 159, 192, 0.10); color: var(--color-text-muted); }

/* ---- Pagination ---------------------------------------------------------- */

.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-8);
}

/* ---- Order Detail: receipt-head already defined in student.css ----------- */

/* Multi-course section */
.receipt-courses-section { margin-top: 0; }

.receipt-course-item {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: var(--space-4);
  align-items: start;
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--color-border);
}

.receipt-course-item:last-child { border-bottom: none; }

.receipt-item-thumb {
  width: 80px;
  height: 50px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface-2);
  flex-shrink: 0;
}

.receipt-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.receipt-item-thumb-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--color-accent-700);
  background: var(--color-accent-50);
}

.receipt-item-body {
  min-width: 0;
}

.receipt-item-title {
  font-size: var(--font-size-base);
  font-weight: 500;
  margin: 0 0 var(--space-1);
  letter-spacing: -0.01em;
  word-break: break-word;
}

.receipt-item-price {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-2);
}

.receipt-item-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ---- Status banner (for PENDING / FAILED orders) ----------------------- */

.order-status-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.order-status-banner.is-warning {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: #f59e0b;
}

.order-status-banner.is-danger {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--color-danger, #f87171);
}

/* ---- Mono (transaction IDs) --------------------------------------------- */

.mono {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.8em;
  word-break: break-all;
}

/* ---- Light mode overrides (via student-theme.css tokens) ---------------- */

html[data-theme="light"] .order-card {
  background: #ffffff;
  border-color: #e5e0f0;
}

html[data-theme="light"] .order-card:hover {
  border-color: rgba(124, 58, 237, 0.35);
  box-shadow: 0 8px 32px rgba(124, 58, 237, 0.08);
}

html[data-theme="light"] .order-card-thumb-fallback {
  background: #ede9fe;
  color: #6d28d9;
}

html[data-theme="light"] .receipt-item-thumb-fallback {
  background: #ede9fe;
  color: #6d28d9;
}

html[data-theme="light"] .filter-pill {
  background: #f7f5ff;
  border-color: #d4cafe;
  color: #5b21b6;
}

html[data-theme="light"] .filter-pill:hover {
  background: #ede9fe;
  border-color: #7c3aed;
  color: #5b21b6;
}

html[data-theme="light"] .filter-pill.is-active {
  background: var(--color-accent-500);
  border-color: var(--color-accent-500);
  color: #fff;
}

/* Status badge light tweaks */
html[data-theme="light"] .status-PAID       { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
html[data-theme="light"] .status-CAPTURED   { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
html[data-theme="light"] .status-PENDING    { background: #fef3c7; color: #92400e; border-color: #fde68a; }
html[data-theme="light"] .status-FAILED     { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
html[data-theme="light"] .status-CANCELLED  { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
html[data-theme="light"] .status-REFUNDED   { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
html[data-theme="light"] .status-AUTHORIZED { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
html[data-theme="light"] .status-CREATED    { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
html[data-theme="light"] .status-EXPIRED    { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }

html[data-theme="light"] .item-status-FULFILLED    { background: #d1fae5; color: #065f46; }
html[data-theme="light"] .item-status-ALREADY_OWNED { background: #dbeafe; color: #1e40af; }
html[data-theme="light"] .item-status-PENDING      { background: #fef3c7; color: #92400e; }
html[data-theme="light"] .item-status-FAILED       { background: #fee2e2; color: #991b1b; }
html[data-theme="light"] .item-status-CANCELLED    { background: #f3f4f6; color: #6b7280; }

html[data-theme="light"] .order-status-banner.is-warning { background: #fef3c7; border-color: #fde68a; color: #92400e; }
html[data-theme="light"] .order-status-banner.is-danger  { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 480px) {
  .order-card {
    grid-template-columns: 1fr;
    padding: var(--space-4);
  }

  .order-card-side {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .orders-filters {
    gap: var(--space-2);
  }

  .receipt-course-item {
    grid-template-columns: 60px 1fr;
    grid-template-rows: auto auto;
  }

  .receipt-item-side {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .pagination-controls {
    flex-wrap: wrap;
    gap: var(--space-3);
  }
}
