/* Production Review & Shift Performance Console - OFALabs Industrial Design System
 * Theme: Minimalist, Data-Dense, Industrial Fleet Management
 * Colors/radii/fonts are inherited from the global stylesheet
 * /_next/static/chunks/1t4aoiqub9ec4.css; local --pr-* aliases below map
 * page-level names onto the global tokens — do not hardcode hex values here.
 */

:root {
  --pr-bg: var(--c-surface);
  --pr-surface: var(--c-white);
  --pr-surface-subtle: var(--c-surface2);
  --pr-border: var(--c-border);
  --pr-border-subtle: var(--c-surface2);
  --pr-text: var(--c-text);
  --pr-text-secondary: var(--c-sub);
  --pr-text-muted: var(--c-muted);
  --pr-primary: var(--c-accent);
  --pr-primary-hover: var(--c-accent2);
  --pr-primary-light: #eff6ff;

  --pr-status-hauling-bg: #e0f2fe;
  --pr-status-hauling-text: #0369a1;
  --pr-status-loading-bg: #dcfce7;
  --pr-status-loading-text: var(--c-loading);
  --pr-status-queue-bg: #fef9c3;
  --pr-status-queue-text: var(--c-dumping);
  --pr-status-breakdown-bg: #fee2e2;
  --pr-status-breakdown-text: var(--c-error);
  --pr-status-standby-bg: var(--c-surface2);
  --pr-status-standby-text: var(--c-queuing);

  --pr-font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --pr-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --pr-radius-card: var(--radius-md);
  --pr-radius-btn: var(--radius-sm);
  --pr-radius-pill: 99px;
}

#production-connection-status[data-tone="live"] { color: var(--c-loading); }
#production-connection-status[data-tone="pending"],
#production-connection-status[data-tone="warning"] { color: #a16207; }
#production-connection-status[data-tone="danger"] { color: var(--c-error); }

/* Base Container */
.pr-console {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 24px;
  background-color: var(--pr-bg);
  color: var(--pr-text);
  font-family: var(--pr-font-sans);
  min-height: calc(100vh - 64px);
  box-sizing: border-box;
}

/* Top Operational Context Bar */
.pr-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--pr-surface);
  border: 1px solid var(--pr-border);
  border-radius: var(--pr-radius-card);
  padding: 12px 18px;
}

.pr-shift-context {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.pr-site-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pr-site-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--pr-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pr-shift-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--pr-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pr-live-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--pr-radius-pill);
  background: #dcfce7;
  color: var(--c-loading);
}

.pr-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-loading);
  animation: pr-pulse 2s infinite;
}

@keyframes pr-pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

.pr-shift-timeline {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--pr-text-secondary);
  background: var(--pr-bg);
  padding: 6px 12px;
  border-radius: var(--pr-radius-btn);
  border: 1px solid var(--pr-border);
}

.pr-timeline-progress {
  width: 90px;
  height: 6px;
  background: var(--c-border);
  border-radius: 3px;
  overflow: hidden;
}

.pr-timeline-fill {
  height: 100%;
  background: var(--pr-primary);
}

.pr-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Compact Primary Production KPI Strip */
.pr-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.pr-kpi-block {
  background: var(--pr-surface);
  border: 1px solid var(--pr-border);
  border-radius: var(--pr-radius-card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pr-kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--pr-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pr-kpi-val {
  font-size: 24px;
  font-weight: 700;
  color: var(--pr-text);
  line-height: 1.15;
}

.pr-kpi-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--pr-text-secondary);
  margin-left: 4px;
}

.pr-kpi-sub {
  font-size: 11.5px;
  color: var(--pr-text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

/* Semantic Badges */
.pr-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--pr-radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.pr-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.pr-badge-green { background: #dcfce7; color: var(--c-loading); }
.pr-badge-blue { background: #e0f2fe; color: #0369a1; }
.pr-badge-amber { background: #fef9c3; color: var(--c-dumping); }
.pr-badge-red { background: #fee2e2; color: var(--c-error); }
.pr-badge-slate { background: var(--c-surface2); color: var(--c-queuing); }

/* Alerts Banner */
.pr-alerts-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--pr-radius-card);
  overflow-x: auto;
}

.pr-alerts-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #92400e;
  white-space: nowrap;
}

.pr-alert-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--c-white);
  border: 1px solid #fcd34d;
  border-radius: var(--pr-radius-btn);
  font-size: 11.5px;
  color: #78350f;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.pr-alert-pill:hover {
  background: #fef3c7;
  border-color: #f59e0b;
}

.pr-alert-pill--critical {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.pr-alert-pill--critical:hover {
  background: #fee2e2;
  border-color: #ef4444;
}

/* Filter Toolbar */
.pr-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--pr-surface);
  border: 1px solid var(--pr-border);
  border-radius: var(--pr-radius-card);
  padding: 12px 16px;
}

.pr-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.pr-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pr-select {
  height: 32px;
  padding: 0 10px;
  background: var(--c-white);
  border: 1px solid var(--pr-border);
  border-radius: var(--pr-radius-btn);
  font-size: 12px;
  color: var(--pr-text);
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.pr-select:focus {
  border-color: var(--pr-primary);
}

.pr-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--pr-radius-btn);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  background: transparent;
  color: var(--pr-text);
}

