/**
 * HOTFIX SPRINT RC2 — LISTING MANAGEMENT / ACTION BAR / DELETE DIALOG
 * HOTFIX 04 / 05 / 06 / 09 — Responsive Listing Management Recovery
 *
 * PRESENTATION LAYER ONLY. No Business Logic / Database / REST changes.
 *
 * ACTION BAR RULES (HOTFIX 05):
 *   Desktop (≥ 769px): Xem · Sửa · Gia hạn · Sao chép · Hoàn thành · Xóa
 *   Mobile   (< 769px): Xem · Sửa · … (opens action menu)
 *                       → Gia hạn · Sao chép · Hoàn thành · Xóa tin
 *   NEVER show 6 buttons on a 390px viewport.
 *
 * DELETE RULES (HOTFIX 06):
 *   Delete always uses a Confirmation Dialog (never native confirm()).
 *   Desktop: inline dialog overlay.
 *   Mobile:  bottom-sheet action menu with a danger "Xóa tin" item.
 *
 * RESPONSIVE RULES (HOTFIX 04 / 09):
 *   Table never breaks: horizontal scroll on small screens.
 *   Cards never overflow: all action rows constrained inside card.
 *
 * @package XOS\Presentation\Styles
 * @version 1.0.0 — HOTFIX SPRINT RC2
 * @since   HOTFIX SPRINT RC2
 */

/* ===========================================================
   1. ACTION BAR — DESKTOP: show all 6; MOBILE: 2 + "…"
   =========================================================== */

/* Desktop: the full wrap row (Xem, Sửa, Gia hạn, Sao chép,
   Hoàn thành, Xóa) is visible ONLY ≥ 769px. */
.mp-actions-row--desktop {
  display: none;
}

@media (min-width: 769px) {
  .mp-actions-row--desktop {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .mp-actions-row--desktop .mp-btn {
    flex: 1 1 auto;
    min-width: 96px;
  }
}

/* Mobile: only Xem + Sửa + "…" are visible. The "…" opens the
   bottom-sheet action menu. */
.mp-actions-row--mobile {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
}

.mp-actions-row--mobile .mp-btn {
  flex: 1 1 0;
}

.mp-actions-row--mobile .mp-btn--more {
  flex: 0 0 auto;
  min-width: 48px;
  max-width: 48px;
  font-weight: 800;
  font-size: 1.125rem;
  line-height: 1;
}

@media (min-width: 769px) {
  .mp-actions-row--mobile {
    display: none !important;
  }
}

/* ===========================================================
   2. ACTION BOTTOM SHEET — mobile action menu
   =========================================================== */

.rc2-action-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: #FFFFFF;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 260ms cubic-bezier(0.2, 0, 0, 1);
  visibility: hidden;
}

.rc2-action-sheet.is-open {
  transform: translateY(0);
  visibility: visible;
}

.rc2-action-sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #D1D5DB;
  margin: 8px auto 4px;
}

.rc2-action-sheet-title {
  padding: 8px 16px 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6B7280;
}

.rc2-action-sheet-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rc2-action-sheet-item {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
  padding: 14px 16px;
  border: none;
  background: transparent;
  font-size: 0.9375rem;
  font-family: inherit;
  color: #111827;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.rc2-action-sheet-item:active {
  background: #F3F4F6;
}

.rc2-action-sheet-item--danger {
  color: #DC2626;
  font-weight: 700;
}

.rc2-action-sheet-cancel {
  margin: 4px 8px 0;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: #F3F4F6;
  font-size: 0.9375rem;
  font-weight: 700;
  font-family: inherit;
  color: #374151;
  cursor: pointer;
  width: calc(100% - 16px);
}

.rc2-action-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.rc2-action-sheet-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ===========================================================
   3. DELETE CONFIRMATION DIALOG — HOTFIX 06
   =========================================================== */

.rc2-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.rc2-confirm-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.rc2-confirm-dialog {
  width: 100%;
  max-width: 340px;
  background: #FFFFFF;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  padding: 24px 20px 16px;
  transform: scale(0.92);
  transition: transform 220ms cubic-bezier(0.2, 0, 0, 1);
  text-align: center;
}

.rc2-confirm-backdrop.is-open .rc2-confirm-dialog {
  transform: scale(1);
}

.rc2-confirm-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #FEE2E2;
  font-size: 26px;
}

.rc2-confirm-title {
  margin: 0 0 8px;
  font-size: 1.125rem;
  font-weight: 800;
  color: #111827;
}

.rc2-confirm-text {
  margin: 0 0 20px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #4B5563;
}

.rc2-confirm-actions {
  display: flex;
  gap: 10px;
}

.rc2-confirm-actions .rc2-btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  border: none;
  font-size: 0.875rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.rc2-confirm-actions .rc2-btn--cancel {
  background: #F3F4F6;
  color: #374151;
}

.rc2-confirm-actions .rc2-btn--delete {
  background: #DC2626;
  color: #FFFFFF;
}

/* ===========================================================
   4. TABLE RECOVERY — HOTFIX 04 (never breaks on 390/412/430)
   =========================================================== */

.listings-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid #E5E7EB;
  background: #FFFFFF;
}

.listings-table {
  min-width: 640px;
  width: 100%;
  border-collapse: collapse;
}

.listings-table th,
.listings-table td {
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  font-size: 0.8125rem;
}

.listings-table th {
  background: #F9FAFB;
  color: #374151;
  font-weight: 700;
  border-bottom: 1px solid #E5E7EB;
}

.listings-table td {
  border-bottom: 1px solid #F3F4F6;
}

.listings-table .actions-cell {
  white-space: nowrap;
}

/* ===========================================================
   5. FILTERS — never overlap on 390px (HOTFIX 04)
   =========================================================== */

.listings-filters .filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 767px) {
  .listings-filters .filter-form > * {
    flex: 1 1 45%;
    min-width: 0 !important;
  }

  .listings-filters .filter-form input[name="search"] {
    flex: 1 1 100% !important;
  }

  .listings-filters .filter-form .xos-btn {
    flex: 1 1 auto !important;
  }
}

/* ===========================================================
   6. STATS BAR — wraps cleanly on small screens (HOTFIX 04)
   =========================================================== */

@media (max-width: 479px) {
  .listing-stats-bar {
    gap: 6px !important;
  }

  .listing-stats-bar span {
    font-size: 0.75rem !important;
    white-space: nowrap;
  }
}

/* ===========================================================
   7. REDUCED MOTION
   =========================================================== */

@media (prefers-reduced-motion: reduce) {
  .rc2-action-sheet,
  .rc2-action-sheet-backdrop,
  .rc2-confirm-backdrop,
  .rc2-confirm-dialog {
    transition: none !important;
  }
}