/* ═══════════════════════════════════════════════════════════════════════
   Dashboard ("لوحة التحكم") — verbatim port of Legacy's real
   panels/dashboard/dashboard-main.css/.html classes (2026-09-18, owner request
   after sending real screenshots — "عايزها بنفس الشكل دا بالمللي... ممنوع
   تخترع تصميم من عندك"). Same class names as Legacy, mapped onto this app's
   already-established CSS custom properties (--lg-* / var(--pos-*)-style tokens
   already defined in app.css) instead of re-declaring a parallel token set —
   Legacy's own dashboard tokens (--bg-card, --text-muted, --accent, ...) are
   aliased below to the existing app.css tokens so this page follows the same
   light/dark theming every other V2 screen already uses, rather than inventing
   a second, dashboard-only palette.
   ═══════════════════════════════════════════════════════════════════════ */

.dash-root { --bar-start: var(--th-accent-500); --bar-end: var(--th-accent2-500); }

/* ─── KPI Card ─── */
.kpi-card {
    background: var(--lg-panel-bg);
    border: 1px solid var(--lg-border);
    border-radius: 14px;
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
    transition: transform .2s, box-shadow .2s, border-color .2s;
}
.kpi-card:hover { transform: translateY(-2px); border-color: rgba(var(--th-accent-500-rgb),.35); box-shadow: 0 8px 32px rgba(var(--th-accent-500-rgb),.12); }
.kpi-card::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(var(--th-accent-500-rgb),.05) 0%, transparent 60%); pointer-events: none; }
.kpi-top-bar { position: absolute; top: 0; right: 0; left: 0; height: 2px; background: linear-gradient(90deg, var(--bar-start, var(--th-accent-500)), var(--bar-end, var(--th-accent2-500))); opacity: .7; }
.kpi-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi-icon i, .kpi-icon svg { width: 17px; height: 17px; }
.kpi-label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.kpi-value { font-size: 24px; font-weight: 900; color: var(--text); margin-top: 6px; line-height: 1.1; }
.kpi-sub { font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

/* ─── Dashboard Card ─── */
.dash-card { background: var(--lg-panel-bg); border: 1px solid var(--lg-border); border-radius: 14px; padding: 20px; transition: border-color .2s; }
.dash-card:hover { border-color: rgba(var(--th-accent-500-rgb),.35); }
.dash-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.dash-card-title { font-size: 14px; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 8px; }
.dash-card-title i, .dash-card-title svg { width: 16px; height: 16px; }
.dash-card-action { font-size: 12px; font-weight: 700; color: var(--accent); text-decoration: none; cursor: pointer; opacity: .8; transition: opacity .2s; background: none; border: none; }
.dash-card-action:hover { opacity: 1; }

/* ─── Financial Card ─── */
.fin-card { background: var(--lg-panel-bg); border: 1px solid var(--lg-border); border-radius: 14px; padding: 16px 18px; position: relative; overflow: hidden; transition: transform .2s, border-color .2s; }
.fin-card:hover { transform: translateY(-1px); border-color: rgba(var(--th-accent-500-rgb),.35); }
.fin-card-label { font-size: 10px; font-weight: 800; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px; }
.fin-card-value { font-size: 20px; font-weight: 900; color: var(--text); }
.fin-card-sub { font-size: 11px; color: var(--muted); margin-top: 5px; font-weight: 600; }

/* ─── Recent Item ─── */
.recent-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; transition: background .15s; }
.recent-item:hover { background: rgba(255,255,255,.04); }
.recent-item-icon { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: rgba(var(--th-accent-500-rgb),.15); color: var(--th-accent-500); }
.recent-item-icon i, .recent-item-icon svg { width: 16px; height: 16px; }
.recent-item-title { font-size: 13px; font-weight: 700; color: var(--text); }
.recent-item-sub { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.recent-item-val { margin-right: auto; font-size: 13px; font-weight: 800; white-space: nowrap; }

/* ─── Alert Item ─── */
.alert-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; background: rgba(255,255,255,.04); border: 1px solid var(--lg-border); margin-bottom: 6px; }
.alert-item:last-child { margin-bottom: 0; }

