/* StockFlows Demo — Exact match to Shopify app */

/* Override StockFlows custom variables to match Polaris */
:root {
  --sf-bg: rgba(241, 241, 241, 1) !important;
  --sf-bg-dark: #1f2225 !important;
  --sf-text: #303030 !important;
  --sf-text-dim: #6d7175 !important;
  --sf-border: #e3e3e3 !important;
  --sf-brand: #303030 !important;
  --sf-critical: #e51c00 !important;
  --sf-warning: #ffb800 !important;
  --sf-success: #29845a !important;
}

/* Shell Layout */
.demo-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar — exact match to Polaris Navigation */
.demo-sidebar {
  width: 240px;
  background: transparent;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* Navigation — exact match to Polaris */
.demo-nav {
  flex: 1;
  padding: var(--p-space-100) 0;
  overflow-y: auto;
}

.demo-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: var(--p-color-text);
  text-decoration: none;
  font-size: var(--p-font-size-350);
  font-weight: var(--p-font-weight-regular);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.demo-nav-item:hover {
  background: var(--p-color-nav-bg-surface-hover);
}

.demo-nav-item.active {
  font-weight: var(--p-font-weight-bold);
  background: var(--p-color-nav-bg-surface-active);
  border-left-color: var(--p-color-border-brand);
}

.demo-nav-item .material-symbols-outlined {
  font-size: 20px;
  color: var(--p-color-icon-secondary);
}

.demo-nav-item.active .material-symbols-outlined {
  color: var(--p-color-icon);
}

/* Sidebar Footer */
.demo-sidebar-footer {
  padding: var(--p-space-100) 20px;
  border-top: var(--p-border-width-025) solid var(--p-color-border);
}

.demo-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--p-color-bg-fill-success);
  color: var(--p-color-text-success-on-bg-fill);
  font-size: 11px;
  font-weight: var(--p-font-weight-semibold);
  border-radius: var(--p-border-radius-100);
  margin-bottom: 8px;
}

.demo-back-link {
  display: block;
  color: var(--p-color-text-secondary);
  text-decoration: none;
  font-size: 12px;
}

.demo-back-link:hover {
  color: var(--p-color-text);
}

/* Main Content — matches Polaris body background */
.demo-main {
  flex: 1;
  overflow-y: auto;
  background: #f1f2f4;
  padding: var(--p-space-400) var(--p-space-400);
}

/* Pages */
.demo-page { display: none; }
.demo-page.active { display: block; }

/* Page Headers — Polaris Page component style */
.demo-header {
  margin-bottom: var(--p-space-400);
}

.demo-header h1 {
  font-size: var(--p-font-size-750);
  font-weight: 400;
  font-family: "Instrument Serif", Georgia, "Times New Roman", serif;
  color: var(--p-color-text);
  margin-bottom: 2px;
}

.demo-subtitle {
  color: var(--p-color-text-secondary);
  font-size: var(--p-font-size-300);
}

.demo-header-actions {
  display: flex;
  gap: var(--p-space-200);
  margin-top: var(--p-space-200);
}

/* Stats Cards — Polaris Card style */
.demo-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--p-space-200);
  margin-bottom: var(--p-space-400);
}

.demo-stat-card {
  background: var(--p-color-bg-surface);
  border-radius: var(--p-border-radius-200);
  padding: var(--p-space-400);
  box-shadow: var(--p-shadow-100);
  border: var(--p-border-width-025) solid var(--p-color-border);
}

.demo-stat-label {
  font-size: var(--p-font-size-300);
  font-weight: var(--p-font-weight-semibold);
  color: var(--p-color-text-secondary);
  margin-bottom: var(--p-space-100);
}

.demo-stat-value {
  font-size: var(--p-font-size-800);
  font-weight: var(--p-font-weight-bold);
  color: var(--p-color-text);
  line-height: 1.2;
}

