/* ==========================================================================
   XENTRA CORE — MERCHANT SHARED CSS
   Shared by: merchant-dashboard, owner-dashboard (and future surfaces).

   Contains ONLY cross-surface primitives:
   - Design tokens (:root)
   - Box-sizing reset
   - Font inheritance for form elements
   - Toast notification component
   - Action menu / popover component
   - Image crop editor modal component

   DO NOT add page-specific layout, sidebar, or domain-specific styles here.
   ========================================================================== */

:root {
  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --bg-app: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --primary-color: #b6ff00;
  --primary-text: #0f172a;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);

  /* Typography Scale Standard (Mobile-Native & Desktop Standard) */
  --font-size-display: 26px;
  --font-size-h1: 22px;
  --font-size-h2: 18px;
  --font-size-h3: 16px;
  --font-size-h4: 14.5px;
  --font-size-body: 13.5px;
  --font-size-body-sm: 12.5px;
  --font-size-caption: 11.5px;

  /* Font Weight Standard */
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;

  /* Line Height Standard */
  --line-height-tight: 1.18;
  --line-height-snug: 1.32;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.6;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

input, button, select, textarea, optgroup {
  font-family: inherit;
}

button, a, input, select, textarea, [role="button"], [tabindex] {
  -webkit-tap-highlight-color: transparent;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
[role="button"]:focus:not(:focus-visible) {
  outline: none;
}

/* ==========================================================================
   TOAST NOTIFICATION COMPONENT
   Used by showToast() in shared.js. Sits above every modal (z-index 13000).
   ========================================================================== */

/* Toast Container — sits above every modal layer (z-index 13000), centered on screen */
.x-toast-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 13000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  width: max-content;
}

.x-toast {
  background: #0f172a;
  color: #ffffff;
  padding: 14px 22px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.04);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-align: center;
  box-sizing: border-box;
  animation: xSharedToastPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  pointer-events: auto;
}

.x-toast.x-toast-error,
.x-toast.x-toast-danger {
  background: #fff0f2;
  color: #991b1b;
  border-color: #ffd4d8;
  box-shadow: 0 12px 32px rgba(225, 29, 72, 0.18), 0 2px 8px rgba(0, 0, 0, 0.04);
}

.x-toast.x-toast-success {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
  box-shadow: 0 12px 32px rgba(22, 101, 52, 0.15), 0 2px 8px rgba(0, 0, 0, 0.04);
}

.x-toast.x-toast-warning {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
  box-shadow: 0 12px 32px rgba(180, 83, 9, 0.15), 0 2px 8px rgba(0, 0, 0, 0.04);
}

.x-toast.x-toast-info {
  background: #f0f9ff;
  color: #075985;
  border-color: #bae6fd;
  box-shadow: 0 12px 32px rgba(14, 116, 144, 0.15), 0 2px 8px rgba(0, 0, 0, 0.04);
}

@keyframes xSharedToastPopIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

@media (max-width: 768px) {
  .x-toast-container {
    max-width: calc(100vw - 32px);
    width: max-content;
  }

  .x-toast {
    max-width: 100%;
    word-break: break-word;
    padding: 12px 18px;
    font-size: 13.5px;
    border-radius: 16px;
  }
}

/* ==========================================================================
   ACTION MENU / POPOVER COMPONENT (XentraActionMenu)
   Reusable overflow action menu ("⋯") with keyboard navigation.
   ========================================================================== */

/* Overflow trigger button (`⋯`) */
.x-action-menu-trigger {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.x-action-menu-trigger:hover,
.x-action-menu-trigger:focus-visible,
.x-action-menu-trigger[aria-expanded="true"] {
  background: #f1f5f9;
  color: var(--text-main);
  border-color: #e2e8f0;
}

.x-action-menu-trigger:active {
  transform: scale(0.92);
}

.x-action-menu-trigger svg {
  display: block;
  pointer-events: none;
}

/* Fixed positioning popover menu attached to body */
.x-action-popover-menu {
  position: fixed;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
  padding: 6px;
  min-width: 180px;
  max-width: 260px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transform: scale(0.96);
  transform-origin: top right;
  transition: opacity 0.15s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  visibility: hidden;
}

.x-action-popover-menu.x-popover-open {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  visibility: visible;
}

/* Backdrop for closing menu anywhere */
.x-action-popover-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: transparent;
  display: none;
}

