/* ==========================================================================
   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);
}

*, *::before, *::after {
  box-sizing: border-box;
}

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

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

/* Toast Container — sits above every modal layer */
.x-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 13000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.x-toast {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: xSharedSlideInRight 0.25s ease;
}

@keyframes xSharedSlideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@media (max-width: 768px) {
  .x-toast-container {
    left: 16px !important;
    right: 16px !important;
    bottom: 16px !important;
    max-width: calc(100vw - 32px) !important;
    box-sizing: border-box !important;
  }

  .x-toast {
    max-width: 100% !important;
    box-sizing: border-box !important;
    word-break: break-word !important;
    padding: 10px 14px !important;
    font-size: 13px !important;
  }
}

/* ==========================================================================
   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;
  }
}
