/* HYDRA Premium v2 — UX polish only (POS, dashboard KPI, storefront, notifications, branding) */

/* —— Boot splash —— */
.hydra-boot-splash {
  position: fixed;
  inset: 0;
  z-index: 120000;
  display: grid;
  place-items: center;
  background: linear-gradient(165deg, #f8fafc 0%, #e8eef6 48%, #f1f5f9 100%);
  transition: opacity 180ms ease-out, visibility 180ms ease-out;
}

.hydra-boot-splash--hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.hydra-boot-splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.hydra-boot-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 8px 20px rgba(15, 23, 42, 0.12));
}

.hydra-boot-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #0f172a;
}

.hydra-boot-shimmer {
  width: 120px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e2e8f0 0%, #0d9488 45%, #e2e8f0 90%);
  background-size: 200% 100%;
  animation: hydraBootShimmer 1.1s ease-in-out infinite;
}

@keyframes hydraBootShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* —— Error / offline states —— */
.hydra-route-error.hydra-error-page {
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

body.offline .sync-status.sync-offline {
  font-weight: 700;
}

/* —— Dashboard KPI v2 —— */
@media (min-width: 769px) {
  body.use-new-ui .dashboard-kpi-grid .premium-kpi-card--v2 {
    position: relative;
    overflow: visible;
  }

  body.use-new-ui .dashboard-kpi-grid .premium-kpi-card.kpi-tone-revenue,
  body.use-new-ui .dashboard-kpi-grid .premium-kpi-card.kpi-tone-profit,
  body.use-new-ui .dashboard-kpi-grid .premium-kpi-card.kpi-tone-cod {
    box-shadow: 0 4px 18px rgba(37, 99, 235, 0.1);
    border-color: rgba(59, 130, 246, 0.28);
  }

  body.use-new-ui .dashboard-kpi-grid .premium-kpi-card.kpi-tone-revenue .card-value {
    color: #0f172a;
  }

  body.use-new-ui .dashboard-kpi-grid .premium-kpi-card.kpi-tone-profit .card-value {
    color: #047857;
  }

  body.use-new-ui .dashboard-kpi-grid .premium-kpi-card.premium-kpi-card--secondary {
    box-shadow: none;
    border-color: #e2e8f0;
    background: #fafbfc;
  }

  body.use-new-ui .kpi-sparkline {
    display: block;
    width: 108px;
    height: 28px;
    flex-shrink: 0;
  }

  body.use-new-ui .kpi-sparkline-path {
    fill: none;
    stroke: #3b82f6;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  body.use-new-ui .premium-kpi-card.kpi-tone-profit .kpi-sparkline-path {
    stroke: #059669;
  }

  body.use-new-ui .kpi-sparkline--draw .kpi-sparkline-path {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    opacity: 0;
    animation: kpiSparkDraw 240ms ease-out forwards, kpiSparkFade 240ms ease-out forwards;
  }

  @keyframes kpiSparkDraw {
    to { stroke-dashoffset: 0; }
  }

  @keyframes kpiSparkFade {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  body.use-new-ui .kpi-insight-pop {
    position: absolute;
    left: 12px;
    right: 12px;
    top: calc(100% + 6px);
    z-index: 40;
    display: none;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.10);
    font-size: 11px;
    line-height: 1.45;
    color: #475569;
    pointer-events: none;
  }

  body.use-new-ui .premium-kpi-card--v2:hover .kpi-insight-pop,
  body.use-new-ui .premium-kpi-card--v2:focus-within .kpi-insight-pop {
    display: grid;
    gap: 3px;
  }

  body.use-new-ui .kpi-insight-row strong {
    color: #0f172a;
    font-weight: 700;
  }

  body.use-new-ui .kpi-insight-trend.trend-up strong,
  body.use-new-ui .kpi-insight-trend.trend-up {
    color: #047857;
  }

  body.use-new-ui .kpi-insight-trend.trend-down {
    color: #b45309;
  }
}

/* —— Notification timeline —— */
body.use-new-ui .notification-item--timeline {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 10px;
  transition: background-color 180ms ease-out;
}

body.use-new-ui .notification-timeline-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f1f5f9;
  font-size: 14px;
}

body.use-new-ui .notification-timeline-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 72px;
}

body.use-new-ui .notification-severity-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #64748b;
}

body.use-new-ui .notification-item.severity-warn .notification-severity-badge,
body.use-new-ui .notification-item.severity-warning .notification-severity-badge {
  background: #fffbeb;
  color: #92400e;
}

body.use-new-ui .notification-item.severity-danger .notification-severity-badge,
body.use-new-ui .notification-item.severity-critical .notification-severity-badge {
  background: #fef2f2;
  color: #991b1b;
}

body.use-new-ui .notification-item.severity-info .notification-severity-badge {
  background: #eff6ff;
  color: #1d4ed8;
}

body.use-new-ui .notification-item--timeline .notification-time {
  font-size: 10px;
  color: #94a3b8;
  white-space: nowrap;
}

body.use-new-ui .notification-item--timeline.unread {
  background: #f8fafc;
  border-left: 3px solid #3b82f6;
}

body.use-new-ui .notification-item--timeline .notification-item-actions {
  opacity: 0;
  transition: opacity 180ms ease-out;
}

body.use-new-ui .notification-item--timeline:hover .notification-item-actions,
body.use-new-ui .notification-item--timeline:focus-within .notification-item-actions {
  opacity: 1;
}

