/* ==========================================================================
   XENTRA CORE — STANDARDIZED UI PRIMITIVES
   Shared component language for Desktop and Mobile (Owner, Merchant, POS)
   ========================================================================== */

/* 1. STANDARDIZED PAGE SHELL & HEADER */
.x-page-shell {
  width: 100%;
  box-sizing: border-box;
}

.x-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.x-page-header-start {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.x-page-header-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main, #0f172a);
  letter-spacing: -0.02em;
}

.x-page-header-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted, #64748b);
}

.x-page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 2. STANDARDIZED MODAL & BOTTOM SHEET */
.x-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.x-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.x-modal-container,
.x-modal-card {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96);
  transition: transform 0.2s ease;
  box-sizing: border-box;
}

.x-modal-backdrop.open .x-modal-container,
.x-modal-backdrop.open .x-modal-card {
  transform: scale(1);
}

.x-modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.x-modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.x-modal-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: #64748b;
}

.x-modal-close-btn {
  background: transparent;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: #64748b;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.x-modal-close-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.x-modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.x-modal-footer {
  padding: 14px 22px;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Mobile Adaptive Transform: Modal becomes Native Bottom Sheet */
@media (max-width: 768px) {
  .x-modal-backdrop {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .x-modal-container,
  .x-modal-card {
    max-width: 100% !important;
    width: 100% !important;
    max-height: min(90dvh, calc(100dvh - 20px)) !important;
    border-radius: 20px 20px 0 0 !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    margin: 0 !important;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .x-modal-backdrop.open .x-modal-container,
  .x-modal-backdrop.open .x-modal-card {
    transform: translateY(0);
  }

  .x-modal-handle {
    display: block !important;
    width: 42px !important;
    height: 5px !important;
    background: #cbd5e1 !important;
    border-radius: 999px !important;
    margin: 6px auto 14px auto !important;
    flex-shrink: 0 !important;
  }
}

/* 3. STANDARDIZED MOBILE CARD FEED */
.x-card-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.x-feed-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.x-feed-item:active {
  background: #f8fafc;
}

.x-feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.x-feed-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.x-feed-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #64748b;
  flex-wrap: wrap;
}

.x-feed-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px dashed #e2e8f0;
  margin-top: 2px;
}
