/* ═══════════════════════════════════════════════════════════════════
   PATRIMYN — Skin Vision UI Pro pour #page-overview
   Adaptatif light / dark (système ou toggle manuel via html.dark)
   Mobile-first par défaut, breakpoints élargis pour desktop
   Aucune logique JS modifiée. Scopé sous `#page-overview`.
   =================================================================== */

#page-overview {
  /* ─── Palette accent (identique light & dark) ─── */
  --vu-cyan: #5BA8E8;
  --vu-violet: #8B83F0;
  --vu-vert: #5DCAA5;
  --vu-rouge: #D4726C;
  --vu-or: #C9A96E;

  /* ─── Defaults LIGHT MODE ─── */
  --vu-page-bg: #F0EEE9;
  --vu-page-overlay:
    radial-gradient(ellipse 800px 600px at 15% 0%, rgba(91, 168, 232, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse 600px 400px at 90% 30%, rgba(139, 131, 240, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse 1000px 600px at 50% 100%, rgba(201, 169, 110, 0.08) 0%, transparent 60%);
  --vu-text: #1B2A4A;
  --vu-text-2: rgba(27, 42, 74, 0.65);
  --vu-text-3: rgba(27, 42, 74, 0.45);
  --vu-surface: rgba(255, 255, 255, 0.65);
  --vu-surface-strong: rgba(255, 255, 255, 0.85);
  --vu-border: rgba(27, 42, 74, 0.08);
  --vu-border-strong: rgba(27, 42, 74, 0.16);
  --vu-shadow: 0 8px 24px rgba(27, 42, 74, 0.08);
  --vu-shadow-strong: 0 12px 32px rgba(27, 42, 74, 0.10);
  --vu-shine: linear-gradient(135deg, rgba(255, 255, 255, 0.55) 0%, transparent 50%);
  --vu-period-bg: rgba(27, 42, 74, 0.04);
  --vu-asset-hover: rgba(27, 42, 74, 0.04);

  /* Application */
  background: var(--vu-page-overlay), var(--vu-page-bg) !important;
  border-radius: 22px;
  padding: 24px !important;
  color: var(--vu-text);
}

/* ─── DARK MODE (système) ─── */
@media (prefers-color-scheme: dark) {
  #page-overview {
    --vu-page-bg: #050B17;
    --vu-page-overlay:
      radial-gradient(ellipse 800px 600px at 15% 0%, rgba(91, 168, 232, 0.10) 0%, transparent 60%),
      radial-gradient(ellipse 600px 400px at 90% 30%, rgba(139, 131, 240, 0.07) 0%, transparent 60%),
      radial-gradient(ellipse 1000px 600px at 50% 100%, rgba(212, 184, 130, 0.05) 0%, transparent 60%);
    --vu-text: #F0EDE6;
    --vu-text-2: rgba(240, 237, 230, 0.65);
    --vu-text-3: rgba(240, 237, 230, 0.40);
    --vu-surface: rgba(15, 28, 51, 0.55);
    --vu-surface-strong: rgba(27, 42, 74, 0.7);
    --vu-border: rgba(255, 255, 255, 0.06);
    --vu-border-strong: rgba(255, 255, 255, 0.12);
    --vu-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
    --vu-shadow-strong: 0 12px 32px rgba(0, 0, 0, 0.32);
    --vu-shine: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, transparent 50%);
    --vu-period-bg: rgba(255, 255, 255, 0.04);
    --vu-asset-hover: rgba(255, 255, 255, 0.03);
  }
}

