/* HYDRA Intelligent Premium Layer — adaptive workspace, insights, ambient UX, storefront emotion */

/* —— 1. Adaptive workspace width —— */
body.use-new-ui {
  --hydra-workspace-max: 1680px;
  --hydra-workspace-gutter: clamp(12px, 1.6vw, 24px);
}

body.use-new-ui.route-dashboard {
  --hydra-workspace-max: 1680px;
}

body.use-new-ui.route-orders {
  --hydra-workspace-max: 1920px;
}

body.use-new-ui.route-customers,
body.use-new-ui.route-storefront-inquiries,
body.use-new-ui.route-cod {
  --hydra-workspace-max: 1540px;
}

body.use-new-ui.route-settings {
  --hydra-workspace-max: 1320px;
}

body.use-new-ui.route-catalog {
  --hydra-workspace-max: 1780px;
}

@media (min-width: 769px) {
  body.use-new-ui #contentScroll .route-pages-host {
    max-width: var(--hydra-workspace-max);
    margin-inline: auto;
    width: 100%;
    padding-inline: var(--hydra-workspace-gutter);
    box-sizing: border-box;
  }
}

#hydraLandingRoot .hydra-mkt-main {
  --hydra-workspace-max: 1780px;
  max-width: var(--hydra-workspace-max);
  margin-inline: auto;
  width: 100%;
  padding-inline: clamp(12px, 2vw, 28px);
  box-sizing: border-box;
}

/* —— 1B. Focus mode — subtle dim, not heavy overlay —— */
@media (min-width: 769px) {
  body.use-new-ui.hydra-focus-mode #app .main-content::after {
    content: "";
    position: fixed;
    inset: 0;
    left: var(--sidebar-width, 248px);
    background: rgba(15, 23, 42, 0.04);
    pointer-events: none;
    z-index: 40;
    opacity: 1;
    transition: opacity 200ms ease-out;
  }

  body.use-new-ui.hydra-focus-mode.sidebar-collapsed #app .main-content::after {
    left: 82px;
  }

  body.use-new-ui.hydra-focus-mode #modal:not(.hidden) {
    --modal-backdrop: rgba(15, 23, 42, 0.22);
  }

  body.use-new-ui.hydra-focus-mode .command-palette-overlay {
    background: rgba(15, 23, 42, 0.18);
  }
}

/* —— 1C. Density-aware spacing (soft, not scale-only) —— */
body.use-new-ui.ui-density-compact {
  --hydra-density-table-py: 5px;
  --hydra-density-card-pad: 10px 12px;
  --hydra-density-toolbar-gap: 6px;
  --hydra-density-filter-gap: 6px;
}

body.use-new-ui.ui-density-compact .compact-table th,
body.use-new-ui.ui-density-compact .compact-table td {
  padding-block: var(--hydra-density-table-py, 5px);
}

body.use-new-ui.ui-density-compact .card,
body.use-new-ui.ui-density-compact .panel.section-block {
  padding: var(--hydra-density-card-pad, 10px 12px);
}

body.use-new-ui.ui-density-compact .toolbar,
body.use-new-ui.ui-density-compact .compact-toolbar {
  gap: var(--hydra-density-toolbar-gap, 6px);
}

body.use-new-ui.ui-density-compact .dashboard-kpi-grid {
  gap: 10px;
}

body.use-new-ui.ui-density-compact .sf-inq-filter-chips,
body.use-new-ui.ui-density-compact .chart-toggle-group {
  gap: var(--hydra-density-filter-gap, 6px);
}

body.use-new-ui.ui-density-compact .owner-insight-row {
  gap: 10px;
}

/* —— 2. Smart insight strip —— */
.hydra-smart-insight-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
}

.hydra-smart-insight {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  transition: border-color 180ms ease-out, background 180ms ease-out;
}

.hydra-smart-insight__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.85;
}

.hydra-smart-insight--info {
  color: #1e3a5f;
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.18);
}

.hydra-smart-insight--info .hydra-smart-insight__dot {
  background: #3b82f6;
}

.hydra-smart-insight--warn {
  color: #78350f;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.22);
}

.hydra-smart-insight--warn .hydra-smart-insight__dot {
  background: #d97706;
}

.hydra-smart-insight--good {
  color: #14532d;
  background: rgba(16, 185, 129, 0.09);
  border-color: rgba(16, 185, 129, 0.2);
}

.hydra-smart-insight--good .hydra-smart-insight__dot {
  background: #059669;
}

/* —— 3. Row hover quick actions —— */
.hydra-row-quick-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  opacity: 0;
  transform: translateY(2px);
  pointer-events: none;
  transition: opacity 180ms ease-out, transform 180ms ease-out;
}

.hydra-rqa-btn {
  appearance: none;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 160ms ease-out, border-color 160ms ease-out, color 160ms ease-out;
}

