﻿/*
 * Purpose: Page-specific styles for dashboard, including layout, components, states, and responsive behavior.
 * Keep page-only rules here; shared primitives belong in app.css.
 */
/* =========================================================
   DASHBOARD SPECIFIC
========================================================= */

.dashboard {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 22px;
  padding: 28px 32px;
  border-radius: var(--r-xl);
  background: linear-gradient(
    135deg,
    rgba(168, 85, 247, 0.06) 0%,
    rgba(255, 255, 255, 0.04) 50%,
    rgba(6, 182, 212, 0.04) 100%
  );
  border: 1px solid rgba(168, 85, 247, 0.14);
  box-shadow: var(--shadow-card), 0 0 60px rgba(168, 85, 247, 0.05);
  -webkit-backdrop-filter: var(--blur-md);
          backdrop-filter: var(--blur-md);
  position: relative;
  overflow: visible;
  min-width: 0;
}

/* Gradient shimmer line */
.dashboard-header::before,
.performance-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(168, 85, 247, 0.50) 30%,
    rgba(255, 255, 255, 0.30) 50%,
    rgba(6, 182, 212, 0.40) 70%,
    transparent 100%
  );
}

.dashboard-title {
  min-width: 0;
}

.dashboard-eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--text-tertiary);
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.dashboard-header h1 {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.dashboard-header p {
  color: var(--text-secondary);
  font-size: 13.5px;
  margin-top: 7px;
  line-height: 1.45;
}

.dashboard-alerts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.dashboard-alerts:empty { display: none; }

.dashboard-alert {
  display: grid;
  gap: 5px;
  min-height: 82px;
  padding: 13px 14px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-glass);
}

.dashboard-alert strong {
  font-size: 12.5px;
  font-weight: 900;
}

.dashboard-alert span {
  color: var(--text-secondary);
  font-size: 11.5px;
  line-height: 1.45;
}

.dashboard-alert--success { border-color: rgba(48, 209, 88, 0.26); background: rgba(48, 209, 88, 0.08); }
.dashboard-alert--warning { border-color: rgba(255, 214, 10, 0.28); background: rgba(255, 214, 10, 0.08); }
.dashboard-alert--danger  { border-color: rgba(255, 69, 58, 0.30); background: rgba(255, 69, 58, 0.08); }
.dashboard-alert--info    { border-color: rgba(10, 132, 255, 0.28); background: rgba(10, 132, 255, 0.08); }

.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  margin-bottom: 0;
}

.kpi-card {
  min-height: 142px;
  min-width: 0;
  padding-right: 16px;
  position: relative;
}

.kpi-card:focus-visible,
.panel-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.kpi-card h3 {
  min-height: 36px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.kpi-card .number {
  font-size: 32px;
  font-weight: 800;
  white-space: nowrap;
  animation: number-pop 0.50s var(--ease-spring) both;
}

/* SVG icon in KPI cards - gradient & glow */
.kpi-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  margin-bottom: 12px;
  flex-shrink: 0;
  transition:
    transform var(--t-fast) var(--ease-spring),
    box-shadow var(--t-base) ease;
}

.kpi-icon svg {
  width: 19px;
  height: 19px;
}

.kpi-card:hover .kpi-icon {
  transform: scale(1.12) rotate(-6deg);
}

.kpi-icon--tasks {
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.18) 0%, rgba(6, 182, 212, 0.12) 100%);
  border: 1px solid rgba(10, 132, 255, 0.28);
  color: var(--info);
  box-shadow: 0 4px 16px rgba(10, 132, 255, 0.12);
}
.kpi-icon--tasks:hover { box-shadow: 0 6px 24px rgba(10, 132, 255, 0.25); }

.kpi-icon--rate {
  background: linear-gradient(135deg, rgba(48, 209, 88, 0.18) 0%, rgba(16, 185, 129, 0.12) 100%);
  border: 1px solid rgba(48, 209, 88, 0.28);
  color: var(--success);
  box-shadow: 0 4px 16px rgba(48, 209, 88, 0.12);
}

.kpi-icon--stock {
  background: linear-gradient(135deg, rgba(255, 69, 58, 0.18) 0%, rgba(255, 51, 71, 0.12) 100%);
  border: 1px solid rgba(255, 69, 58, 0.28);
  color: var(--danger);
  box-shadow: 0 4px 16px rgba(255, 69, 58, 0.12);
}

.kpi-icon--orders {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.18) 0%, rgba(99, 102, 241, 0.12) 100%);
  border: 1px solid rgba(168, 85, 247, 0.28);
  color: #a855f7;
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.12);
}