.demo-stat-value.green { color: var(--p-color-text-success); }
.demo-stat-value.red { color: var(--p-color-text-critical); }
.demo-stat-value.blue { color: var(--p-color-text-emphasis); }

/* Cards — Polaris Card component */
.demo-card {
  background: var(--p-color-bg-surface);
  border-radius: var(--p-border-radius-200);
  padding: var(--p-space-400);
  box-shadow: var(--p-shadow-100);
  border: var(--p-border-width-025) solid var(--p-color-border);
}

.demo-card h3 {
  font-size: var(--p-font-size-400);
  font-weight: var(--p-font-weight-semibold);
  color: var(--p-color-text);
  margin-bottom: var(--p-space-300);
}

/* Grid */
.demo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--p-space-400);
}

/* Tables */
.demo-table-wrap {
  overflow-x: auto;
}

.demo-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--p-color-bg-surface);
  border: var(--p-border-width-025) solid var(--p-color-border);
  border-radius: var(--p-border-radius-200);
  overflow: hidden;
}

.demo-table th {
  padding: var(--p-space-200);
  text-align: left;
  font-size: var(--p-font-size-275);
  font-weight: var(--p-font-weight-semibold);
  color: var(--p-color-text-secondary);
  background: var(--p-color-bg);
  border-bottom: var(--p-border-width-025) solid var(--p-color-border);
}

.demo-table td {
  padding: var(--p-space-200);
  font-size: var(--p-font-size-300);
  border-bottom: var(--p-border-width-025) solid var(--p-color-border);
  color: var(--p-color-text);
}

.demo-table tbody tr:hover {
  background: var(--p-color-bg-surface-hover);
}

/* Status Badges — Polaris Badge */
.demo-status {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: var(--p-font-weight-medium);
  border-radius: var(--p-border-radius-200);
}

.demo-status.in-stock {
  background: var(--p-color-bg-fill-success);
  color: var(--p-color-text-success-on-bg-fill);
}

.demo-status.low-stock {
  background: var(--p-color-bg-fill-warning);
  color: var(--p-color-text-warning-on-bg-fill);
}

.demo-status.out-of-stock {
  background: var(--p-color-bg-fill-critical);
  color: var(--p-color-text-critical-on-bg-fill);
}

.demo-status.draft {
  background: var(--p-color-bg-fill-tertiary);
  color: var(--p-color-text-secondary);
}

.demo-status.sent {
  background: var(--p-color-bg-fill-info);
  color: var(--p-color-text-info-on-bg-fill);
}

.demo-status.partial {
  background: var(--p-color-bg-fill-warning);
  color: var(--p-color-text-warning-on-bg-fill);
}

.demo-status.received {
  background: var(--p-color-bg-fill-success);
  color: var(--p-color-text-success-on-bg-fill);
}

/* Buttons — Polaris Button */
.demo-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--p-space-150) var(--p-space-400);
  font-size: var(--p-font-size-300);
  font-weight: var(--p-font-weight-medium);
  font-family: var(--p-font-family-sans);
  cursor: pointer;
  border: var(--p-border-width-025) solid var(--p-color-border);
  border-radius: var(--p-border-radius-100);
  background: var(--p-color-bg-surface);
  color: var(--p-color-text);
  transition: all 0.15s;
  line-height: 1.4;
}

.demo-btn:hover {
  background: var(--p-color-bg-surface-hover);
  border-color: var(--p-color-border-hover);
}

.demo-btn-primary {
  background: var(--p-color-bg-fill-brand);
  color: var(--p-color-text-brand-on-bg-fill);
  border-color: var(--p-color-border-brand);
}

.demo-btn-primary:hover {
  background: var(--p-color-bg-fill-brand-hover);
}

/* Inputs — Polaris TextField */
.demo-search,
.demo-select {
  padding: var(--p-space-150) var(--p-space-200);
  font-size: var(--p-font-size-300);
  font-family: var(--p-font-family-sans);
  border: var(--p-border-width-025) solid var(--p-color-input-border);
  border-radius: var(--p-border-radius-100);
  background: var(--p-color-input-bg-surface);
  color: var(--p-color-text);
  line-height: 1.4;
}