.hydra-rqa-btn:hover,
.hydra-rqa-btn:focus-visible {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.hydra-rqa-btn--primary {
  border-color: rgba(13, 148, 136, 0.35);
  color: #0f766e;
  background: rgba(13, 148, 136, 0.06);
}

@media (min-width: 769px) {
  tr[data-product-row]:hover .hydra-row-quick-actions,
  tr[data-product-row]:focus-within .hydra-row-quick-actions,
  tr[data-customer-row]:hover .hydra-row-quick-actions,
  tr[data-customer-row]:focus-within .hydra-row-quick-actions,
  tr.sf-inq-row:hover .hydra-inq-quick-actions,
  tr.sf-inq-row:focus-within .hydra-inq-quick-actions {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
}

@media (max-width: 768px) {
  .hydra-row-quick-actions,
  .hydra-inq-quick-actions {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}

.hydra-inq-quick-actions {
  display: inline-flex;
  gap: 4px;
  margin-right: 6px;
  vertical-align: middle;
}

/* —— 4. Ambient KPI & notifications —— */
@media (min-width: 769px) {
  body.use-new-ui .premium-kpi-card.kpi-ambient-trend-up .kpi-sparkline path {
    filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.35));
  }

  body.use-new-ui .premium-kpi-card.kpi-ambient-stock-warn {
    box-shadow: inset 3px 0 0 rgba(245, 158, 11, 0.55), 0 2px 12px rgba(245, 158, 11, 0.08);
  }

  @keyframes hydraKpiStockPulse {
    0%,
    100% {
      box-shadow: inset 3px 0 0 rgba(245, 158, 11, 0.45), 0 2px 12px rgba(245, 158, 11, 0.06);
    }
    50% {
      box-shadow: inset 3px 0 0 rgba(245, 158, 11, 0.7), 0 2px 14px rgba(245, 158, 11, 0.12);
    }
  }

  body.use-new-ui .premium-kpi-card.kpi-ambient-stock-warn {
    animation: hydraKpiStockPulse 3.2s ease-in-out infinite;
  }
}

tr.hydra-order-complete-flash {
  background: rgba(16, 185, 129, 0.1) !important;
  transition: background 500ms ease-out;
}

body.use-new-ui .notification-item--timeline.notification-item--sev-warning {
  border-left: 3px solid rgba(245, 158, 11, 0.55);
}

body.use-new-ui .notification-item--timeline.notification-item--sev-success {
  border-left: 3px solid rgba(16, 185, 129, 0.5);
}

body.use-new-ui .notification-item--timeline.notification-item--sev-info {
  border-left: 3px solid rgba(59, 130, 246, 0.45);
}

body.use-new-ui .notification-item--timeline .notification-timeline-icon {
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.6);
}

body.use-new-ui .notification-item--timeline.unread .notification-timeline-icon {
  filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.12));
}

/* —— 5. Storefront emotion —— */
#hydraLandingRoot .hydra-mkt-chip--low {
  color: #9a3412;
  background: rgba(251, 146, 60, 0.14);
  border: 1px solid rgba(251, 146, 60, 0.28);
}

#hydraLandingRoot .hydra-mkt-chip--scarcity {
  color: #7c2d12;
  background: rgba(254, 215, 170, 0.5);
  border: 1px solid rgba(234, 88, 12, 0.25);
  font-weight: 600;
}

#hydraLandingRoot .hydra-mkt-chip--bestseller {
  color: #1e3a5f;
  background: linear-gradient(180deg, #f8fafc 0%, #e8eef6 100%);
  border: 1px solid rgba(100, 116, 139, 0.28);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 10px;
}

#hydraLandingRoot .hydra-mkt-card--hot-subtle {
  position: relative;
}

@keyframes hydraMktHotPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(13, 148, 136, 0);
  }
  50% {
    box-shadow: 0 0 0 1px rgba(13, 148, 136, 0.12);
  }
}

#hydraLandingRoot .hydra-mkt-card--hot-subtle .hydra-mkt-card-media {
  animation: hydraMktHotPulse 4s ease-in-out infinite;
}

#hydraLandingRoot .hydra-mkt-card--grid.hydra-mkt-card--sp-rare {
  border: 1px solid rgba(124, 58, 237, 0.22);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06), inset 0 0 0 1px rgba(124, 58, 237, 0.06);
}

#hydraLandingRoot .hydra-mkt-chip--rarity.hydra-mkt-badge--sp {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.12) 0%, rgba(15, 23, 42, 0.04) 100%);
  border: 1px solid rgba(124, 58, 237, 0.28);
  color: #5b21b6;
  font-weight: 700;
}

#hydraLandingRoot .hydra-mkt-card--grid .hydra-mkt-card-media img {
  transition: transform 220ms ease-out;
}

#hydraLandingRoot .hydra-mkt-card--grid:hover .hydra-mkt-card-media img,
#hydraLandingRoot .hydra-mkt-card--grid:focus-within .hydra-mkt-card-media img {
  transform: translateY(-2px) scale(1.02);
}

#hydraLandingRoot .hydra-mkt-card--grid {
  transition: box-shadow 220ms ease-out, transform 220ms ease-out;
}

#hydraLandingRoot .hydra-mkt-card--grid:hover,
#hydraLandingRoot .hydra-mkt-card--grid:focus-within {
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.1);
}

#hydraLandingRoot .hydra-mkt-card--grid:hover .hydra-mkt-card-btn--primary,
#hydraLandingRoot .hydra-mkt-card--grid:focus-within .hydra-mkt-card-btn--primary {
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.22);
}

/* —— 6. Chart motion —— */
body.use-new-ui .kpi-sparkline path {
  stroke-dasharray: 240;
  stroke-dashoffset: 240;
  animation: hydraSparkDraw 220ms ease-out forwards;
}

@keyframes hydraSparkDraw {
  to {
    stroke-dashoffset: 0;
  }
}
