/* =========================================================
   page-sales-analysis.css
   業績分析頁（v3 暖色系）
   依賴：ewoooc-tokens.css → ewoooc-tokens-v2-alias.css → ewoooc-shell.css

   來源：sales_analysis.html inline <style> 519 行 → token 化 / 暖色化
   - Loading overlay：移除 紫(#4F46E5) / 粉(#EC4899) / 橙(#F59E0B) 三色 → 全焦糖色階
   - Flatpickr：移除 #3498db 藍 → 焦糖橘
   - Form focus / Card hover：藍色 #3498db → page-accent
   - bg-primary / btn-primary 漸層：保留 alias 暖色（已是 caramel→mahogany）
   ========================================================= */

/* ---------- Page scope helpers ---------- */
.sales-analysis-page {
  font-family: var(--momo-font-body, 'Inter', system-ui, sans-serif);
}

.sales-analysis-page .card {
  border: 1px solid var(--momo-border-strong);
  border-radius: 10px;
  box-shadow: var(--momo-shadow-soft);
  margin-bottom: 1.4rem;
  background: var(--momo-surface);
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.sales-analysis-page .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--momo-text-strong) 12%, transparent);
}

.sales-analysis-page .card-header {
  background: color-mix(in srgb, var(--momo-page-accent) 6%, var(--momo-surface));
  border-bottom: 1px solid var(--momo-border-subtle);
  font-weight: 700;
  color: var(--momo-text-strong);
  padding: 1rem 1.2rem;
  border-radius: 10px 10px 0 0;
}

.sales-analysis-page .card-header i {
  color: var(--momo-page-accent);
}

/* ---------- Form controls ---------- */
.sales-analysis-page .form-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--momo-text-muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sales-analysis-page .input-group-text {
  background: color-mix(in srgb, var(--momo-text-strong) 5%, var(--momo-surface));
  border-color: var(--momo-border-strong);
  color: var(--momo-text-muted);
}

.sales-analysis-page .form-control,
.sales-analysis-page .form-select {
  border: 1px solid var(--momo-border-strong);
  background: var(--momo-surface);
  color: var(--momo-text-strong);
  padding: 0.55rem 0.9rem;
  border-radius: 7px;
  font-size: 0.94rem;
}

.sales-analysis-page .form-control:focus,
.sales-analysis-page .form-select:focus {
  border-color: var(--momo-page-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--momo-page-accent) 18%, transparent);
}

.sales-analysis-page .btn {
  border-radius: 7px;
  padding: 0.55rem 1.1rem;
  font-weight: 600;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.sales-analysis-page .dropdown-menu { z-index: 1050 !important; }

/* ---------- Bootstrap colour overrides (warm) ---------- */
.sales-analysis-page .bg-primary,
.sales-analysis-page .btn-primary {
  background: var(--momo-page-accent) !important;
  border-color: color-mix(in srgb, var(--momo-page-accent) 80%, var(--momo-text-strong)) !important;
  color: var(--momo-on-accent, var(--momo-on-accent, #fff8ef)) !important;
}

.sales-analysis-page .btn-primary:hover {
  background: color-mix(in srgb, var(--momo-page-accent) 90%, var(--momo-text-strong)) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 14px color-mix(in srgb, var(--momo-page-accent) 32%, transparent);
}

.sales-analysis-page .btn-success,
.sales-analysis-page .bg-success {
  background: var(--momo-tag-olive) !important;
  border-color: color-mix(in srgb, var(--momo-tag-olive) 80%, var(--momo-text-strong)) !important;
  color: var(--momo-on-accent, var(--momo-on-accent, #fff8ef)) !important;
}

.sales-analysis-page .text-primary,
.sales-analysis-page .text-success {
  color: var(--momo-page-accent) !important;
}

.sales-analysis-page .badge.bg-secondary {
  background: color-mix(in srgb, var(--momo-text-muted) 80%, var(--momo-text-strong)) !important;
  color: var(--momo-on-accent, var(--momo-on-accent, #fff8ef)) !important;
}

/* ---------- KPI cards ---------- */
.sales-analysis-page .kpi-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--momo-border-strong);
  border-left-width: 4px;
  border-radius: 10px;
}

.sales-analysis-page .kpi-card .icon-bg {
  position: absolute;
  right: -12px;
  bottom: -12px;
  font-size: 5rem;
  opacity: 0.1;
  color: currentColor;
  transform: rotate(-12deg);
  pointer-events: none;
}

.sales-analysis-page .kpi-value {
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--momo-text-strong);
  margin-bottom: 0.25rem;
  line-height: 1.1;
}

.sales-analysis-page .kpi-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--momo-text-muted);
}

/* ---------- Tables ---------- */
.sales-analysis-page .table th {
  font-weight: 700;
  color: var(--momo-text-strong);
  background: color-mix(in srgb, var(--momo-page-accent) 12%, var(--momo-surface));
  border-bottom: 2px solid var(--momo-page-accent);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.8rem 0.85rem;
}

.sales-analysis-page .table tbody td {
  padding: 0.65rem 0.85rem;
  vertical-align: middle;
  color: var(--momo-text-strong);
  border-bottom: 1px solid var(--momo-border-subtle);
}

.sales-analysis-page .table-hover tbody tr:hover {
  background: color-mix(in srgb, var(--momo-page-accent) 6%, var(--momo-surface));
}

.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Loading Overlay (warm reskin) ---------- */
#loadingOverlay {
  position: fixed;
  inset: 0;
  background: var(--momo-surface-raised);
  z-index: 9999;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 24px;
  backdrop-filter: blur(8px);
}

#loadingOverlay .loading-logo-container {
  position: relative;
  width: 160px;
  height: 160px;
  display: grid;
  place-items: center;
}