/* ─── Badge ─── */
.dash-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 10px; font-weight: 800; letter-spacing: .04em; }
.dash-badge-amber  { background: rgba(245,158,11,.15); color: #f59e0b; border: 1px solid rgba(245,158,11,.25); }
.dash-badge-blue   { background: rgba(59,130,246,.15); color: #3b82f6; border: 1px solid rgba(59,130,246,.25); }
.dash-badge-green  { background: rgba(16,185,129,.15); color: #10b981; border: 1px solid rgba(16,185,129,.25); }
.dash-badge-red    { background: rgba(239,68,68,.15);  color: #ef4444; border: 1px solid rgba(239,68,68,.25); }
.dash-badge-indigo { background: rgba(var(--th-accent-500-rgb),.15); color: var(--th-accent-500); border: 1px solid rgba(var(--th-accent-500-rgb),.25); }

.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
@keyframes dashPulse { 0%,100%{opacity:1;transform:scale(1);} 50%{opacity:.7;transform:scale(1.1);} }
.pulse-dot { animation: dashPulse 2s ease-in-out infinite; }

.dash-section-title { font-size: 13px; font-weight: 900; color: var(--text-sub); letter-spacing: .06em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.dash-section-title i, .dash-section-title svg { width: 14px; height: 14px; }
.dash-section-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--lg-border), transparent); }

.dash-trend-up { color: #10b981; }
.dash-trend-down { color: #ef4444; }
.dash-trend-neutral { color: var(--muted); }

.dash-progress-bar { height: 5px; background: rgba(255,255,255,.06); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.dash-progress-fill { height: 100%; border-radius: 99px; transition: width 1s cubic-bezier(.4,0,.2,1); }

.dash-list-scroll { max-height: 240px; overflow-y: auto; padding-inline-end: 4px; }
.dash-list-scroll::-webkit-scrollbar { width: 3px; }
.dash-list-scroll::-webkit-scrollbar-thumb { background: rgba(var(--th-accent-500-rgb),.3); border-radius: 99px; }

/* ─── Header: quick strip + date-range + status badges ─── */
.dash-header { background: var(--lg-panel-bg); border-bottom: 1px solid var(--lg-border); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; position: relative; }
.dash-header::after { content: ''; position: absolute; bottom: 0; right: 0; left: 0; height: 1px; background: linear-gradient(90deg, var(--th-accent-500), var(--th-accent2-500), transparent); opacity: .3; }
.dash-strip { display: flex; align-items: center; background: var(--lg-panel-bg); border: 1px solid var(--lg-border); border-radius: 12px; overflow: hidden; }
.strip-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 14px; border-inline-end: 1px solid var(--lg-border); }
.strip-item:last-child { border-inline-end: none; }
.strip-val { font-size: 15px; font-weight: 900; color: var(--text); }
.strip-lbl { font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }

.date-range-selector { display: flex; align-items: center; background: rgba(255,255,255,.05); border: 1px solid var(--lg-border); border-radius: 10px; padding: 3px; gap: 2px; }
.date-range-btn { padding: 5px 12px; border-radius: 7px; border: none; background: transparent; color: var(--muted); font-family: 'Cairo', sans-serif; font-size: 11px; font-weight: 700; cursor: pointer; transition: all .2s; white-space: nowrap; }
.date-range-btn:hover { color: var(--text); background: var(--lg-panel-bg); }
.date-range-btn.active { background: linear-gradient(135deg, var(--th-accent-500), var(--th-accent2-500)); color: #fff; box-shadow: 0 2px 8px rgba(var(--th-accent-500-rgb),.35); }

.dash-status-pill { display: flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 9px; }

/* ─── Pulse ticker (WO quick-actions strip) ─── */
.pulse-ticker { display: flex; align-items: stretch; background: var(--lg-panel-bg); border-bottom: 1px solid var(--lg-border); }
.weather-chip { flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 7px 16px; background: linear-gradient(135deg, rgba(34,211,238,.14), rgba(var(--th-accent-500-rgb),.08)); border-inline-end: 1px solid var(--lg-border); min-width: 140px; }
.weather-chip-icon { font-size: 24px; line-height: 1; filter: drop-shadow(0 0 8px rgba(34,211,238,.25)); }
.weather-chip-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.weather-chip-temp { font-size: 15px; font-weight: 900; color: var(--text); line-height: 1.1; }
.weather-chip-label { font-size: 9.5px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pulse-ticker-scroll { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; padding: 8px 0; }
.pulse-ticker-track { display: inline-flex; gap: 30px; font-size: 12px; font-weight: 700; color: var(--text-sub); padding-inline-end: 30px; }
.pulse-ticker-track span { flex-shrink: 0; }
@media (prefers-reduced-motion: no-preference) {
    .pulse-ticker-track { animation: dashTickerScroll 40s linear infinite; }
    .pulse-ticker:hover .pulse-ticker-track { animation-play-state: paused; }
}
@keyframes dashTickerScroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ─── Milestone bar ─── */
.milestone-bar { display: flex; align-items: center; gap: 14px; background: linear-gradient(135deg, rgba(245,158,11,.12), rgba(var(--th-accent2-500-rgb),.08)); border: 1px solid rgba(245,158,11,.25); border-radius: 14px; padding: 14px 18px; }
.milestone-ico { font-size: 26px; flex-shrink: 0; }
.milestone-text { font-size: 13px; font-weight: 800; color: var(--text); }
.milestone-sub { font-size: 11px; color: var(--muted); margin-top: 2px; font-weight: 600; }

/* ─── Health gauge + weather block ─── */
.health-gauge-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.weather-block { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; padding-inline-start: 12px; border-inline-start: 1px solid var(--lg-border); }

/* ─── Peak-hours heatmap ─── */
.peak-heat-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; }
.heat-cell { aspect-ratio: 1; border-radius: 4px; background: #22d3ee; display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 800; color: rgba(0,0,0,.55); }

/* ─── Lightweight dependency-free line chart (SVG) — same visual shape as
   Legacy's Chart.js line, without pulling in a chart library (this app's own
   established convention — see SalesReport.razor's own "no chart library"
   note — a real V2 precedent, not invented for this screen). ─── */
.chart-wrap { position: relative; height: 220px; }
.chart-svg-wrap { width: 100%; height: 100%; }
.chart-point { fill: var(--th-accent-500); stroke: var(--lg-panel-bg); stroke-width: 2; }
.chart-axis-label { font-size: 10px; font-weight: 700; fill: var(--muted); }

@media (max-width: 767px) {
    .dash-header { padding: 10px 14px; flex-direction: column; align-items: stretch; }
    .dash-strip { justify-content: center; }
    .pulse-ticker-track { font-size: 11px; gap: 18px; }
    .weather-chip { min-width: auto; padding: 6px 10px; gap: 6px; }
    .weather-chip-icon { font-size: 19px; }
    .weather-chip-temp { font-size: 13px; }
    .weather-chip-label { display: none; }
    .peak-heat-grid { grid-template-columns: repeat(8, 1fr); }
}
@media (max-width: 479px) {
    .peak-heat-grid { grid-template-columns: repeat(6, 1fr); }
}