.x-action-popover-backdrop.x-popover-open {
  display: block;
}

/* Menu items inside popover */
.x-action-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #334155;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  transition: background-color 0.12s ease, color 0.12s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.x-action-menu-item:hover,
.x-action-menu-item:focus-visible {
  background: #f1f5f9;
  color: #0f172a;
}

.x-action-menu-item:active {
  background: #e2e8f0;
}

.x-action-menu-item.is-destructive {
  color: #dc2626;
}

.x-action-menu-item.is-destructive:hover,
.x-action-menu-item.is-destructive:focus-visible {
  background: #fef2f2;
  color: #b91c1c;
}

.x-action-menu-item.is-destructive:active {
  background: #fee2e2;
}

.x-action-menu-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: inherit;
}

.x-action-menu-item-icon svg {
  display: block;
  stroke: currentColor;
}

.x-action-menu-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 4px -2px;
}

@media (max-width: 768px) {
  .x-action-popover-menu {
    min-width: 190px;
  }
}

@media (max-width: 480px) {
  .x-action-menu-trigger {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
  }
}

/* ==========================================================================
   IMAGE CROP EDITOR COMPONENT (XentraCropEditor)
   Reusable modal-based image crop / zoom editor (Media System M2).
   ========================================================================== */

.x-crop-modal-card {
  max-width: min(580px, calc(100vw - 24px));
  width: 100%;
  max-height: min(94vh, calc(100dvh - 24px));
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  user-select: none;
}

.x-crop-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: #0f172a;
  overflow: hidden;
  position: relative;
}

.x-crop-viewport {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: 320px;
  max-height: 52vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #020617;
  border-radius: 8px;
  overflow: hidden;
  touch-action: none; /* prevent page scroll during touch drag */
  cursor: grab;
}

.x-crop-viewport:active {
  cursor: grabbing;
}

.x-crop-canvas-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
}

.x-crop-image {
  display: block;
  max-width: none;
  pointer-events: none;
  will-change: transform;
}

/* Fixed crop framing overlay */
.x-crop-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.75);
  border: 2px solid var(--primary-color, #b6ff00);
  border-radius: 4px;
  transition: border-color 0.2s;
}

.x-crop-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  pointer-events: none;
}

.x-crop-grid-line-v {
  border-right: 1px dashed rgba(255, 255, 255, 0.35);
}

.x-crop-grid-line-h {
  border-bottom: 1px dashed rgba(255, 255, 255, 0.35);
}

.x-crop-toolbar {
  width: 100%;
  background: #1e293b;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-sizing: border-box;
}

.x-crop-slider-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.x-crop-slider-label {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.x-crop-slider {
  flex: 1;
  accent-color: var(--primary-color, #b6ff00);
  cursor: pointer;
}

.x-crop-tool-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.x-crop-tool-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.x-crop-info-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #94a3b8;
  padding: 0 4px;
  box-sizing: border-box;
}

.x-crop-modal-card .x-modal-footer {
  margin-top: 0;
  padding: 14px 20px;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 480px) {
  .x-crop-modal-card {
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }
  .x-crop-body {
    padding: 10px;
    gap: 10px;
  }
  .x-crop-viewport {
    height: 240px;
    max-height: 42vh;
  }
  .x-crop-toolbar {
    padding: 8px 10px;
    flex-wrap: wrap;
  }
  .x-crop-slider-group {
    width: 100%;
    order: 1;
  }
  .x-crop-tool-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
}

/* Modal and Button Primitives for Shared Components */
.x-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 12010;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.x-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  background: #ffffff;
  box-sizing: border-box;
  width: 100%;
}

.x-modal-header h3 {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main, #0f172a);
  margin: 0;
}