#loadingOverlay .loading-logo {
  z-index: 3;
  font-size: 2.5rem;
  font-weight: 800;
  font-family: var(--momo-font-display, 'Inter', system-ui, sans-serif);
  background: var(--momo-surface-raised);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 4px;
  filter: drop-shadow(0 4px 15px color-mix(in srgb, var(--momo-page-accent) 32%, transparent));
  animation: cloud-float 3s ease-in-out infinite;
}

@keyframes cloud-float {
  0%, 100% { transform: translateY(0) translateX(0) scale(1); }
  25%      { transform: translateY(-15px) translateX(5px) scale(1.02); }
  50%      { transform: translateY(-8px) translateX(-3px) scale(1); }
  75%      { transform: translateY(-20px) translateX(3px) scale(1.01); }
}

#loadingOverlay .logo-ring {
  position: absolute;
  width: 150px; height: 150px;
  border: 4px solid transparent;
  border-top-color: var(--momo-page-accent);
  border-right-color: var(--momo-tag-rust);
  border-radius: 50%;
  animation: ring-spin 2s linear infinite;
}

#loadingOverlay .logo-ring-inner {
  position: absolute;
  width: 120px; height: 120px;
  border: 3px solid transparent;
  border-bottom-color: var(--momo-tag-mahogany);
  border-left-color: var(--momo-tag-honey);
  border-radius: 50%;
  animation: ring-spin-reverse 1.5s linear infinite;
}

#loadingOverlay .logo-pulse {
  position: absolute;
  width: 100px; height: 100px;
  background: color-mix(in srgb, var(--momo-page-accent) 16%, transparent);
  border-radius: 50%;
  animation: pulse-expand 2s ease-out infinite;
}

@keyframes ring-spin {
  to { transform: rotate(360deg); }
}
@keyframes ring-spin-reverse {
  to { transform: rotate(-360deg); }
}
@keyframes pulse-expand {
  0%   { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

#loadingOverlay .orbit-particles {
  position: absolute;
  width: 160px; height: 160px;
  animation: orbit-rotate 4s linear infinite;
}
#loadingOverlay .orbit-particle {
  position: absolute;
  width: 8px; height: 8px;
  background: var(--momo-surface-raised);
  border-radius: 50%;
  box-shadow: 0 0 10px color-mix(in srgb, var(--momo-page-accent) 60%, transparent);
}
#loadingOverlay .orbit-particle:nth-child(1) { top: 0;     left: 50%; transform: translateX(-50%); }
#loadingOverlay .orbit-particle:nth-child(2) { top: 50%;   right: 0;  transform: translateY(-50%); }
#loadingOverlay .orbit-particle:nth-child(3) { bottom: 0;  left: 50%; transform: translateX(-50%); }
#loadingOverlay .orbit-particle:nth-child(4) { top: 50%;   left: 0;   transform: translateY(-50%); }

@keyframes orbit-rotate { to { transform: rotate(360deg); } }

