/* =========================================================
   POS RETAIL COMPATIBILITY LAYER
   Base visual source: custom-modern.css from POS Aztech.
   This file only bridges rebuild-specific components to the
   exact typography, spacing, colors, radii and shadows used
   by the reference theme.
   ========================================================= */

/* Page heading generated by the rebuild layout */
.modern-pos .content-header {
  padding: 24px 18px 0 32px;
}

.modern-pos .content-header > .container-fluid,
.modern-pos .modern-content > .container-fluid {
  padding-right: 0;
  padding-left: 0;
}

.modern-pos .modern-content {
  padding: 18px 18px 35px 32px;
}

.modern-pos .content-header .modern-page-header {
  margin-bottom: 0;
}

.modern-pos .content-header .modern-page-header h1,
.modern-pos .page-title-modern {
  margin: 0;
  color: #111827;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
}

.modern-pos .content-header .modern-page-header p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 14px;
  font-weight: 400;
}

/* Bootstrap card markup used by the complete retail modules */
.modern-pos .card.modern-card {
  width: 100%;
  margin-bottom: 24px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #e5eaf2;
  border-radius: 18px;
  box-shadow: var(--az-shadow-md);
}

.modern-pos .card.modern-card .card-header {
  min-height: 70px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #ffffff;
  border-bottom: 1px solid #eef2f7;
}

.modern-pos .card.modern-card .card-title {
  margin: 0;
  color: #0f172a;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 700;
}

.modern-pos .card.modern-card .card-title i {
  color: #2563eb !important;
}

.modern-pos .card.modern-card .card-body {
  padding: 22px 24px 24px;
}

.modern-pos .card.modern-card .card-footer {
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid #eef2f7;
}

.modern-pos .card.modern-card > .table-responsive,
.modern-pos .card.modern-card > .table-modern,
.modern-pos .card.modern-card > .table {
  margin: 0;
}

.modern-pos .card.modern-card > .table-responsive {
  padding: 14px 18px 18px;
}

.modern-pos .card.modern-card .card-body.p-0 > .table,
.modern-pos .card.modern-card .card-body.p-0 > .table-responsive {
  margin: 0;
}

/* Exact reference table dimensions */
.modern-pos .table-modern {
  width: 100%;
  min-width: 0;
  margin-bottom: 0;
  overflow: hidden;
  border: 1px solid #e5eaf2;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 14px;
  color: #334155;
}