.x-modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.x-modal-close:hover {
  background: #f1f5f9;
  color: var(--text-main, #0f172a);
}

.x-btn-primary {
  background: #0f172a;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-sm, 8px);
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.x-btn-primary:hover {
  background: #1e293b;
}

.x-btn-secondary {
  background: #f1f5f9;
  color: #334155;
  padding: 10px 16px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border-color, #e2e8f0);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.x-btn-secondary:hover {
  background: #e2e8f0;
}


/* ==========================================================================
   MASTER MENU — INLINE DEPENDENCY CREATION
   ========================================================================== */
.x-master-inline-select-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.x-master-inline-select-row .x-input,
.x-master-inline-select-row .x-occ-dropdown,
.x-master-inline-select-row .x-owner-select-dropdown {
  flex: 1 1 auto;
  min-width: 0;
}

.x-master-inline-link {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-sm, 8px);
  background: transparent;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.x-master-inline-link svg {
  display: block;
  width: 14px;
  height: 14px;
  margin: auto;
  pointer-events: none;
}

.x-master-inline-link:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
}

.x-master-inline-link:active {
  transform: scale(0.95);
  background: #f1f5f9;
}

.x-master-inline-link:focus-visible {
  outline: 2px solid #94a3b8;
  outline-offset: 2px;
}

.x-master-inline-link:disabled {
  background: transparent;
  border-color: #f1f5f9;
  color: #cbd5e1;
  cursor: not-allowed;
  transform: none;
  opacity: 0.5;
}

.x-master-inline-dependency-hint,
.x-master-inline-created {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.45;
}

.x-master-inline-dependency-hint {
  color: var(--text-muted, #64748b);
}

.x-master-inline-created {
  color: #15803d;
  font-weight: 700;
}

.x-master-inline-sheet-content {
  width: 100%;
}

.x-master-inline-sheet {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 4px 0 0;
}

.x-master-inline-sheet-intro strong {
  display: block;
  color: var(--text-main, #0f172a);
  font-size: 14px;
  font-weight: 800;
}

.x-master-inline-sheet-intro p {
  margin: 4px 0 0;
  color: var(--text-muted, #64748b);
  font-size: 12px;
  line-height: 1.5;
}

.x-master-inline-sheet-fields {
  display: grid;
  gap: 12px;
}

.x-master-inline-field label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-main, #0f172a);
  font-size: 12px;
  font-weight: 700;
}

.x-master-inline-field small {
  display: block;
  margin-top: 5px;
  color: var(--text-muted, #64748b);
  font-size: 11px;
  line-height: 1.45;
}

.x-master-inline-optional {
  margin-left: 4px;
  color: #94a3b8;
  font-weight: 500;
}

.x-master-inline-sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

@media (max-width: 480px) {
  .x-master-inline-select-row {
    align-items: center;
  }

  .x-master-inline-sheet-actions {
    position: sticky;
    bottom: 0;
    margin: 0 -16px -16px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: #ffffff;
    border-top: 1px solid var(--border-color, #e2e8f0);
  }
}

/* ==========================================================================
   PASSWORD INPUT WITH VISIBILITY TOGGLE (EYE ICON)
   ========================================================================== */
.x-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.x-password-wrap .x-input {
  width: 100%;
  padding-right: 44px !important;
}

.x-btn-toggle-pw {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
  z-index: 2;
  user-select: none;
}

.x-btn-toggle-pw:hover {
  color: var(--text-main, #0f172a);
  background: rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   CANONICAL PAGE TRANSITION & BOTTOM BAR ANIMATION PRIMITIVES
   Shared across all Xentra mobile/web apps (Owner, Merchant, POS, Customer).
   Outer .x-tab-content sections must NEVER use transform/animation.
   ========================================================================== */
@keyframes xentraSlidePushIn {
  0% {
    opacity: 0.96;
    transform: translate3d(14px, 0, 0);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes xentraSlidePopIn {
  0% {
    opacity: 0.96;
    transform: translate3d(-12px, 0, 0);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes xentraTabFadeIn {
  0% {
    opacity: 0.96;
    transform: none;
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes xentraBottomBarEaseUp {
  0% {
    opacity: 0;
    transform: translate3d(0, 100%, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.x-page-anim-push,
.x-owner-page-anim-push {
  animation: xentraSlidePushIn 0.18s cubic-bezier(0.22, 1, 0.36, 1) both;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.x-page-anim-pop,
.x-owner-page-anim-pop {
  animation: xentraSlidePopIn 0.16s cubic-bezier(0.22, 1, 0.36, 1) both;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.x-page-anim-tab,
.x-owner-page-anim-tab {
  animation: xentraTabFadeIn 0.14s cubic-bezier(0.22, 1, 0.36, 1) both;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.x-bottom-bar-ease-up,
.x-owner-bottom-bar-ease-up {
  animation: xentraBottomBarEaseUp 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