#loadingOverlay .sparkles { position: absolute; width: 180px; height: 180px; }
#loadingOverlay .sparkle {
  position: absolute;
  width: 4px; height: 4px;
  background: var(--momo-tag-honey);
  border-radius: 50%;
  animation: sparkle-twinkle 1.5s ease-in-out infinite;
}
#loadingOverlay .sparkle:nth-child(1) { top: 10%;    left: 20%;  animation-delay: 0s; }
#loadingOverlay .sparkle:nth-child(2) { top: 5%;     right: 25%; animation-delay: 0.3s; }
#loadingOverlay .sparkle:nth-child(3) { bottom: 15%; right: 15%; animation-delay: 0.6s; }
#loadingOverlay .sparkle:nth-child(4) { bottom: 10%; left: 25%;  animation-delay: 0.9s; }
#loadingOverlay .sparkle:nth-child(5) { top: 30%;    left: 5%;   animation-delay: 1.2s; }
#loadingOverlay .sparkle:nth-child(6) { top: 25%;    right: 5%;  animation-delay: 0.4s; }

@keyframes sparkle-twinkle {
  0%, 100% { transform: scale(0); opacity: 0; }
  50%      { transform: scale(1); opacity: 1; }
}

#loadingOverlay .loading-text {
  font-size: 1.15rem;
  color: var(--momo-tag-mahogany);
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.04em;
}

#loadingOverlay .loading-hint {
  font-size: 0.85rem;
  color: var(--momo-text-muted);
  text-align: center;
  max-width: 300px;
}

#loadingOverlay .loading-progress {
  width: 200px; height: 4px;
  background: color-mix(in srgb, var(--momo-page-accent) 18%, transparent);
  border-radius: 2px;
  overflow: hidden;
}

#loadingOverlay .loading-progress-bar {
  height: 100%;
  background: var(--momo-surface-raised);
  background-size: 200% 100%;
  animation: progress-flow 1.5s linear infinite;
  width: 100%;
}

@keyframes progress-flow {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ---------- Flatpickr (warm) ---------- */
.flatpickr-input { cursor: pointer; }

.flatpickr-calendar {
  border-radius: 10px !important;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--momo-text-strong) 18%, transparent) !important;
  border: 1px solid var(--momo-border-strong) !important;
  background: var(--momo-surface) !important;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--momo-page-accent) !important;
  border-color: var(--momo-page-accent) !important;
  color: var(--momo-on-accent, var(--momo-on-accent, #fff8ef)) !important;
}

.flatpickr-day.selected:hover {
  background: color-mix(in srgb, var(--momo-page-accent) 90%, var(--momo-text-strong)) !important;
}

.flatpickr-day:hover {
  background: color-mix(in srgb, var(--momo-page-accent) 12%, var(--momo-surface));
  border-color: color-mix(in srgb, var(--momo-page-accent) 25%, var(--momo-border-subtle));
}

.flatpickr-months .flatpickr-month {
  background: var(--momo-page-accent);
  color: var(--momo-on-accent, var(--momo-on-accent, #fff8ef));
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
  background: var(--momo-page-accent);
  color: var(--momo-on-accent, var(--momo-on-accent, #fff8ef));
}

.flatpickr-current-month .numInputWrapper { color: var(--momo-on-accent, var(--momo-on-accent, #fff8ef)); }

.flatpickr-current-month .flatpickr-monthDropdown-months:hover {
  background: color-mix(in srgb, var(--momo-page-accent) 90%, var(--momo-text-strong));
}

/* ---------- Custom dark navbar (legacy, kept for safety) ---------- */
.navbar.bg-custom-dark {
  background: var(--momo-surface-raised);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--momo-text-strong) 18%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--momo-on-accent, #fff8ef) 10%, transparent);
}
.navbar.bg-custom-dark .navbar-brand,
.navbar.bg-custom-dark .navbar-nav .nav-link.active { color: var(--momo-on-accent, #fff8ef); font-weight: 600; }
.navbar.bg-custom-dark .navbar-nav .nav-link { color: rgba(255,255,255,0.85); font-weight: 500; }
.navbar.bg-custom-dark .navbar-nav .nav-link:hover { color: var(--momo-on-accent, #fff8ef); }
.navbar.bg-custom-dark .navbar-text { color: rgba(255,255,255,0.75); }

/* ---------- ABC / YoY / Vendor banners ---------- */
.sales-analysis-page .panel-banner {
  background: var(--momo-surface-raised);
  border: 1px solid var(--momo-border-strong);
  border-radius: 10px;
  padding: 1.2rem 1.4rem;
}

.sales-analysis-page .card.border-primary {
  border-color: color-mix(in srgb, var(--momo-page-accent) 50%, var(--momo-border-strong)) !important;
  border-left-width: 4px !important;
  border-left-color: var(--momo-page-accent) !important;
}