.modern-pos .table-modern thead th {
  padding: 10px 9px;
  white-space: nowrap;
  vertical-align: middle;
  background: #f8fafc;
  color: #475569;
  border-top: 0;
  border-bottom: 1px solid #e5eaf2;
  font-size: 11px;
  line-height: 1.35;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modern-pos .table-modern tbody td,
.modern-pos .table-modern tfoot td,
.modern-pos .table-modern tfoot th {
  padding: 10px 9px;
  white-space: nowrap;
  vertical-align: middle;
  color: #334155;
  border-top: 0;
  border-bottom: 1px solid #eef2f7;
  font-size: 13px;
  line-height: 1.4;
}

.modern-pos .table-modern tbody tr:last-child td {
  border-bottom: 0;
}

.modern-pos .table-modern tbody tr:hover {
  background: #f8fafc;
}

.modern-pos .table-modern tfoot th,
.modern-pos .table-modern tfoot td {
  background: #f8fafc;
  color: #0f172a;
  font-weight: 700;
}

.modern-pos .table-modern small {
  color: #94a3b8;
  font-size: 12px;
}

/* Filter container follows the reference filter area */
.modern-pos .filter-bar {
  margin-bottom: 18px;
  padding: 18px 22px;
  background: #ffffff;
  border: 1px solid #e5eaf2;
  border-radius: 18px;
  box-shadow: var(--az-shadow-md);
}

.modern-pos .filter-bar .form-group {
  margin-bottom: 0;
}

/* Exact form typography and sizing */
.modern-pos label {
  margin-bottom: 7px;
  color: #0f172a;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
}

.modern-pos .form-control,
.modern-pos .custom-select,
.modern-pos .input-group-text {
  min-height: 42px;
  height: 42px;
  color: #334155;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background-color: #ffffff;
  box-shadow: none;
  font-size: 14px;
  font-weight: 400;
}

.modern-pos textarea.form-control {
  height: auto;
  min-height: 96px;
}

.modern-pos .form-control-sm,
.modern-pos .custom-select-sm {
  min-height: 34px;
  height: 34px;
  padding-top: 4px;
  padding-bottom: 4px;
  border-radius: 9px;
  font-size: 12px;
}

.modern-pos .form-control-lg {
  min-height: 48px;
  height: 48px;
  font-size: 15px;
}

.modern-pos .form-control:focus,
.modern-pos .custom-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.modern-pos .input-group > .form-control:not(:last-child),
.modern-pos .input-group > .custom-select:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.modern-pos .input-group > .input-group-append > .btn,
.modern-pos .input-group > .input-group-append > .input-group-text {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Button palette and dimensions from the reference */
.modern-pos .btn {
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1;
  font-weight: 600;
  box-shadow: none;
}

.modern-pos .btn-primary {
  color: #ffffff;
  border-color: #2563eb;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.modern-pos .btn-primary:hover,
.modern-pos .btn-primary:focus {
  color: #ffffff;
  border-color: #1d4ed8;
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.25);
}

.modern-pos .btn-light {
  color: #334155;
  background: #ffffff;
  border-color: #dbe3ef;
}

.modern-pos .btn-light:hover {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.modern-pos .btn-outline-primary,
.modern-pos .btn-soft-primary {
  color: #2563eb;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.modern-pos .btn-outline-primary:hover,
.modern-pos .btn-soft-primary:hover {
  color: #1d4ed8;
  background: #dbeafe;
  border-color: #93c5fd;
}

.modern-pos .btn-danger,
.modern-pos .btn-outline-danger:hover {
  color: #ffffff;
  background: #ef4444;
  border-color: #ef4444;
}

.modern-pos .btn-outline-danger {
  color: #dc2626;
  background: #fef2f2;
  border-color: #fecaca;
}

.modern-pos .btn-warning,
.modern-pos .btn-outline-warning:hover {
  color: #ffffff;
  background: #f59e0b;
  border-color: #f59e0b;
}

.modern-pos .btn-outline-warning {
  color: #b45309;
  background: #fffbeb;
  border-color: #fde68a;
}

.modern-pos .btn-sm {
  min-height: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 12px;
}

.modern-pos .btn-lg {
  min-height: 46px;
  height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  font-size: 14px;
}

.modern-pos .btn-block {
  display: flex;
  width: 100%;
}

.modern-pos .content-header .btn-primary {
  min-height: 40px;
  padding: 0 13px;
  border: 0;
  border-radius: 12px;
  font-size: 12px;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.28);
}

/* Badges/statuses */
.modern-pos .badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  font-weight: 600;
}

.modern-pos .badge-light {
  color: #475569;
  background: #f1f5f9;
}

.modern-pos .badge-info {
  color: #1d4ed8;
  background: #dbeafe;
}

/* Alerts follow the reference card language, without extra heavy shadows */
.modern-pos .modern-alert,
.modern-pos .alert {
  border-radius: 14px;
  font-size: 14px;
}

.modern-pos .modern-alert {
  border: 1px solid transparent;
  box-shadow: none;
}

/* Dashboard/report metric cards mapped to the reference stat cards */
.modern-pos .metric-card {
  position: relative;
  min-height: 145px;
  height: 100%;
  margin-bottom: 24px;
  padding: 22px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 18px;
  box-shadow: var(--az-shadow-md);
}

.modern-pos .metric-card::before {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  top: -42px;
  right: -42px;
  border-radius: 50%;
  background: #dbeafe;
  opacity: 0.55;
}

.modern-pos .metric-label {
  position: relative;
  z-index: 2;
  display: inline-block;
  margin-bottom: 10px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.modern-pos .metric-value {
  position: relative;
  z-index: 2;
  margin-top: 0;
  color: #0f172a;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
}

.modern-pos .metric-icon {
  position: absolute;
  z-index: 2;
  right: 20px;
  bottom: 20px;
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2563eb;
  background: #dbeafe;
  border-radius: 18px;
  font-size: 22px;
}

.modern-pos .row > [class*="col-"]:nth-child(2) .metric-card::before,
.modern-pos .row > [class*="col-"]:nth-child(2) .metric-icon {
  color: #16a34a;
  background: #dcfce7;
}

.modern-pos .row > [class*="col-"]:nth-child(3) .metric-card::before,
.modern-pos .row > [class*="col-"]:nth-child(3) .metric-icon {
  color: #f97316;
  background: #ffedd5;
}

.modern-pos .row > [class*="col-"]:nth-child(4) .metric-card::before,
.modern-pos .row > [class*="col-"]:nth-child(4) .metric-icon {
  color: #ef4444;
  background: #fee2e2;
}

/* Empty states in compact tables */
.modern-pos td .empty-state {
  margin: 10px;
}

/* Pagination */
.modern-pos .pagination {
  gap: 5px;
  margin: 16px 0 0;
}

.modern-pos .page-link {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  background: #ffffff;
  border: 1px solid #dbe3ef;
  border-radius: 10px !important;
  font-size: 13px;
  font-weight: 600;
}

.modern-pos .page-link:hover {
  color: #2563eb;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.modern-pos .page-item.active .page-link {
  color: #ffffff;
  background: #2563eb;
  border-color: #2563eb;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.modern-pos .page-item.disabled .page-link {
  color: #94a3b8;
  background: #f8fafc;
}

/* Modals */
.modern-pos .modal-content {
  overflow: hidden;
  border: 1px solid #e5eaf2;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}

.modern-pos .modal-header {
  padding: 18px 22px;
  background: #ffffff;
  border-bottom: 1px solid #eef2f7;
}

.modern-pos .modal-title {
  color: #0f172a;
  font-size: 18px;
  font-weight: 700;
}

.modern-pos .modal-body {
  padding: 22px;
}

.modern-pos .modal-footer {
  padding: 14px 22px;
  background: #f8fafc;
  border-top: 1px solid #eef2f7;
}

/* Detail pages */
.modern-pos .detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.modern-pos .detail-field {
  padding: 14px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
}

.modern-pos .detail-field small {
  display: block;
  color: #64748b;
  font-size: 11px;
  line-height: 1.35;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modern-pos .detail-field strong {
  display: block;
  margin-top: 5px;
  color: #0f172a;
  font-size: 14px;
  font-weight: 700;
}

/* POS checkout page, restyled with the same reference tokens */
.modern-pos .pos-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(340px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.modern-pos .pos-left,
.modern-pos .pos-right {
  min-width: 0;
}

.modern-pos .pos-right {
  position: sticky;
  top: 78px;
}

.modern-pos .product-search-wrap {
  position: relative;
}

.modern-pos .product-search-results {
  position: absolute;
  z-index: 1050;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  display: none;
  max-height: 340px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.12);
}

.modern-pos .product-result {
  padding: 11px 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  color: #334155;
  border-bottom: 1px solid #eef2f7;
  font-size: 13px;
}

.modern-pos .product-result:last-child {
  border-bottom: 0;
}

.modern-pos .product-result:hover {
  color: #1d4ed8;
  background: #eff6ff;
}

.modern-pos .cart-table input,
.modern-pos .cart-table select {
  min-width: 72px;
}

.modern-pos .cart-name {
  color: #0f172a;
  font-size: 13px;
  font-weight: 600;
}

.modern-pos .cart-meta,
.modern-pos .shortcut-hint {
  color: #94a3b8;
  font-size: 12px;
}

.modern-pos .payment-row {
  margin-bottom: 10px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
}

.modern-pos .summary-line {
  padding: 7px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #475569;
  font-size: 13px;
}

.modern-pos .summary-line.total {
  margin-top: 8px;
  padding-top: 12px;
  color: #0f172a;
  border-top: 2px dashed #dbe3ef;
  font-size: 18px;
  font-weight: 700;
}

.modern-pos .sticky-actions {
  position: sticky;
  bottom: 0;
  margin: 0 -24px -24px;
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid #eef2f7;
}

/* Receipt remains print-safe */
.receipt-paper {
  width: 80mm;
  margin: 0 auto;
  color: #000000;
  font-family: Arial, sans-serif;
  font-size: 12px;
}

.receipt-paper.receipt-58 {
  width: 58mm;
}

.receipt-center {
  text-align: center;
}

.receipt-line {
  margin: 8px 0;
  border-top: 1px dashed #000000;
}

.receipt-table {
  width: 100%;
  border-collapse: collapse;
}

.receipt-table td {
  padding: 2px 0;
  vertical-align: top;
}

.receipt-right {
  text-align: right;
}

@media (max-width: 1100px) {
  .modern-pos .pos-shell {
    grid-template-columns: 1fr;
  }

  .modern-pos .pos-right {
    position: static;
  }

  .modern-pos .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .modern-pos .content-header {
    padding: 20px 14px 0;
  }

  .modern-pos .modern-content {
    padding: 16px 14px 30px;
  }

  .modern-pos .content-header .modern-page-header h1,
  .modern-pos .page-title-modern {
    font-size: 24px;
  }

  .modern-pos .content-header .modern-page-header {
    align-items: flex-start;
    gap: 14px;
  }

  .modern-pos .filter-bar {
    padding: 16px;
  }

  .modern-pos .filter-bar .form-group {
    margin-bottom: 12px;
  }

  .modern-pos .card.modern-card .card-header,
  .modern-pos .card.modern-card .card-body,
  .modern-pos .card.modern-card .card-footer {
    padding-right: 16px;
    padding-left: 16px;
  }

  .modern-pos .card.modern-card > .table-responsive {
    padding-right: 14px;
    padding-left: 14px;
  }

  .modern-pos .metric-value {
    font-size: 25px;
  }
}

@media (max-width: 575px) {
  .modern-pos .content-header .modern-page-header {
    flex-direction: column;
  }

  .modern-pos .content-header .modern-page-header > *:last-child {
    width: 100%;
  }

  .modern-pos .content-header .modern-page-header > *:last-child .btn {
    width: 100%;
  }

  .modern-pos .detail-grid {
    grid-template-columns: 1fr;
  }

  .modern-pos .table-responsive {
    font-size: 13px;
  }
}

@media print {
  .no-print,
  .main-header,
  .main-sidebar,
  .main-footer,
  .content-header {
    display: none !important;
  }

  .content-wrapper {
    margin-left: 0 !important;
    background: #ffffff !important;
  }

  .receipt-paper {
    margin: 0;
  }

  .modern-pos .card.modern-card {
    border: 0;
    box-shadow: none;
  }
}

/* POST logout keeps the exact sidebar link appearance */
.modern-pos .main-sidebar .nav-sidebar form {
  width: 100%;
}

.modern-pos .main-sidebar .nav-sidebar form .nav-link {
  width: calc(100% - 8px);
  border: 0;
  background: transparent;
  text-align: left;
}

.modern-pos .main-sidebar .nav-sidebar form .nav-link:hover {
  background: #fef2f2;
}

.modern-pos .main-header form .logout-link {
  border: 1px solid #ffe4e6;
  background: #fff1f2;
  font-family: inherit;
}

/* =========================================================
   GLOBAL PRODUCT SEARCH DROPDOWN FIX — v1.0.5
   Product result lists are positioned outside their cards.
   The reference theme clips every card with overflow:hidden,
   so search cards must explicitly allow their dropdowns out.
   ========================================================= */
.modern-pos .card.modern-card.product-search-card {
  position: relative;
  z-index: 60;
  overflow: visible !important;
}

.modern-pos .card.modern-card.product-search-card > .card-body,
.modern-pos .card.modern-card.product-search-card form,
.modern-pos .card.modern-card.product-search-card .form-row,
.modern-pos .card.modern-card.product-search-card .form-group {
  overflow: visible !important;
}

.modern-pos .product-search-wrap {
  position: relative;
  z-index: 70;
}

.modern-pos .product-search-results {
  z-index: 2080;
  max-height: min(360px, 52vh);
  overscroll-behavior: contain;
}

/* Keep subsequent cards below the active search layer. */
.modern-pos .product-search-card ~ .card,
.modern-pos .pos-left > .card:not(.product-search-card) {
  position: relative;
  z-index: 1;
}

@media (max-width: 767.98px) {
  .modern-pos .product-search-results {
    right: 0;
    left: 0;
    max-height: 46vh;
  }
}

/* =========================================================
   PRODUCT SEARCH PORTAL — v1.0.6 definitive fix
   The result node is moved to document.body by layout/script.php.
   It no longer depends on any parent card overflow or z-index.
   ========================================================= */
.modern-pos > .product-search-results.product-search-portal,
body.modern-pos .product-search-results.product-search-portal {
  position: fixed !important;
  right: auto !important;
  margin: 0 !important;
  min-width: 220px;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  background: #ffffff !important;
  border: 1px solid #dbe3ef !important;
  border-radius: 12px !important;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.22) !important;
  z-index: 2147483000 !important;
}

body.modern-pos .product-search-results.product-search-portal.opens-up {
  transform-origin: bottom center;
}

body.modern-pos .product-search-results.product-search-portal .product-result {
  min-height: 58px;
  background: #ffffff;
}

body.modern-pos .product-search-results.product-search-portal .product-result:hover {
  background: #eff6ff;
}