/* ─── DARK MODE (toggle manuel via html.dark) ─── */
html.dark #page-overview {
  --vu-page-bg: #050B17;
  --vu-page-overlay:
    radial-gradient(ellipse 800px 600px at 15% 0%, rgba(91, 168, 232, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse 600px 400px at 90% 30%, rgba(139, 131, 240, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse 1000px 600px at 50% 100%, rgba(212, 184, 130, 0.05) 0%, transparent 60%);
  --vu-text: #F0EDE6;
  --vu-text-2: rgba(240, 237, 230, 0.65);
  --vu-text-3: rgba(240, 237, 230, 0.40);
  --vu-surface: rgba(15, 28, 51, 0.55);
  --vu-surface-strong: rgba(27, 42, 74, 0.7);
  --vu-border: rgba(255, 255, 255, 0.06);
  --vu-border-strong: rgba(255, 255, 255, 0.12);
  --vu-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  --vu-shadow-strong: 0 12px 32px rgba(0, 0, 0, 0.32);
  --vu-shine: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, transparent 50%);
  --vu-period-bg: rgba(255, 255, 255, 0.04);
  --vu-asset-hover: rgba(255, 255, 255, 0.03);
}

/* ═══════════════════════ HERO (toujours sombre — focus visuel) ═══════════════════════
   Le hero garde le gradient bleu-nuit dans les deux modes pour créer un point d'ancrage
   visuel premium, indépendant du thème. */
#page-overview .ov-hero {
  position: relative;
  background: linear-gradient(135deg, #0A1A36 0%, #1B2A4A 50%, #2A3F6E 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 28px 32px;
  margin-bottom: 18px;
  overflow: hidden;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.20);
  color: #F0EDE6;
}
#page-overview .ov-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 600px 400px at 75% 50%, rgba(91, 168, 232, 0.22) 0%, transparent 70%);
  pointer-events: none;
}
#page-overview .ov-hero-content {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
}
#page-overview .ov-hero-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(240, 237, 230, 0.65);
  margin-bottom: 6px;
  font-weight: 500;
}
#page-overview #topbar-greeting {
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 1.1;
  color: #F0EDE6;
  font-weight: 400;
  margin: 0 0 10px;
  letter-spacing: -0.3px;
}
#page-overview .ov-hero-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: rgba(240, 237, 230, 0.65);
  flex-wrap: wrap;
}
#page-overview .ov-hero-meta #topbar-date {
  color: rgba(240, 237, 230, 0.65);
  font-size: 12.5px;
}
#page-overview .ov-hero-art {
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 280px;
  height: 280px;
  pointer-events: none;
  opacity: 0.85;
}
#page-overview .ov-feedback-btn {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  color: #F0EDE6;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s ease;
  flex-shrink: 0;
}
#page-overview .ov-feedback-btn:hover { background: rgba(255, 255, 255, 0.16); }
#page-overview .ov-feedback-btn svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* Cache les data sinks devenus invisibles */
#page-overview .ov-legacy-sink { display: none !important; }

/* ═══════════════════════ DASHBOARD HEADER ═══════════════════════ */
#page-overview .ov-dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
#page-overview #overview-date {
  color: var(--vu-text-2);
  font-size: 12px;
  margin: 0;
}
#page-overview #delta-period-selector {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--vu-period-bg);
  border: 1px solid var(--vu-border);
  border-radius: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#page-overview #delta-period-selector::-webkit-scrollbar { display: none; }
#page-overview .delta-period {
  border: none;
  background: transparent;
  padding: 6px 14px;
  font-size: 12px;
  font-family: inherit;
  color: var(--vu-text-2);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
#page-overview .delta-period:hover { color: var(--vu-text); }
#page-overview .delta-period.active {
  background: linear-gradient(135deg, rgba(91, 168, 232, 0.18), rgba(139, 131, 240, 0.18));
  color: var(--vu-text);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--vu-border-strong);
}

/* ═══════════════════════ KPI METRICS ═══════════════════════ */
#page-overview .metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
#page-overview #ov-net-row {
  grid-template-columns: repeat(2, 1fr);
  margin-top: 0 !important;
  margin-bottom: 18px;
}