.demo-search:focus,
.demo-select:focus {
  outline: none;
  border-color: var(--p-color-border-focus);
  box-shadow: 0 0 0 1px var(--p-color-border-focus);
}

.demo-search { width: 220px; }

/* Alert Items */
.demo-alert-item {
  display: flex;
  align-items: center;
  gap: var(--p-space-200);
  padding: var(--p-space-200) 0;
  border-bottom: var(--p-border-width-025) solid var(--p-color-border);
}

.demo-alert-item:last-child { border-bottom: none; }

.demo-alert-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.demo-alert-dot.critical { background: var(--p-color-icon-critical); }
.demo-alert-dot.warning { background: var(--p-color-icon-warning); }
.demo-alert-dot.info { background: var(--p-color-icon-info); }

.demo-alert-text { flex: 1; font-size: var(--p-font-size-300); }
.demo-alert-qty { font-size: var(--p-font-size-275); color: var(--p-color-text-secondary); }

/* Activity Items */
.demo-activity-item {
  display: flex;
  align-items: center;
  gap: var(--p-space-200);
  padding: var(--p-space-200) 0;
  border-bottom: var(--p-border-width-025) solid var(--p-color-border);
}

.demo-activity-item:last-child { border-bottom: none; }

.demo-activity-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--p-color-bg-fill-tertiary);
  border-radius: var(--p-border-radius-100);
  flex-shrink: 0;
}

.demo-activity-icon .material-symbols-outlined {
  font-size: 18px;
  color: var(--p-color-icon-secondary);
}

.demo-activity-text { flex: 1; font-size: var(--p-font-size-300); }
.demo-activity-time { font-size: var(--p-font-size-275); color: var(--p-color-text-secondary); }

/* Forecast Cards */
.demo-forecast-card {
  background: var(--p-color-bg-surface);
  border-radius: var(--p-border-radius-200);
  padding: var(--p-space-400);
  box-shadow: var(--p-shadow-100);
  border: var(--p-border-width-025) solid var(--p-color-border);
}

.demo-forecast-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--p-space-300);
}

.demo-forecast-product { font-weight: var(--p-font-weight-semibold); font-size: var(--p-font-size-300); }

.demo-forecast-model {
  font-size: 11px;
  color: var(--p-color-text-secondary);
  font-weight: var(--p-font-weight-medium);
}

.demo-forecast-chart {
  height: 60px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  margin-bottom: var(--p-space-300);
}

.demo-forecast-bar {
  flex: 1;
  background: var(--p-color-bg-fill-brand);
  opacity: 0.3;
  border-radius: var(--p-border-radius-100) var(--p-border-radius-100) 0 0;
}

.demo-forecast-bar.predicted { opacity: 0.7; }
.demo-forecast-bar:hover { opacity: 1; }

.demo-forecast-stats {
  display: flex;
  gap: var(--p-space-400);
  font-size: var(--p-font-size-275);
  color: var(--p-color-text-secondary);
}

/* Report Cards */
.demo-report-row {
  display: flex;
  justify-content: space-between;
  padding: var(--p-space-200) 0;
  border-bottom: var(--p-border-width-025) solid var(--p-color-border);
  font-size: var(--p-font-size-300);
}

.demo-report-row:last-child { border-bottom: none; }
.demo-report-total { font-weight: var(--p-font-weight-semibold); }

/* Settings Page */
.demo-settings-group {
  display: flex;
  flex-direction: column;
}

.demo-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--p-space-300) 0;
  border-bottom: var(--p-border-width-025) solid var(--p-color-border);
}

.demo-setting-row:last-child { border-bottom: none; }

.demo-setting-label {
  font-size: var(--p-font-size-300);
  font-weight: var(--p-font-weight-medium);
  color: var(--p-color-text);
}