/* —— Storefront premium —— */
@media (min-width: 900px) {
  #hydraLandingRoot .hydra-mkt-card--grid {
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 180ms ease-out, box-shadow 180ms ease-out;
  }

  #hydraLandingRoot .hydra-mkt-card--grid:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.1);
  }

  #hydraLandingRoot .hydra-mkt-card--grid .hydra-mkt-card-media {
    overflow: hidden;
  }

  #hydraLandingRoot .hydra-mkt-card--grid .hydra-mkt-card-media img {
    transition: transform 180ms ease-out;
  }

  #hydraLandingRoot .hydra-mkt-card--grid:hover .hydra-mkt-card-media img {
    transform: scale(1.03);
  }

  #hydraLandingRoot .hydra-mkt-card--grid .hydra-mkt-card-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 118px;
  }

  #hydraLandingRoot .hydra-mkt-card--grid .hydra-mkt-card-name {
    font-weight: 600;
    line-height: 1.4;
  }

  #hydraLandingRoot .hydra-mkt-card--grid .hydra-mkt-card-meta,
  #hydraLandingRoot .hydra-mkt-card--grid .hydra-mkt-card-sub {
    color: #64748b;
    line-height: 1.35;
  }

  #hydraLandingRoot .hydra-mkt-card--grid .hydra-mkt-card-price {
    margin-top: auto;
    padding-top: 0.35rem;
    font-weight: 700;
    color: #0f766e;
  }

  #hydraLandingRoot .hydra-mkt-card--grid .hydra-mkt-card-actions {
    margin-top: 0.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  #hydraLandingRoot .hydra-mkt-card-btn.hydra-mkt-card-btn--primary {
    order: 2;
  }

  #hydraLandingRoot .hydra-mkt-card-btn.secondary {
    order: 1;
  }

  #hydraLandingRoot .hydra-mkt-widget-list {
    display: grid;
    gap: 6px;
  }

  #hydraLandingRoot .hydra-mkt-mini {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 6px 8px;
    border-radius: 10px;
    transition: background-color 120ms ease-out;
  }

  #hydraLandingRoot .hydra-mkt-mini:hover {
    background: #f8fafc;
  }

  #hydraLandingRoot .hydra-mkt-mini-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    overflow: hidden;
    background: #f1f5f9;
  }

  #hydraLandingRoot .hydra-mkt-mini-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  #hydraLandingRoot .hydra-mkt-mini-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  #hydraLandingRoot .hydra-mkt-mini-name {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #hydraLandingRoot .hydra-mkt-mini-price {
    font-size: 12px;
    font-weight: 700;
    color: #0f766e;
  }
}

/* —— POS modal v2 (desktop) —— */
@media (min-width: 1024px) {
  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-cart-zone {
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 42%) !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-global-search.pos-scan-focus input,
  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-product-search-row.pos-scan-focus input {
    border-color: #38bdf8 !important;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2) !important;
    outline: none !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-cart-row .oi-name {
    font-weight: 600 !important;
    color: #0f172a !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-cart-row .oi-profit.profit-positive {
    color: #047857 !important;
    font-weight: 700 !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .oi-stock-badge.warn {
    color: #92400e !important;
    background: #fffbeb !important;
    border: 1px solid #fde68a !important;
    font-weight: 600 !important;
    font-size: 10px !important;
    padding: 2px 6px !important;
    border-radius: 6px !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-cart-row .oi-del {
    opacity: 0;
    transition: opacity 180ms ease-out;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-cart-row:hover .oi-del,
  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-cart-row:focus-within .oi-del {
    opacity: 1;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-cart-row.row-added {
    animation: posRowFlash 240ms ease-out;
  }

  @keyframes posRowFlash {
    0% { background-color: rgba(16, 185, 129, 0.18); }
    100% { background-color: transparent; }
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-cart-zone {
    position: relative;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-mini-toast {
    position: absolute;
    right: 12px;
    top: 8px;
    z-index: 25;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #065f46;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 180ms ease-out, transform 180ms ease-out;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-mini-toast.is-show {
    opacity: 1;
    transform: translateY(0);
  }

  /* Dynamic density */
  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-density-spacious .pos-cart-row {
    min-height: 52px !important;
    padding: 10px 10px !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-density-spacious .pos-cart-row input {
    min-height: 38px !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-density-compact .pos-cart-row {
    min-height: 34px !important;
    padding: 4px 8px !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-density-compact .pos-cart-row input {
    min-height: 30px !important;
    font-size: 12px !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-density-compact .pos-cart-head {
    padding: 4px 8px !important;
    font-size: 9px !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-totals-card {
    background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%) !important;
    border: 1px solid #bbf7d0 !important;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.08) !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-totals-card .summary-value.profit-positive {
    color: #047857 !important;
    font-size: 13px !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-totals-card .summary-label {
    color: #64748b !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-modal-footer {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
    border-top: 1px solid #cbd5e1 !important;
    box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.08) !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-summary-strip #sumProfit.profit-positive {
    color: #047857 !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-summary-strip #sumRevenue {
    color: #0f172a !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-summary-strip #sumCost {
    color: #64748b !important;
    font-weight: 600 !important;
  }

  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-right {
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hydra-boot-shimmer,
  body.use-new-ui .kpi-sparkline--draw .kpi-sparkline-path,
  body.use-new-ui.route-orders #modal .modal-card.order-pos-modal .pos-cart-row.row-added,
  #hydraLandingRoot .hydra-mkt-card--grid,
  #hydraLandingRoot .hydra-mkt-card--grid .hydra-mkt-card-media img {
    animation: none !important;
    transition: none !important;
  }
}
