/*
  App-specific rules that must not depend on the Tailwind scan/build.
  DaisyUI + Tailwind utilities come from the CDN in base.html.

  Shared chrome (home + review + upload + email + settings): .lux-panel,
  .lux-page-header, .lux-section-label, .lux-status-*. List tables use
  django_tables2/daisyui. Bump ?v= on lux.css in base.html when this file
  changes (sandbox/Caddy cache).
*/

a.lux-settings-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

a.lux-settings-card:hover {
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.06),
    0 16px 32px rgb(0 0 0 / 0.1);
  transform: translateY(-1px);
}

.lux-settings-card .lux-panel-title {
  margin-bottom: 0;
}

.lux-settings-card-muted {
  opacity: 0.75;
}

/* Soft white cards on the gray page background */
.lux-panel {
  border-radius: 1rem;
  background: var(--color-base-100, #fff);
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.04),
    0 12px 28px rgb(0 0 0 / 0.08);
}

.lux-panel-body {
  padding: 1.25rem 1.5rem;
}

.lux-panel-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  letter-spacing: -0.01em;
}

/* Page title block (home filter panel / review header) */
.lux-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
}

.lux-page-header h1,
.lux-page-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.25;
}

.lux-page-kicker {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.55;
  margin-bottom: 0.35rem;
  text-decoration: none;
  color: inherit;
}

.lux-page-kicker:hover {
  opacity: 0.85;
  text-decoration: underline;
}

.lux-page-sub {
  font-size: 0.875rem;
  opacity: 0.6;
  margin: 0.35rem 0 0;
}

.lux-section-label {
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.6;
  margin: 0 0 0.5rem;
}

/* Status accents — same tokens as home stat cards */
.lux-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  border-left-width: 3px;
  background: var(--color-base-100, #fff);
  color: inherit;
}

.lux-status-pending {
  --lux-stat-accent: var(--color-warning, #fbbd23);
  border-color: color-mix(in oklab, var(--lux-stat-accent) 35%, transparent);
  border-left-color: var(--lux-stat-accent);
  background: color-mix(in oklab, var(--lux-stat-accent) 12%, white);
}

.lux-status-pushed {
  --lux-stat-accent: var(--color-success, #36d399);
  border-color: color-mix(in oklab, var(--lux-stat-accent) 35%, transparent);
  border-left-color: var(--lux-stat-accent);
  background: color-mix(in oklab, var(--lux-stat-accent) 12%, white);
}

.lux-status-rejected {
  --lux-stat-accent: var(--color-neutral, #3d4451);
  border-color: color-mix(in oklab, var(--lux-stat-accent) 30%, transparent);
  border-left-color: var(--lux-stat-accent);
  background: color-mix(in oklab, var(--lux-stat-accent) 8%, white);
}

.lux-status-failed {
  --lux-stat-accent: var(--color-error, #f87272);
  border-color: color-mix(in oklab, var(--lux-stat-accent) 35%, transparent);
  border-left-color: var(--lux-stat-accent);
  background: color-mix(in oklab, var(--lux-stat-accent) 12%, white);
}

/* Review line items — colgroup-driven widths; description is text+ellipsis, not an input */
#review-form .lux-line-items {
  width: 100%;
  min-width: 36rem;
  table-layout: fixed;
}

#review-form .lux-line-items .lux-col-match {
  width: 10.5rem;
}

#review-form .lux-line-items .lux-col-code {
  width: 9.5rem;
}

#review-form .lux-line-items .lux-col-desc {
  width: auto;
}

#review-form .lux-line-items .lux-col-qty {
  width: 3.75rem;
}

#review-form .lux-line-items .lux-col-price {
  width: 5rem;
}

#review-form .lux-line-items .lux-col-del {
  width: 2.25rem;
}

#review-form .lux-line-items th,
#review-form .lux-line-items td {
  vertical-align: middle;
}

#review-form .lux-line-items th:last-child,
#review-form .lux-line-items td:last-child {
  text-align: center;
}

#review-form .lux-line-items .lux-input-qty,
#review-form .lux-line-items .lux-input-price {
  width: 100%;
  max-width: 4.75rem;
  text-align: right;
  padding-inline: 0.4rem;
}

#review-form .lux-line-items td:nth-of-type(2) input {
  width: 100%;
  text-align: left;
}

#review-form .lux-desc-truncate {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  font-size: 0.8rem;
  line-height: 1.35;
  opacity: 0.72;
  cursor: default;
}

#review-form .lux-match-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

#review-form .lux-match-inline .lux-match-itemid {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#review-form .lux-price-flag {
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  max-width: 100%;
}

#review-form .lux-price-flag .badge {
  flex-shrink: 0;
}