.kpi-icon--time {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.18) 0%, rgba(234, 179, 8, 0.12) 100%);
  border: 1px solid rgba(249, 115, 22, 0.28);
  color: #f97316;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.12);
}

.dashboard-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 14px;
  min-width: 0;
}

.performance-panel {
  padding: 22px;
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.038);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-card);
  -webkit-backdrop-filter: var(--blur-md);
          backdrop-filter: var(--blur-md);
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.performance-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.performance-header h2,
.panel h2 {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0;
}

.performance-header p,
.panel-heading p {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.performance-score {
  min-width: 84px;
  padding: 11px 13px;
  border-radius: var(--r-md);
  background: rgba(10, 132, 255, 0.10);
  color: var(--info);
  text-align: center;
  border: 1px solid rgba(10, 132, 255, 0.22);
}

.performance-score span {
  display: block;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
}

.performance-score small {
  display: block;
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.performance-chart-wrap {
  width: 100%;
  overflow-x: auto;
}

.performance-chart {
  width: 100%;
  min-width: 620px;
  height: 220px;
  display: block;
}

.performance-grid-line    { stroke: rgba(255,255,255,0.055); stroke-width: 1; }
.performance-axis-label,
.performance-day-label    { fill: var(--text-secondary); font-size: 11px; font-weight: 700; }
.performance-value-label  { fill: var(--text); font-size: 11px; font-weight: 800; }
.performance-area         { fill: rgba(10, 132, 255, 0.10); }
.performance-line         { fill: none; stroke: var(--info); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.performance-line-gap     { stroke-dasharray: 5 6; opacity: 0.72; }
.performance-point        { fill: #fff; stroke: var(--info); stroke-width: 2.5; }
.performance-point-empty  { fill: var(--glass-8); stroke: var(--border-glass-strong); stroke-width: 2; }

.performance-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
}

.performance-day {
  padding: 8px 5px;
  border-radius: var(--r-sm);
  background: var(--glass-4);
  border: 1px solid var(--border-glass);
  text-align: center;
}

.performance-day span {
  display: block;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.performance-day strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.dashboard-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
}

.dashboard-content > .panel {
  min-width: 0;
}

.dashboard-content-wide .dashboard-cockpit-panel {
  grid-column: span 2;
}

.dashboard-content-wide .dashboard-time-panel {
  grid-column: span 2;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin-bottom: 5px;
}

.panel-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  flex-shrink: 0;
  padding: 7px 10px;
  border-radius: var(--r-xs);
  color: var(--text-secondary);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-glass);
  font-size: 11px;
  font-weight: 900;
}

.dashboard-load-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--warning);
  border-radius: var(--r-md);
  color: var(--text);
  background: var(--glass-4);
}

.dashboard [hidden] {
  display: none !important;
}

.panel-heading > div,
.priority-item > div,
.task-list li > div,
.material-list li > div,
.dashboard-status-row {
  min-width: 0;
  overflow-wrap: anywhere;
}

.priority-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.panel-link:hover {
  color: var(--text);
  border-color: var(--border-glass-mid);
}

.dashboard-cockpit {
  display: grid;
  grid-template-columns: minmax(150px, 0.42fr) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  min-width: 0;
}

.stock-health-graphic {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  padding: 14px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
}

.stock-health-chart {
  --stock-health-deg: 0deg;
  --status-color: var(--success);
  width: 124px;
  height: 124px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(12, 14, 30, 0.96) 0 54%, transparent 55%),
    conic-gradient(var(--status-color) 0 var(--stock-health-deg), rgba(255,255,255,0.10) var(--stock-health-deg) 360deg);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.stock-health-chart.is-success { --status-color: var(--success); }
.stock-health-chart.is-warning { --status-color: var(--warning); }
.stock-health-chart.is-danger  { --status-color: var(--danger); }
.stock-health-chart.is-empty {
  background:
    radial-gradient(circle at center, rgba(12, 14, 30, 0.96) 0 54%, transparent 55%),
    conic-gradient(var(--glass-18) 0 360deg);
}

.stock-health-chart span {
  font-size: 28px;
  font-weight: 900;
  color: var(--text);
}

.stock-health-copy {
  display: grid;
  gap: 4px;
}

.stock-health-copy strong {
  font-size: 13px;
  font-weight: 900;
}

.stock-health-copy span {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
}

.dashboard-status-bars {
  display: grid;
  gap: 10px;
}

.dashboard-status-row {
  display: grid;
  gap: 6px;
  padding: 10px 11px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
}