.pr-btn-primary {
  background: var(--pr-primary);
  color: var(--c-white);
}

.pr-btn-primary:hover {
  background: var(--pr-primary-hover);
}

.pr-btn-outline {
  background: var(--c-white);
  border-color: var(--pr-border);
  color: var(--pr-text);
}

.pr-btn-outline:hover {
  background: var(--pr-surface-subtle);
  border-color: var(--c-border2);
}

.pr-btn-ghost {
  color: var(--pr-text-secondary);
}

.pr-btn-ghost:hover {
  background: var(--pr-surface-subtle);
  color: var(--pr-text);
}

.pr-active-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11.5px;
}

.pr-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--pr-primary-hover);
  border-radius: var(--pr-radius-pill);
  font-size: 11px;
}

.pr-filter-pill-close {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

/* Hourly Trend Section: Chart + Performance Table */
.pr-hourly-section {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
}

@media (max-width: 1200px) {
  .pr-hourly-section {
    grid-template-columns: 1fr;
  }
}

.pr-panel {
  background: var(--pr-surface);
  border: 1px solid var(--pr-border);
  border-radius: var(--pr-radius-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pr-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--pr-border-subtle);
  padding-bottom: 10px;
}

.pr-panel-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--pr-text);
  display: flex;
  align-items: center;
  gap: 7px;
}

.pr-panel-sub {
  font-size: 11px;
  color: var(--pr-text-secondary);
  font-weight: 400;
  margin-top: 2px;
}

.pr-chart-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--pr-text-secondary);
}

.pr-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.pr-legend-box {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.pr-legend-line {
  width: 14px;
  height: 2px;
}

/* SVG Chart Container */
.pr-chart-wrap {
  width: 100%;
  position: relative;
}

.pr-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.pr-chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--c-text);
  color: var(--c-white);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  z-index: 10;
}

/* Tables */
.pr-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.pr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.pr-table th {
  padding: 8px 10px;
  background: var(--pr-surface-subtle);
  color: var(--pr-text-secondary);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--pr-border);
  white-space: nowrap;
}

.pr-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--pr-border-subtle);
  color: var(--pr-text);
  white-space: nowrap;
}

.pr-table tr:hover td {
  background: var(--c-surface);
}

.pr-table-row--selected td {
  background: #eff6ff !important;
  font-weight: 600;
}

.pr-mono {
  font-family: var(--pr-font-mono);
}

/* Two-Column Analytics Grid: Payload + Cycle Breakdown */
.pr-analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 1100px) {
  .pr-analytics-grid {
    grid-template-columns: 1fr;
  }
}

/* Payload Analytics */
.pr-payload-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pr-payload-stacked-bar {
  display: flex;
  height: 18px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--c-border);
}

.pr-payload-seg-optimal { background: #22c55e; }
.pr-payload-seg-underload { background: #f59e0b; }
.pr-payload-seg-overload { background: #ef4444; }

.pr-payload-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pr-payload-breakdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  padding: 6px 8px;
  background: var(--pr-bg);
  border-radius: var(--pr-radius-btn);
}

/* Cycle Time Breakdown */
.pr-cycle-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pr-cycle-phase-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pr-phase-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
}

.pr-phase-bar-track {
  height: 6px;
  background: var(--c-surface2);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.pr-phase-bar-fill {
  height: 100%;
  border-radius: 3px;
}

.pr-phase-fill-normal { background: var(--c-accent); }
.pr-phase-fill-warning { background: #f59e0b; }
.pr-phase-fill-critical { background: var(--c-error); }

/* Operational Bottlenecks Card */
.pr-bottleneck-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--pr-radius-btn);
}

.pr-bottleneck-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: #92400e;
}

.pr-bottleneck-desc {
  font-size: 11.5px;
  color: #78350f;
  line-height: 1.4;
}

/* Estimated Production Loss */
.pr-loss-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--pr-radius-btn);
}

.pr-loss-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pr-loss-label {
  font-size: 10.5px;
  font-weight: 600;
  color: #991b1b;
  text-transform: uppercase;
}

.pr-loss-val {
  font-size: 14px;
  font-weight: 700;
  color: #7f1d1d;
}

/* Fleet Operations Tabs */
.pr-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--pr-border);
  padding-bottom: 2px;
}

.pr-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px 6px 0 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--pr-text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.pr-tab-btn:hover {
  color: var(--pr-text);
  background: var(--c-surface2);
}

.pr-tab-btn--active {
  color: var(--pr-primary);
  border-bottom-color: var(--pr-primary);
  background: var(--c-white);
}

/* Modal / Drawer */
.pr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.pr-modal {
  background: var(--pr-surface);
  border: 1px solid var(--pr-border);
  border-radius: var(--pr-radius-card);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.pr-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--pr-border);
}

.pr-modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pr-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--pr-border);
  background: var(--pr-surface-subtle);
}

.pr-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.pr-kv-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px solid var(--pr-border-subtle);
}

.pr-kv-key {
  color: var(--pr-text-secondary);
}

.pr-kv-val {
  color: var(--pr-text);
  font-weight: 600;
}

/* Responsive Overrides */
@media (max-width: 1366px) {
  .pr-console {
    padding: 12px 16px;
    gap: 12px;
  }
  .pr-kpi-val {
    font-size: 21px;
  }
}