#review-form .lux-price-flag-detail {
  display: block;
  font-size: 0.65rem;
  line-height: 1.25;
  opacity: 0.7;
  white-space: normal;
  word-break: break-word;
}

#review-form .lux-price-ok {
  margin-top: 0.25rem;
  font-size: 0.65rem;
  line-height: 1.25;
  color: var(--color-success, #36d399);
}

/* Review: email meta (when PO came from Graph) */
.lux-email-meta .lux-email-subject {
  margin: 0.25rem 0 0.35rem;
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

/* Review: PDF pane + form actions */
.lux-pdf-switcher {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0.65rem;
  border: 1px solid color-mix(in oklab, var(--color-base-content, #1f2937) 14%, transparent);
  background: color-mix(in oklab, var(--color-base-200, #e5e7eb) 55%, white);
}

.lux-pdf-hint {
  margin: 0.65rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
  opacity: 0.65;
}

.lux-pdf-frame {
  width: 100%;
  height: 80vh;
  border: 0;
  border-radius: 0.75rem;
  background: var(--color-base-200, #e5e7eb);
}

.lux-review-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding-top: 1rem;
  border-top: 1px solid color-mix(in oklab, var(--color-base-content, #1f2937) 12%, transparent);
}

.lux-review-actions .lux-review-reject {
  margin-left: auto;
}

/* Review page activity log (ul only — do not put .lux-activity on a panel). */
ul.lux-activity {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul.lux-activity > li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid color-mix(in oklab, var(--color-base-content, #1f2937) 8%, transparent);
  font-size: 0.9rem;
}

ul.lux-activity > li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

ul.lux-activity > li:first-child {
  padding-top: 0;
}

ul.lux-activity .lux-activity-time {
  font-size: 0.8rem;
  opacity: 0.55;
  white-space: nowrap;
}

/* Form validation (Django errorlist) — shared, not inline in review.html */
.errorlist {
  list-style: none;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
  background-color: color-mix(in oklab, var(--color-error, #f87272) 12%, white);
  color: color-mix(in oklab, var(--color-error, #f87272) 55%, #1f2937);
  border: 1px solid color-mix(in oklab, var(--color-error, #f87272) 35%, transparent);
  border-radius: 0.5rem;
}

/* Status cards + separate archive card */
/* Seven equal cards: PO statuses + inbound + archive (no side gap). */
.lux-stats {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.65rem;
  min-width: 0;
}

@media (max-width: 1100px) {
  .lux-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .lux-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.lux-stat-inbound {
  --lux-stat-accent: var(--color-info, #3abff8);
  border-left-color: var(--lux-stat-accent);
}

/* Home desk activity (below PO table) — scoped; not Review's ul.lux-activity */
.lux-desk-activity-heading {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.lux-desk-activity-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid color-mix(in oklab, var(--color-base-content, #1f2937) 8%, transparent);
}

.lux-desk-activity-item {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr) auto;
  gap: 0.75rem 1rem;
  align-items: baseline;
  padding: 0.55rem 0.85rem;
  background: var(--color-base-100, #fff);
  border-bottom: 1px solid color-mix(in oklab, var(--color-base-content, #1f2937) 6%, transparent);
}

.lux-desk-activity-item:nth-child(even) {
  background: color-mix(in oklab, var(--color-base-200, #e5e7eb) 45%, white);
}

.lux-desk-activity-item:last-child {
  border-bottom: none;
}

.lux-desk-activity-po {
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--color-primary, #570df8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lux-desk-activity-po:hover {
  text-decoration: underline;
}

.lux-desk-activity-msg {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.35;
  opacity: 0.8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.lux-desk-activity-time {
  font-size: 0.7rem;
  opacity: 0.5;
  white-space: nowrap;
  flex-shrink: 0;
}

.lux-desk-activity-pager {
  display: inline-flex;
  margin-top: 0.75rem;
}

@media (max-width: 640px) {
  .lux-desk-activity-item {
    grid-template-columns: 1fr auto;
  }

  .lux-desk-activity-msg {
    grid-column: 1 / -1;
    white-space: normal;
  }
}

.lux-stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.1rem;
  border-radius: 1rem;
  background: var(--color-base-100, #fff);
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.04),
    0 8px 20px rgb(0 0 0 / 0.06);
  border: 1px solid transparent;
  border-left: 4px solid var(--color-base-300, #d1d5db);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.lux-stat:hover {
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.04),
    0 12px 28px rgb(0 0 0 / 0.1);
}

.lux-stat-active {
  border-color: color-mix(in oklab, var(--lux-stat-accent, #570df8) 35%, transparent);
  box-shadow:
    0 0 0 1px color-mix(in oklab, var(--lux-stat-accent, #570df8) 25%, transparent),
    0 12px 28px rgb(0 0 0 / 0.08);
}

.lux-stat-pending {
  --lux-stat-accent: var(--color-warning, #fbbd23);
  border-left-color: var(--lux-stat-accent);
}

.lux-stat-pushed {
  --lux-stat-accent: var(--color-success, #36d399);
  border-left-color: var(--lux-stat-accent);
}

.lux-stat-rejected {
  --lux-stat-accent: var(--color-neutral, #3d4451);
  border-left-color: var(--lux-stat-accent);
}

.lux-stat-failed {
  --lux-stat-accent: var(--color-error, #f87272);
  border-left-color: var(--lux-stat-accent);
}

.lux-stat-archived {
  --lux-stat-accent: var(--color-base-content, #1f2937);
  border-left-color: color-mix(in oklab, var(--lux-stat-accent) 40%, transparent);
  border-style: dashed;
  background: color-mix(in oklab, var(--color-base-200, #e5e7eb) 55%, white);
}

.lux-stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.65;
}

.lux-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.lux-stat-hint {
  font-size: 0.7rem;
  font-weight: 500;
  opacity: 0.55;
  margin-top: 0.15rem;
}

/* Actions: centered header; rule between open button and archive */
.lux-actions-head {
  text-align: center;
}

.lux-actions-cell {
  text-align: center;
  white-space: nowrap;
  overflow: visible;
}

.lux-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.lux-actions form {
  display: inline-flex;
  margin: 0;
  padding-left: 0.45rem;
  border-left: 1px solid color-mix(in oklab, var(--color-base-content, #1f2937) 22%, transparent);
}

.lux-action-icon {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
  flex-shrink: 0;
}

/* Fixed width so View / Review rows stay aligned */
.lux-action-open {
  min-width: 5.75rem;
  justify-content: flex-start;
  gap: 0.35rem;
  font-weight: 500;
  padding-inline: 0.55rem;
}

.lux-action-review {
  background: color-mix(in oklab, var(--color-primary, #570df8) 12%, transparent);
  border: 1px solid color-mix(in oklab, var(--color-primary, #570df8) 45%, transparent);
  color: var(--color-primary, #570df8);
}

.lux-action-review:hover {
  background: color-mix(in oklab, var(--color-primary, #570df8) 20%, transparent);
}

.lux-action-view {
  background: transparent;
  border: 1px solid color-mix(in oklab, var(--color-base-content, #1f2937) 18%, transparent);
  color: color-mix(in oklab, var(--color-base-content, #1f2937) 75%, transparent);
}

.lux-action-view:hover {
  background: color-mix(in oklab, var(--color-base-200, #e5e7eb) 80%, white);
  border-color: color-mix(in oklab, var(--color-base-content, #1f2937) 28%, transparent);
}

.lux-action-archive {
  opacity: 0.7;
}

.lux-action-archive:hover {
  opacity: 1;
  background: color-mix(in oklab, var(--color-base-200, #e5e7eb) 80%, white);
}

/*
  Shared list tables (home POs + inbound email): horizontal scroll shell,
  fixed layout, column resize handles. #po-table kept as alias for older hooks.
*/
.lux-data-table-shell,
#po-table-shell {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.lux-data-table,
#po-table {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 58rem;
}

#email-table.lux-data-table {
  min-width: 48rem;
}

.lux-data-table th,
.lux-data-table td,
#po-table th,
#po-table td {
  position: relative;
  vertical-align: middle;
}

.lux-data-table .file-cell,
#po-table .file-cell {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  font-size: 0.75rem;
  opacity: 0.55;
}

.lux-data-table .buyer-cell,
#po-table .buyer-cell {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}

#po-table th:nth-child(4),
#po-table td:nth-child(4),
#po-table th:nth-child(5),
#po-table td:nth-child(5),
#po-table th:nth-child(6),
#po-table td:nth-child(6) {
  overflow: visible;
  white-space: nowrap;
}

#po-table th:nth-child(1),
#po-table td:nth-child(1),
#po-table th:nth-child(2),
#po-table td:nth-child(2),
#po-table th:nth-child(3),
#po-table td:nth-child(3) {
  overflow: hidden;
}

#email-table th:nth-child(4),
#email-table td:nth-child(4),
#email-table th:nth-child(5),
#email-table td:nth-child(5) {
  overflow: visible;
  white-space: nowrap;
}

.lux-data-table .col-resize,
#po-table .col-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
}

.lux-data-table .col-resize:hover,
#po-table .col-resize:hover {
  background: color-mix(in oklab, var(--color-primary, #570df8) 35%, transparent);
}

.lux-filter-row,
#po-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.lux-filter-row .lux-filter-search,
#po-filter-row .po-filter-search {
  width: 18rem;
  max-width: 100%;
}

.lux-filter-row .lux-filter-status,
#po-filter-row .po-filter-status {
  width: 11rem;
  max-width: 100%;
}

