/* ============================================================================
 * screen-cockpit.css — “Apple” polish for dashboards / cockpit.
 *
 * PRESENTATION ONLY. Everything is handled by the root selector
 * `.cockpit-screen` (set on the <main> of the affected views): this file is
 * loaded globally but ONLY AFFECTS the cockpit/dashboard pages — zero
 * leakage into the ~200 other views.
 *
 * Scope: views/gestion/dashboard.ejs · views/admin/dashboard.ejs ·
 *             views/admin/cockpit.ejs.
 *
 * KIT: we USE the kit classes (.btn-pill, .halo, .empty-state,
 * .skeleton…) without ever redefining them. The kit tokens (--ease, --dur*,
 * r-pill) are referenced with a `var(--token, fallback)` fallback so the
 * rendering stays correct even while the kit has not yet been merged into staging.
 * We DO NOT TOUCH app.css.
 * ========================================================================== */

/* Header: branded blue halo behind the title --------------------------- */
/* The .halo class comes from the kit. Here we only POSITION the halo in the
   cockpit header context (without redefining the halo itself). */
.cockpit-screen .app-page-header {
  position: relative;
  isolation: isolate;
}
.cockpit-screen .app-page-header::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -40%;
  left: -2%;
  width: 320px;
  height: 320px;
  max-width: 60%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(
    circle at center,
    rgba(94, 127, 168, 0.18) 0%,
    rgba(94, 127, 168, 0.07) 42%,
    transparent 72%
  );
  filter: blur(8px);
  opacity: 0.9;
}
:root[data-theme="dark"] .cockpit-screen .app-page-header::before {
  background: radial-gradient(
    circle at center,
    rgba(120, 158, 209, 0.22) 0%,
    rgba(120, 158, 209, 0.09) 42%,
    transparent 72%
  );
}

/* Cards: soft shadows + natural lift on hover -------------------------- */
.cockpit-screen .app-card,
.cockpit-screen .app-stat-card {
  /* Signature: keep the glass rim; do not flatten it to shadow-sm
     alone, or the cockpit/dashboard cards lose their Liquid Glass depth. */
  box-shadow: var(--lg-highlight), var(--lg-shadow);
  transition:
    transform var(--dur-2, 0.22s) var(--ease-spring, cubic-bezier(0.22, 1, 0.36, 1)),
    box-shadow var(--dur-2, 0.22s) var(--ease-spring, cubic-bezier(0.22, 1, 0.36, 1)),
    border-color var(--dur-1, 0.16s) var(--ease, ease);
  will-change: transform;
}
/* Hover only on fine-pointer devices (mouse), never on touch —
   consistent with the app's touch lock. */
@media (hover: hover) and (pointer: fine) {
  .cockpit-screen .app-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--lg-highlight), var(--lg-shadow-lg);
  }
  .cockpit-screen .app-card:hover {
    box-shadow: var(--lg-highlight), var(--lg-shadow-lg);
  }
}

/* KPIs: aligned figures (tabular-nums) --------------------------------- */
.cockpit-screen .app-stat-value,
.cockpit-screen .app-kpi-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Pill-shaped header buttons ------------------------------------------ */
/* .btn-pill comes from the kit. Fallback: if the kit is not loaded, we still
   round the cockpit header buttons for the “pill” look. */
.cockpit-screen .app-page-header .app-btn {
  border-radius: var(--r-pill, 999px);
}

/* --- Skeleton shimmer on the « en direct » widgets ---------------------
 * The .skeleton class comes from the kit (with its animation). Until the kit is
 * merged, this LOCAL fallback (scoped to .cockpit-screen) gives the same shimmer to
 * elements waiting for data. The selector is deliberately scoped so it does not
 * redefine the kit's global class outside the cockpit.
 * --------------------------------------------------------------------------- */
.cockpit-screen .ck-skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm, 6px);
  background: var(--cream-2, #e9eef5);
  color: transparent !important;
  min-height: 1em;
}
.cockpit-screen .ck-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 100%
  );
  animation: ck-shimmer 1.4s var(--ease, ease) infinite;
}
:root[data-theme="dark"] .cockpit-screen .ck-skeleton {
  background: rgba(255, 255, 255, 0.08);
}
:root[data-theme="dark"] .cockpit-screen .ck-skeleton::after {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.12) 50%,
    transparent 100%
  );
}
@keyframes ck-shimmer {
  100% { transform: translateX(100%); }
}

/* Pending value block (large live KPI): fixed width to prevent the
   layout « saut » when the real value arrives. */
.cockpit-screen .ck-skeleton-kpi {
  display: inline-block;
  min-width: 3.2ch;
  height: 1em;
  vertical-align: middle;
}

/* --- « en direct » badge: soft pulse ------------------------------------- */
.cockpit-screen .ck-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--system-blue, #2563eb);
  animation: ck-pulse 1.8s var(--ease, ease-in-out) infinite;
}
@keyframes ck-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.82); }
}

/* Accessibility: reduced motion --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .cockpit-screen .app-card,
  .cockpit-screen .app-stat-card {
    transition: none;
  }
  .cockpit-screen .app-stat-card:hover,
  .cockpit-screen .app-card:hover {
    transform: none;
  }
  .cockpit-screen .ck-skeleton::after,
  .cockpit-screen .ck-live-dot {
    animation: none;
  }
  .cockpit-screen .ck-skeleton::after { display: none; }
}
