/* ==========================================================================
   Unified Orders, Enquiries & PDFs - Redesigned Modern Workspace UI
   ========================================================================== */

.orders-page-container {
  max-width: 1300px;
  margin: 0 auto;
  padding-bottom: 60px;
}

/* Page Header */
.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.admin-page-header h1 {
  margin: 0 0 4px 0;
  font-size: 24px;
  font-weight: 800;
  color: var(--navy, #1f2d50);
  letter-spacing: -0.02em;
}
.admin-page-header p {
  margin: 0;
  font-size: 13.5px;
  color: #64748b;
}

/* KPI / Metrics Bar */
.admin-status-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.admin-status-strip .kpi-tile {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  transition: all 180ms ease;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.admin-status-strip .kpi-tile:hover {
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}
.admin-status-strip .kpi-tile.is-active {
  border-color: #2563eb;
  background: #f8faff;
  box-shadow: 0 0 0 1.5px #2563eb;
}
.kpi-tile .kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 6px;
}
.kpi-tile .kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
}
.kpi-tile .kpi-sub {
  font-size: 11.5px;
  color: #10b981;
  font-weight: 600;
  margin-top: 4px;
}

/* Filter Card Wrap */
.admin-filter-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 22px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

/* Primary Tabs (Inside Filter Card) */
.admin-type-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 14px;
  overflow-x: auto;
}
.admin-type-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  text-decoration: none;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  transition: all 140ms ease;
  white-space: nowrap;
}
.admin-type-tab:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.admin-type-tab.is-active {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}
.admin-type-tab.is-active .count-pill {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}
.admin-type-tab .count-pill {
  background: #e2e8f0;
  color: #475569;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}
.admin-type-tab-archived {
  margin-left: auto;
  border-color: #fed7aa;
  color: #c2410c;
  background: #fff7ed;
}
.admin-type-tab-archived.is-active {
  background: #c2410c;
  border-color: #c2410c;
  color: #ffffff;
}

/* Filter Controls Row (Search, Status, Dates, Buttons on a single clean row) */
.filter-controls-row {
  display: grid;
  grid-template-columns: minmax(240px, 2.5fr) minmax(160px, 1.2fr) minmax(280px, 1.8fr) auto;
  gap: 12px;
  align-items: center;
}
@media (max-width: 1024px) {
  .filter-controls-row {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 640px) {
  .filter-controls-row {
    grid-template-columns: 1fr;
  }
}

.search-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-field-wrap .search-icon {
  position: absolute;
  left: 12px;
  color: #94a3b8;
  pointer-events: none;
  font-size: 15px;
}
.search-field-wrap input {
  width: 100% !important;
  height: 40px !important;
  padding: 0 12px 0 36px !important;
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px !important;
  font-size: 13.5px !important;
  color: #0f172a !important;
  transition: all 140ms ease;
  margin: 0 !important;
}
.search-field-wrap input:focus {
  background: #fff !important;
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
}

.custom-select-wrap select {
  width: 100% !important;
  height: 40px !important;
  padding: 0 12px !important;
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #0f172a !important;
  margin: 0 !important;
  cursor: pointer;
}
.custom-select-wrap select:focus {
  background: #fff !important;
  border-color: #2563eb !important;
}

.date-inputs-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 2px 8px;
  height: 40px;
  box-sizing: border-box;
}
.date-inputs-cluster input[type="date"] {
  border: 0 !important;
  background: transparent !important;
  padding: 0 4px !important;
  height: 34px !important;
  font-size: 12.5px !important;
  font-family: inherit !important;
  color: #0f172a !important;
  outline: none !important;
  margin: 0 !important;
  width: 120px !important;
  min-width: 0 !important;
}
.date-inputs-cluster .date-sep {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
  user-select: none;
}

.filter-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-filter-apply {
  height: 40px;
  padding: 0 18px;
  background: #2563eb;
  color: #ffffff;
  border: 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease;
  white-space: nowrap;
}
.btn-filter-apply:hover {
  background: #1d4ed8;
}
.btn-filter-clear {
  height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
  transition: color 140ms ease;
}
.btn-filter-clear:hover {
  color: #dc2626;
  background: #fef2f2;
}

/* Preset Pills Sub-bar */
.presets-sub-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #f1f5f9;
  flex-wrap: wrap;
}
.presets-sub-bar .preset-caption {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.preset-tag {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 130ms ease;
  user-select: none;
}
.preset-tag:hover {
  border-color: #94a3b8;
  color: #0f172a;
}
.preset-tag.is-active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  font-weight: 600;
}

/* ==========================================================================
   Record Card Row (Modern Compact Card View)
   ========================================================================== */
.records-stream {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.record-row-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  transition: all 160ms ease;
  overflow: hidden;
}
.record-row-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

/* Header Row Toggle */
.record-row-toggle {
  display: grid;
  grid-template-columns: 240px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 12px 18px;
  cursor: pointer;
  background: #ffffff;
  transition: background 120ms ease;
}
.record-row-toggle:hover {
  background: #fbfcfe;
}
.record-row-card.is-open .record-row-toggle {
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
}