.dashboard-status-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.dashboard-status-row-head span {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 900;
}

.dashboard-status-row-head strong {
  color: var(--text);
  font-size: 16px;
  line-height: 1;
}

.dashboard-status-track {
  height: 8px;
  overflow: hidden;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-glass);
}

.dashboard-status-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), rgba(249, 115, 22, 0.9));
  position: relative;
  overflow: hidden;
}

/* Shimmer spell on progress bar */
.dashboard-status-track span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.35) 50%,
    transparent 100%
  );
  background-size: 200% auto;
  animation: shimmer-flow 2.5s linear infinite;
}

.dashboard-status-row--success .dashboard-status-track span {
  background: linear-gradient(90deg, var(--success), rgba(16, 185, 129, 0.85));
}
.dashboard-status-row--warning .dashboard-status-track span {
  background: linear-gradient(90deg, var(--warning), rgba(249, 115, 22, 0.85));
}
.dashboard-status-row--danger .dashboard-status-track span {
  background: linear-gradient(90deg, var(--danger), rgba(255, 51, 71, 0.85));
}
.dashboard-status-row--info .dashboard-status-track span {
  background: linear-gradient(90deg, var(--info), rgba(6, 182, 212, 0.85));
}

.priority-list {
  display: grid;
  gap: 10px;
}

.priority-item {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 11px;
  align-items: center;
  padding: 12px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border-glass);
  transition:
    background var(--t-fast) ease,
    border-color var(--t-fast) ease,
    transform var(--t-fast) var(--ease-spring);
}

.priority-item:hover {
  background: rgba(255,255,255,0.055);
  transform: translateX(3px);
}

.priority-item > span {
  width: 10px;
  height: 42px;
  border-radius: var(--r-full);
  background: linear-gradient(180deg, var(--info), rgba(6, 182, 212, 0.6));
  box-shadow: 0 0 8px rgba(10, 132, 255, 0.35);
}

.priority-item strong {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
}

.priority-item small {
  display: block;
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 11.5px;
  line-height: 1.4;
}

.priority-item--success > span {
  background: linear-gradient(180deg, var(--success), rgba(48, 209, 88, 0.5));
  box-shadow: 0 0 8px rgba(48, 209, 88, 0.35);
}
.priority-item--warning > span {
  background: linear-gradient(180deg, var(--warning), rgba(255, 214, 10, 0.5));
  box-shadow: 0 0 8px rgba(255, 214, 10, 0.30);
}
.priority-item--danger > span {
  background: linear-gradient(180deg, var(--danger), rgba(255, 69, 58, 0.5));
  box-shadow: 0 0 8px rgba(255, 69, 58, 0.35);
}
.priority-item--info > span {
  background: linear-gradient(180deg, var(--info), rgba(6, 182, 212, 0.6));
  box-shadow: 0 0 8px rgba(10, 132, 255, 0.35);
}

.task-list li,
.material-list li {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 11px;
  align-items: center;
  padding: 11px 13px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-glass);
  border-radius: var(--r-sm);
  margin-bottom: 7px;
}

.task-list li:hover,
.material-list li:hover {
  background: var(--glass-6);
  border-color: var(--border-glass-mid);
}

.task-list li strong,
.material-list li strong {
  display: block;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text);
}

.task-list li span,
.material-list li span {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.35;
}

.dashboard-list-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--glass-8);
  font-size: 17px;
  border: 1px solid var(--border-glass);
  flex-shrink: 0;
  overflow: hidden;
}

.dashboard-list-icon-img,
.dashboard-list-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.dashboard-list-icon-emoji { font-size: 17px; }

.dashboard-risk-critical {
  border-color: rgba(255, 69, 58, 0.28) !important;
}

.dashboard-risk-low {
  border-color: rgba(255, 214, 10, 0.24) !important;
}

.time-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.time-status-card {
  display: grid;
  gap: 5px;
  min-height: 96px;
  padding: 12px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border-glass);
}