#page-overview .metric {
  background: var(--vu-surface);
  border: 1px solid var(--vu-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--vu-shadow);
}
/* Neutralise le legacy `.metric::before` (top:-30%; right:-30%; width:60%; height:60%)
   qui créait un overlay 60% en haut-droite au lieu de couvrir toute la card. */
#page-overview .metric::before {
  content: '';
  position: absolute;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: auto !important;
  height: auto !important;
  background: var(--vu-shine);
  pointer-events: none;
  border-radius: inherit;
  transform: none !important;
  transition: none !important;
}
#page-overview .metric:hover {
  transform: translateY(-2px);
  border-color: var(--vu-border-strong);
  box-shadow: var(--vu-shadow-strong);
}
#page-overview .metric.primary {
  background:
    linear-gradient(135deg, rgba(91, 168, 232, 0.16) 0%, rgba(139, 131, 240, 0.16) 100%),
    var(--vu-surface);
  border-color: rgba(91, 168, 232, 0.32);
}
#page-overview .metric.tx-metric.active {
  border-color: var(--vu-cyan);
  box-shadow:
    0 0 0 1px rgba(91, 168, 232, 0.4),
    0 12px 32px rgba(91, 168, 232, 0.18);
}

#page-overview .metric-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--vu-text-2);
  font-weight: 600;
  margin-bottom: 8px;
}
#page-overview .metric.primary .metric-label { color: var(--vu-cyan); }

#page-overview .metric-value {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  color: var(--vu-text);
  line-height: 1.1;
}

#page-overview .metric-delta {
  margin-top: 8px;
  font-size: 11.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--vu-text-2);
}
#page-overview .metric-delta .pnl-up,
#page-overview .metric-delta .pnl-down {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
#page-overview .metric-delta .pnl-up {
  background: rgba(93, 202, 165, 0.16);
  color: var(--vu-vert);
}
#page-overview .metric-delta .pnl-down {
  background: rgba(212, 114, 108, 0.16);
  color: var(--vu-rouge);
}

/* ═══════════════════════ CARDS (charts + assets) ═══════════════════════ */
#page-overview .two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

#page-overview .card {
  background: var(--vu-surface);
  border: 1px solid var(--vu-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--vu-shadow-strong);
}
/* Neutralise le legacy `.card::before` (top:-50%; left:-50%; width:200%; height:200%
   + transition transform au hover qui faisait apparaître un "second cadre fantôme"
   au survol). On ramène le pseudo-élément aux 4 coins de la card et on tue la
   transition + le transform pour figer le shine. */
#page-overview .card::before {
  content: '';
  position: absolute;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: auto !important;
  height: auto !important;
  background: var(--vu-shine);
  pointer-events: none;
  border-radius: inherit;
  transform: none !important;
  transition: none !important;
}
#page-overview .card:hover::before {
  transform: none !important;
}
#page-overview .two-col .card { margin-bottom: 0; }

#page-overview .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}
#page-overview .card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--vu-text);
}

/* Donut legend */
#page-overview .legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}
#page-overview .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--vu-text-2);
}
#page-overview .legend-dot {
  width: 9px; height: 9px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Asset list */
#page-overview .asset-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border-bottom: 1px solid var(--vu-border);
  transition: background 0.18s ease, transform 0.18s ease;
  position: relative;
  z-index: 1;
}
#page-overview .asset-row:last-child { border-bottom: none; }
#page-overview .asset-row:hover {
  background: var(--vu-asset-hover);
  transform: translateX(2px);
}
#page-overview .asset-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
#page-overview .asset-info { flex: 1; min-width: 0; }
#page-overview .asset-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--vu-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#page-overview .asset-sub {
  font-size: 11px;
  color: var(--vu-text-3);
  margin-top: 2px;
}
#page-overview .asset-right { text-align: right; flex-shrink: 0; }
#page-overview .asset-amount {
  font-size: 14px;
  font-weight: 600;
  color: var(--vu-text);
  font-variant-numeric: tabular-nums;
}
#page-overview .asset-pct {
  font-size: 11px;
  color: var(--vu-text-3);
  margin-top: 2px;
}