@media (max-width: 900px) {
  .record-row-toggle {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* Col 1: ID, Type Badge, Customer */
.record-col-customer {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.record-num-badge {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
}
.customer-info-line {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.customer-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.customer-contact-sub {
  font-size: 12px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 4px;
}
.customer-contact-sub a {
  color: #64748b;
  text-decoration: none;
}
.customer-contact-sub a:hover {
  color: #2563eb;
  text-decoration: underline;
}
.wa-icon-link {
  font-size: 13px;
  line-height: 1;
  text-decoration: none !important;
  filter: saturate(1.2);
}

/* Col 2: Preview Snippet (Products, details) */
.record-col-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.preview-text {
  font-size: 13px;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-text strong {
  color: #0f172a;
}
.row-mini-thumb {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
}

/* Col 3: Side Metrics & Quick View */
.record-col-side {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: flex-end;
  white-space: nowrap;
}
.record-timestamp {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
}
.record-price-display {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  min-width: 85px;
  text-align: right;
}
.btn-row-quickview {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 130ms ease;
}
.btn-row-quickview:hover {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}
.row-chevron {
  font-size: 11px;
  color: #94a3b8;
  transition: transform 180ms ease;
  user-select: none;
}
.record-row-card.is-open .row-chevron {
  transform: rotate(180deg);
}

/* Type Badges */
.type-badge-pill {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2.5px 7px;
  border-radius: 4px;
}
.type-badge-pill.is-order { background: #e0f2fe; color: #0284c7; }
.type-badge-pill.is-inquiry { background: #fef3c7; color: #d97706; }
.type-badge-pill.is-enquiry { background: #dcfce7; color: #16a34a; }

/* Status Badges */
.badge-clean {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: capitalize;
}
.badge-clean.status-new { background: #fef9c3; color: #854d0e; }
.badge-clean.status-paid, .badge-clean.status-delivered { background: #dcfce7; color: #15803d; }
.badge-clean.status-contacted { background: #e0e7ff; color: #4338ca; }
.badge-clean.status-quoted { background: #f3e8ff; color: #7e22ce; }
.badge-clean.status-shipped { background: #e0f2fe; color: #0369a1; }
.badge-clean.status-failed, .badge-clean.status-cancelled { background: #fee2e2; color: #b91c1c; }
.badge-clean.status-created { background: #f1f5f9; color: #475569; }
.badge-clean.status-closed { background: #f1f5f9; color: #334155; }

/* ==========================================================================
   Inline Expanded Drawer
   ========================================================================== */
.record-inline-drawer {
  padding: 18px 20px;
  background: #fafbfc;
  border-top: 1px solid #f1f5f9;
}
.drawer-columns-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 960px) {
  .drawer-columns-grid {
    grid-template-columns: 1fr;
  }
}

/* Items Table */
.drawer-table-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
}
.drawer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.drawer-table th {
  background: #f8fafc;
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
}
.drawer-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
}
.drawer-table tr:last-child td {
  border-bottom: 0;
}

/* Totals Strip */
.drawer-summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 12.5px;
  color: #475569;
  align-items: center;
}
.drawer-summary-strip .highlight-val {
  color: #0f172a;
  font-weight: 700;
}
.drawer-summary-strip .savings-val {
  color: #16a34a;
  font-weight: 600;
}

/* Customer Meta Card */
.drawer-meta-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px 16px;
  font-size: 12.5px;
}
.meta-item strong {
  color: #64748b;
  font-weight: 600;
}
.meta-item span {
  color: #0f172a;
}

/* Actions Sidebar */
.drawer-actions-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel-widget {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
}
.widget-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin: 0 0 8px 0;
}
.widget-form-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.widget-form-stack select,
.widget-form-stack input {
  height: 36px !important;
  border-radius: 6px !important;
  font-size: 12.5px !important;
  margin: 0 !important;
  width: 100% !important;
}
.btn-save-status {
  height: 34px;
  background: #0f172a;
  color: #ffffff;
  border: 0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease;
}
.btn-save-status:hover {
  background: #1e293b;
}

/* Action Buttons */
.btn-action-outline {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #1e293b;
  text-decoration: none;
  cursor: pointer;
  transition: all 130ms ease;
  width: 100%;
  box-sizing: border-box;
}
.btn-action-outline:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}
.btn-action-outline.highlight-bill {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}
.btn-action-outline.highlight-order {
  border-color: #bae6fd;
  background: #f0f9ff;
  color: #0369a1;
}
.btn-action-danger {
  background: transparent;
  border: 0;
  color: #dc2626;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  text-align: left;
}
.btn-action-danger:hover {
  text-decoration: underline;
}

/* Dialog Modernization */
.shared-record-dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(780px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}
.shared-record-dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
}
.dialog-content {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
  background: #ffffff;
}
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}
.dialog-close-btn {
  background: #f1f5f9;
  border: 0;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  color: #475569;
  cursor: pointer;
}
.dialog-body {
  padding: 20px;
  overflow-y: auto;
}