.time-status-card span {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.time-status-card strong {
  font-size: 22px;
  font-weight: 900;
}

.time-status-card small {
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1.35;
}

/* Responsive overrides for this breakpoint. */
@media (max-width: 1280px) {
  .dashboard-top-grid { grid-template-columns: 1fr; }
}

/* Responsive overrides for this breakpoint. */
@media (max-width: 1100px) {
  .dashboard-content { grid-template-columns: 1fr; }
  .dashboard-content-wide .dashboard-cockpit-panel,
  .dashboard-content-wide .dashboard-time-panel {
    grid-column: span 1;
  }
}

/* Responsive overrides for this breakpoint. */
@media (max-width: 900px) {
  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-kpis,
  .dashboard-alerts,
  .dashboard-content {
    grid-template-columns: 1fr;
  }

  .dashboard-cockpit {
    grid-template-columns: 1fr;
  }

  .stock-health-graphic {
    grid-template-columns: 124px 1fr;
    justify-items: start;
    text-align: left;
  }

  .performance-days {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Responsive overrides for this breakpoint. */
@media (max-width: 700px) {
  .dashboard { padding: 16px; }
  .dashboard-header { padding: 18px; }
  .dashboard-header h1 { font-size: 24px; }
  .performance-panel { padding: 16px; }
  .performance-chart { min-width: 520px; }
  .performance-header { flex-direction: column; align-items: stretch; }
  .performance-score { width: 100%; }
  .performance-days { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .time-status-grid { grid-template-columns: 1fr; }
  .dashboard-load-status { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-status-track span::after,
  .kpi-card .number { animation: none; }
  .priority-item,
  .kpi-icon { transition: none; }
  .priority-item:hover,
  .kpi-card:hover .kpi-icon { transform: none; }
}

/* Responsive overrides for this breakpoint. */
@media (max-width: 460px) {
  .stock-health-graphic {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
}

/* ===== LIGHT THEME DASHBOARD OVERRIDES ===== */
body.theme-light .dashboard-header,
body.theme-light .performance-panel,
body.theme-light .panel,
body.theme-light .dashboard-alert,
body.theme-light .performance-score,
body.theme-light .performance-day,
body.theme-light .panel-link,
body.theme-light .stock-health-graphic,
body.theme-light .dashboard-status-row,
body.theme-light .dashboard-status-track,
body.theme-light .priority-item,
body.theme-light .task-list li,
body.theme-light .material-list li,
body.theme-light .dashboard-list-icon,
body.theme-light .time-status-card {
  background: #ffffff;
  border-color: #d6dce6;
  color: var(--text);
}

body.theme-light .dashboard-header::before,
body.theme-light .performance-panel::before {
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.05), transparent);
}

body.theme-light .dashboard-alert {
  background: #eff2f7;
}

body.theme-light .dashboard-alert--success {
  background: rgba(5, 150, 105, 0.10);
  border-color: rgba(5, 150, 105, 0.20);
}

body.theme-light .dashboard-alert--warning {
  background: rgba(217, 119, 6, 0.10);
  border-color: rgba(217, 119, 6, 0.20);
}

body.theme-light .dashboard-alert--danger {
  background: rgba(220, 38, 38, 0.10);
  border-color: rgba(220, 38, 38, 0.20);
}

body.theme-light .dashboard-alert--info {
  background: rgba(3, 105, 161, 0.10);
  border-color: rgba(3, 105, 161, 0.20);
}

body.theme-light .performance-score {
  background: rgba(3, 105, 161, 0.10);
  border-color: rgba(3, 105, 161, 0.20);
  color: #0369a1;
}

body.theme-light .performance-day {
  background: #eff2f7;
}

body.theme-light .performance-grid-line {
  stroke: rgba(0, 0, 0, 0.08);
}

body.theme-light .stock-health-chart {
  background:
    radial-gradient(circle at center, #ffffff 0 54%, transparent 55%),
    conic-gradient(var(--status-color) 0 var(--stock-health-deg), rgba(0, 0, 0, 0.08) var(--stock-health-deg) 360deg);
}

body.theme-light .dashboard-status-track {
  background: #d6dce6;
}

body.theme-light .priority-item {
  background: #eff2f7;
}

body.theme-light .task-list li,
body.theme-light .material-list li {
  background: #eff2f7;
}

body.theme-light .task-list li:hover,
body.theme-light .material-list li:hover {
  background: #ffffff;
  border-color: #d6dce6;
}

body.theme-light .dashboard-list-icon {
  background: #e8ecf3;
  border-color: #d6dce6;
}

body.theme-light .time-status-card {
  background: #eff2f7;
}

/* Ensure numbers are readable in light mode */
body.theme-light .kpi-card .number {
  color: var(--text);
  font-weight: 900;
}

body.theme-light .performance-score span {
  color: #0369a1;
  font-weight: 900;
}

body.theme-light .performance-score small {
  color: var(--text-secondary);
}

body.theme-light .dashboard-status-row-head strong {
  color: var(--text);
}

body.theme-light .time-status-card strong {
  color: var(--text);
}

body.theme-light .stock-health-chart span {
  color: var(--text);
}
