/* ============================================================
   Dashboard Modern — Shared Design System
   Loaded after custom.css to override legacy styles
   ============================================================ */

/* === Extended CSS Variables === */
:root {
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.8125rem;
  --font-size-base: 0.9rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 1.75rem;
  /* Semantic status colors */
  --status-pending-bg: #FFF8E1;
  --status-pending-text: #F57F17;
  --status-processing-bg: #E3F2FD;
  --status-processing-text: #1565C0;
  --status-shipped-bg: #E8F5E9;
  --status-shipped-text: #2E7D32;
  --status-delivered-bg: #E0F2F1;
  --status-delivered-text: #00695C;
  --status-cancelled-bg: #FFEBEE;
  --status-cancelled-text: #C62828;
  --status-paid-bg: #E8F5E9;
  --status-paid-text: #2E7D32;
  --status-failed-bg: #FFEBEE;
  --status-failed-text: #C62828;
}

/* === Override legacy .header padding === */
.header {
  padding: 20px 0 12px !important;
  margin-bottom: 8px !important;
}

/* === Modern Card === */
.card-modern {
  background: #fff;
  border: 1px solid var(--gray-200, #e9ecef);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
  overflow: hidden;
}
.card-modern:hover {
  box-shadow: var(--shadow-md);
}
.card-modern .card-body {
  padding: var(--spacing-xl);
}
.card-modern .card-header-modern {
  padding: var(--spacing-lg) var(--spacing-xl);
  border-bottom: 1px solid var(--gray-100, #f1f3f5);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-modern .card-header-modern h5,
.card-modern .card-header-modern h4 {
  margin: 0;
  font-weight: 600;
  font-size: var(--font-size-lg);
}

/* === Stat Card === */
.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200, #e9ecef);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-xl);
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat-card__icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-card__icon--blue { background: rgba(59,130,246,.1); color: #3b82f6; }
.stat-card__icon--green { background: rgba(16,185,129,.1); color: #10b981; }
.stat-card__icon--purple { background: rgba(139,92,246,.1); color: #8b5cf6; }
.stat-card__icon--orange { background: rgba(245,158,11,.1); color: #f59e0b; }
.stat-card__icon--red { background: rgba(239,68,68,.1); color: #ef4444; }
.stat-card__icon--teal { background: rgba(20,184,166,.1); color: #14b8a6; }
.stat-card__content {
  flex: 1;
  min-width: 0;
}
.stat-card__value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  line-height: 1.2;
  color: var(--gray-800, #343a40);
}
.stat-card__label {
  font-size: var(--font-size-sm);
  color: var(--gray-500, #adb5bd);
  margin-top: 2px;
  font-weight: 500;
}
.stat-card__label a {
  color: var(--gray-500, #adb5bd);
  text-decoration: none;
}
.stat-card__label a:hover {
  color: var(--primary);
}

/* === Status Badge === */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  border-radius: 20px;
  line-height: 1.5;
  white-space: nowrap;
  text-transform: capitalize;
}
.status-badge--pending { background: var(--status-pending-bg); color: var(--status-pending-text); }
.status-badge--processing { background: var(--status-processing-bg); color: var(--status-processing-text); }
.status-badge--shipped { background: var(--status-shipped-bg); color: var(--status-shipped-text); }
.status-badge--delivered { background: var(--status-delivered-bg); color: var(--status-delivered-text); }
.status-badge--cancelled { background: var(--status-cancelled-bg); color: var(--status-cancelled-text); }
.status-badge--paid, .status-badge--success { background: var(--status-paid-bg); color: var(--status-paid-text); }
.status-badge--failed { background: var(--status-failed-bg); color: var(--status-failed-text); }
.status-badge--live { background: #ECFDF5; color: #065F46; }
.status-badge--setup { background: #FFF7ED; color: #9A3412; }

/* === Modern Tabs === */
.nav-tabs-modern {
  border-bottom: 2px solid var(--gray-100, #f1f3f5);
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.nav-tabs-modern::-webkit-scrollbar { display: none; }
.nav-tabs-modern .nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 12px 18px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--gray-500, #adb5bd);
  background: transparent;
  white-space: nowrap;
  transition: all 0.2s ease;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.nav-tabs-modern .nav-link:hover {
  color: var(--gray-700, #495057);
  border-bottom-color: var(--gray-300, #dee2e6);
  background: rgba(0,0,0,.02);
}
.nav-tabs-modern .nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(62,111,219,.06);
  border-bottom-width: 3px;
  margin-bottom: -3px;
}
.nav-tabs-modern .nav-link .badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
}
.nav-tabs-modern .nav-link.active .badge {
  box-shadow: 0 0 0 1px rgba(62,111,219,.2);
}

/* Server-rendered Bootstrap modals — modern override */
.modal .modal-content {
  border: none;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.25);
  overflow: hidden;
}
.modal .modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #f1f5f9;
  background: #fafbfc;
}
.modal .modal-header .modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}
.modal .modal-header .close {
  font-size: 22px;
  color: #94a3b8;
  opacity: 1;
  text-shadow: none;
  padding: 0;
  margin: 0;
}
.modal .modal-header .close:hover { color: #334155; }
.modal .modal-body {
  padding: 20px 24px;
}
.modal .modal-body label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #94a3b8;
  margin-bottom: 6px;
}
.modal .modal-body .form-control {
  border-radius: 8px;
  border-color: #e2e8f0;
  font-size: 13px;
  padding: 9px 12px;
  transition: border-color .2s;
}
.modal .modal-body .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(62,111,219,.08);
}
.modal .modal-body select.form-control {
  border-radius: 8px;
}
.modal .modal-body textarea.form-control {
  border-radius: 8px;
  resize: vertical;
  min-height: 60px;
}
.modal .modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid #f1f5f9;
  background: #fafbfc;
}
.modal .modal-footer .btn {
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 20px;
}
/* Right-slide modals used on Salla orders */
.modal.right_modal .modal-dialog {
  max-width: 440px;
}
.modal.right_modal.bd-example-modal-lg .modal-dialog {
  max-width: 700px;
}
/* Backdrop */
.modal-backdrop {
  background: rgba(15,23,42,.4);
  backdrop-filter: blur(2px);
}
.modal-backdrop.show {
  opacity: 1;
}

/* === Page Header === */
.page-header {
  padding: 16px 0 12px;
  margin-bottom: 12px;
}
.page-header__title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gray-800, #343a40);
  margin: 0 0 2px;
}
.page-header__subtitle {
  font-size: var(--font-size-sm);
  color: var(--gray-500, #adb5bd);
  margin: 0;
}
.page-header__actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* === Form Section (settings pages) === */
.form-section {
  padding: var(--spacing-xl) 0;
  border-bottom: 1px solid var(--gray-100, #f1f3f5);
}
.form-section:last-child { border-bottom: none; }
.form-section__desc {
  padding-inline-start: var(--spacing-lg);
  border-inline-start: 3px solid var(--primary-200, rgba(62,111,219,.2));
}
.form-section__desc h5 {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--gray-800, #343a40);
  margin-bottom: 4px;
}
.form-section__desc p {
  font-size: var(--font-size-sm);
  color: var(--gray-500, #adb5bd);
  margin: 0;
  line-height: 1.6;
}

/* === DataTables Modern Overrides === */
.dataTables_wrapper {
  font-size: 13px;
}
.dataTables_wrapper .dataTables_filter {
  margin-bottom: 0;
}
.dataTables_wrapper .dataTables_filter label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  margin: 0;
}
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  min-width: 220px;
  transition: all 0.2s;
  background: #f8fafc;
  color: #334155;
}
.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(62,111,219,0.08);
  background: #fff;
}
.dataTables_wrapper .dataTables_filter input::placeholder {
  color: #94a3b8;
}
.dataTables_wrapper .dataTables_length select {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  background: #f8fafc;
}
.dataTables_wrapper .dataTables_info {
  font-size: 12px;
  color: #94a3b8;
  padding-top: 4px;
}
.dataTables_wrapper .dataTables_paginate {
  padding-top: 4px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: 6px !important;
  margin: 0 2px;
  padding: 5px 12px !important;
  font-size: 12px !important;
  font-weight: 500;
  border: 1px solid #e2e8f0 !important;
  background: #fff !important;
  color: #475569 !important;
  transition: all 0.15s;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
  box-shadow: none !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  color: #cbd5e1 !important;
  background: #f8fafc !important;
  border-color: #f1f5f9 !important;
  cursor: default;
}
.dataTables_wrapper .dataTables_processing {
  background: rgba(255,255,255,0.9);
  color: #64748b;
  font-size: 13px;
  border: none;
}
/* Hide default DT borders */
.dataTables_wrapper table.dataTable {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}
.dataTables_wrapper table.dataTable thead th {
  border-bottom: 2px solid #e2e8f0 !important;
}
.dataTables_wrapper table.dataTable tbody td {
  border-bottom: 1px solid #f1f5f9;
}
.dataTables_wrapper table.dataTable.no-footer {
  border-bottom: none !important;
}

/* Modern table styling */
.table-modern {
  border-collapse: separate;
  border-spacing: 0;
}
.table-modern thead th {
  background: var(--gray-50, #f8f9fa);
  border-bottom: 2px solid var(--gray-200, #e9ecef);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500, #adb5bd);
  padding: 12px 16px;
}
.table-modern tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100, #f1f3f5);
  vertical-align: middle;
  font-size: var(--font-size-sm);
}
.table-modern tbody tr:hover td {
  background: var(--gray-50, #f8f9fa);
}
.table-modern tbody tr:last-child td {
  border-bottom: none;
}

/* === Variant Table (scoped scrollable) === */
.variant-table tbody {
  display: block;
  max-height: 350px;
  overflow-y: auto;
}
.variant-table thead,
.variant-table tbody tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

/* === Loading Dots === */
.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.loading-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: dotPulse 1.4s infinite ease-in-out both;
}
.loading-dots .dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dots .dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0.4); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* === Spinner Overlay === */
.overlay-modern {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius-md);
}
.spinner-modern {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200, #e9ecef);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spinModern 0.7s linear infinite;
}
@keyframes spinModern {
  to { transform: rotate(360deg); }
}

/* === Button Enhancements === */
.btn-modern {
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--font-size-sm);
  padding: 8px 20px;
  transition: all 0.2s ease;
  letter-spacing: 0.2px;
}
.btn-modern:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn-xs {
  padding: 3px 10px;
  font-size: var(--font-size-xs);
  line-height: 1.5;
  border-radius: var(--radius-sm);
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}
.empty-state__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  color: var(--gray-300, #dee2e6);
}
.empty-state__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--gray-700, #495057);
  margin-bottom: 8px;
}
.empty-state__desc {
  font-size: var(--font-size-sm);
  color: var(--gray-500, #adb5bd);
  margin-bottom: 20px;
}

/* === Progress Bar === */
.progress-modern {
  height: 8px;
  border-radius: 4px;
  background: var(--gray-100, #f1f3f5);
  overflow: hidden;
}
.progress-modern__bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* === Bulk Actions Bar === */
.bulk-bar {
  background: var(--gray-50, #f8f9fa);
  border: 1px solid var(--gray-200, #e9ecef);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--spacing-md);
}
.bulk-bar select {
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  padding: 4px 10px;
}

/* === Summary Row (used in order details, checkout) === */
.sum-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: var(--font-size-sm);
  color: var(--gray-600, #868e96);
}
.sum-row.sum-total {
  border-top: 2px solid var(--gray-200, #e9ecef);
  margin-top: 8px;
  padding-top: 12px;
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--gray-800, #343a40);
}

/* === Detail Card (orders, payments) === */
.detail-card {
  background: #fff;
  border: 1px solid var(--gray-200, #e9ecef);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
  overflow: hidden;
}
.detail-card__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100, #f1f3f5);
  display: flex;
  align-items: center;
  gap: 10px;
}
.detail-card__header h5 {
  margin: 0;
  font-size: var(--font-size-base);
  font-weight: 600;
}
.detail-card__header i {
  color: var(--gray-400, #ced4da);
  font-size: 14px;
}
.detail-card__body {
  padding: 20px;
}
.detail-card__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-50, #f8f9fa);
  font-size: var(--font-size-sm);
}
.detail-card__row:last-child { border-bottom: none; }
.detail-card__label { color: var(--gray-500, #adb5bd); }
.detail-card__value { font-weight: 600; color: var(--gray-800, #343a40); }

/* === Timeline === */
.timeline-vertical {
  position: relative;
  padding-inline-start: 28px;
}
.timeline-vertical::before {
  content: '';
  position: absolute;
  inset-inline-start: 8px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--gray-200, #e9ecef);
}
.timeline-vertical__item {
  position: relative;
  padding-bottom: 20px;
}
.timeline-vertical__item:last-child { padding-bottom: 0; }
.timeline-vertical__dot {
  position: absolute;
  inset-inline-start: -24px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gray-300, #dee2e6);
  border: 2px solid #fff;
  z-index: 1;
}
.timeline-vertical__dot--active {
  background: var(--primary);
}
.timeline-vertical__dot--done {
  background: #10b981;
}
.timeline-vertical__label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--gray-700, #495057);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.timeline-vertical__date {
  font-size: var(--font-size-xs);
  color: var(--gray-400, #ced4da);
  margin-top: 2px;
}

/* === Color Input === */
.form-control-color {
  height: 42px;
  padding: 4px;
  cursor: pointer;
}

/* === RTL Overrides === */
[dir="rtl"] .stat-card { flex-direction: row-reverse; }
[dir="rtl"] .detail-card__row { flex-direction: row-reverse; }
[dir="rtl"] .timeline-vertical { padding-inline-start: 28px; padding-inline-end: 0; }
[dir="rtl"] .bulk-bar { flex-direction: row-reverse; }

/* === Dark Mode === */
[data-theme-style="dark"] .card-modern,
[data-theme-style="dark"] .stat-card,
[data-theme-style="dark"] .detail-card {
  background: var(--gray-800, #343a40);
  border-color: var(--gray-700, #495057);
}
[data-theme-style="dark"] .stat-card__value,
[data-theme-style="dark"] .detail-card__value {
  color: var(--gray-100, #f1f3f5);
}
[data-theme-style="dark"] .table-modern thead th {
  background: var(--gray-800, #343a40);
  border-color: var(--gray-700, #495057);
}
[data-theme-style="dark"] .table-modern tbody td {
  border-color: var(--gray-700, #495057);
}
[data-theme-style="dark"] .table-modern tbody tr:hover td {
  background: var(--gray-700, #495057);
}
[data-theme-style="dark"] .nav-tabs-modern {
  border-color: var(--gray-700, #495057);
}
[data-theme-style="dark"] .form-section {
  border-color: var(--gray-700, #495057);
}
[data-theme-style="dark"] .bulk-bar {
  background: var(--gray-800, #343a40);
  border-color: var(--gray-700, #495057);
}
[data-theme-style="dark"] .overlay-modern {
  background: rgba(0,0,0,0.7);
}