.demo-input {
  padding: var(--p-space-150) var(--p-space-200);
  font-size: var(--p-font-size-300);
  font-family: var(--p-font-family-sans);
  border: var(--p-border-width-025) solid var(--p-color-input-border);
  border-radius: var(--p-border-radius-100);
  background: var(--p-color-input-bg-surface);
  color: var(--p-color-text);
}

.demo-input:focus {
  outline: none;
  border-color: var(--p-color-border-focus);
  box-shadow: 0 0 0 1px var(--p-color-border-focus);
}

.demo-input-sm { width: 80px; text-align: right; }

/* Toggle Switch — Polaris Switch style */
.demo-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.demo-toggle input { opacity: 0; width: 0; height: 0; }

.demo-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--p-color-bg-fill-tertiary);
  transition: 0.2s;
  border-radius: 10px;
}

.demo-toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: var(--p-shadow-100);
}

.demo-toggle input:checked + .demo-toggle-slider { background: var(--p-color-bg-fill-success); }
.demo-toggle input:checked + .demo-toggle-slider:before { transform: translateX(16px); }

/* Tour Overlay */
.tour-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.tour-backdrop { position: absolute; inset: 0; background: var(--p-color-backdrop-bg); }
.tour-tooltip { position: relative; background: var(--p-color-bg-surface); border: var(--p-border-width-025) solid var(--p-color-border); border-radius: var(--p-border-radius-200); padding: var(--p-space-600); max-width: 400px; z-index: 1001; box-shadow: var(--p-shadow-400); }
.tour-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--p-space-300); }
.tour-step { font-size: var(--p-font-size-275); font-weight: var(--p-font-weight-medium); color: var(--p-color-text-secondary); }
.tour-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--p-color-text-secondary); padding: 0; line-height: 1; }
.tour-close:hover { color: var(--p-color-text); }
.tour-tooltip h3 { font-size: var(--p-font-size-550); font-weight: var(--p-font-weight-semibold); margin-bottom: var(--p-space-200); color: var(--p-color-text); }
.tour-tooltip p { font-size: var(--p-font-size-300); color: var(--p-color-text-secondary); line-height: 1.6; margin-bottom: var(--p-space-400); }
.tour-nav { display: flex; justify-content: space-between; gap: var(--p-space-200); }
.tour-start-btn { position: fixed; bottom: 24px; right: 24px; width: 44px; height: 44px; border-radius: 50%; background: var(--p-color-bg-fill-brand); color: var(--p-color-text-brand-on-bg-fill); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: var(--p-shadow-300); z-index: 999; }
.tour-start-btn:hover { background: var(--p-color-bg-fill-brand-hover); }
.tour-start-btn .material-symbols-outlined { font-size: 20px; }
.tour-highlight { position: relative; z-index: 1002; box-shadow: 0 0 0 2px var(--p-color-border-focus); border-radius: var(--p-border-radius-100); }

/* Mobile */
@media (max-width: 768px) {
  .demo-shell { flex-direction: column; }
  .demo-sidebar { width: 100%; flex-direction: row; overflow-x: auto; }
  .demo-nav { display: flex; padding: 0; }
  .demo-nav-item { padding: 10px 16px; white-space: nowrap; }
  .demo-sidebar-footer { display: none; }
  .demo-main { padding: var(--p-space-300); }
  .demo-grid { grid-template-columns: 1fr; }
  .demo-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Force body background to match Polaris exactly */
body {
  background-color: #f1f2f4 !important;
}

/* Nav items — exact match to Polaris Navigation */
.demo-nav-item {
  font-family: "Inter", -apple-system, "system-ui", "Segoe UI", Roboto, sans-serif !important;
}

/* Nav text — uppercase via CSS, not content */
.demo-nav-item span:last-child {
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Force body background — Polaris sets transparent for embedded mode */
html body,
html > body {
  background-color: #f1f2f4 !important;
}