/* Banners */
#page-overview #install-banner {
  border-color: var(--vu-border-strong) !important;
  border-radius: 16px !important;
  box-shadow: var(--vu-shadow);
}
#page-overview #completion-bar {
  background: var(--vu-surface) !important;
  border-color: var(--vu-border) !important;
  border-radius: 14px !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
#page-overview #completion-bar > div:first-child > div {
  color: var(--vu-text) !important;
}

/* Divers */
#page-overview .page-title { display: none; }
#page-overview .page-sub { color: var(--vu-text-2); }
#page-overview .chart-wrap { position: relative; z-index: 1; }

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════ */

/* ── Tablet (≤1100px) : sub-tab et charts en 1 colonne ── */
@media (max-width: 1100px) {
  #page-overview .two-col {
    grid-template-columns: 1fr;
  }
}

/* ── Tablette portrait (≤900px) : 2 KPIs par ligne ── */
@media (max-width: 900px) {
  #page-overview .metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  #page-overview .ov-hero {
    padding: 24px;
    min-height: 130px;
  }
  #page-overview .ov-hero-art {
    width: 220px;
    height: 220px;
    right: -30px;
  }
}

/* ── Mobile (≤700px) ── */
@media (max-width: 700px) {
  #page-overview {
    padding: 14px !important;
    border-radius: 14px;
  }

  /* Hero compact mobile : layout colonne, orbe cachée */
  #page-overview .ov-hero {
    padding: 20px;
    min-height: auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    border-radius: 16px;
  }
  #page-overview .ov-hero-art { display: none; }
  #page-overview #topbar-greeting {
    font-size: 24px;
    margin-bottom: 8px;
  }
  #page-overview .ov-hero-eyebrow { font-size: 10.5px; }
  #page-overview .ov-feedback-btn {
    align-self: flex-start;
    padding: 6px 12px;
    font-size: 11px;
  }

  /* Dashboard header : empile sub + selector */
  #page-overview .ov-dash-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  #page-overview #delta-period-selector {
    align-self: flex-start;
    width: 100%;
    max-width: 100%;
  }
  #page-overview .delta-period {
    flex: 1;
    text-align: center;
    padding: 7px 8px;
    font-size: 11.5px;
  }

  /* KPI : 1 colonne sur très petit, 2 sur normal */
  #page-overview .metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  #page-overview .metric {
    padding: 14px 16px;
    border-radius: 14px;
  }
  #page-overview .metric-label {
    font-size: 9.5px;
    margin-bottom: 6px;
  }
  #page-overview .metric-value {
    font-size: 20px;
  }
  #page-overview .metric-delta {
    margin-top: 6px;
    font-size: 10.5px;
  }
  #page-overview .metric-delta .pnl-up,
  #page-overview .metric-delta .pnl-down {
    padding: 1px 6px;
    font-size: 10px;
  }

  /* Cards (charts + assets) compactes */
  #page-overview .card {
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 14px;
  }
  #page-overview .card-title { font-size: 14px; }

  /* Asset list compact */
  #page-overview .asset-row {
    padding: 10px 8px;
    gap: 10px;
  }
  #page-overview .asset-icon {
    width: 32px; height: 32px;
    border-radius: 9px;
    font-size: 11px;
  }
  #page-overview .asset-name { font-size: 13px; }
  #page-overview .asset-amount { font-size: 13px; }

  /* Charts hauteur réduite */
  #page-overview .chart-wrap {
    height: 220px !important;
  }
}

/* ── Mobile très petit (≤380px) : KPI en colonne unique ── */
@media (max-width: 380px) {
  #page-overview .metrics {
    grid-template-columns: 1fr;
  }
  #page-overview #ov-net-row {
    grid-template-columns: 1fr;
  }
}
