/* ============================================
   RÉTROPLANNING 3.0 — Cockpit visuel du projet
   Stylesheet aligné design system "editorial" + Joy hues.
   ============================================ */

.rp-cockpit {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 4px 0;
}

/* When embedded inside the overview tab, add a generous top margin so the
   cockpit visually breathes from the budget/contract blocks above. */
.overview-rp-embed {
  margin-top: 24px;
}

/* ---- Loading / error ---- */
.rp-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; padding: 60px 20px;
  color: var(--text-muted, #888);
}
.rp-loading-spinner {
  width: 18px; height: 18px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%;
  animation: rp-spin 0.8s linear infinite;
}
@keyframes rp-spin { to { transform: rotate(360deg); } }
.rp-error {
  padding: 20px; border-radius: 8px;
  background: #fee; color: #b00; border: 1px solid #fcc;
}

/* ============================================
   HEADER SYNTHÈSE — cockpit KPIs
   ============================================ */
.rp-header {
  padding: 28px 28px 24px;
}
.rp-header-meta {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 22px;
}
.rp-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.rp-kpi {
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--surface-alt, #fbf9f6);
  border: 1px solid var(--border, #ece6dd);
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
  transition: transform .15s ease, box-shadow .15s ease;
}
.rp-kpi:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.05); }
.rp-kpi-hero {
  background: linear-gradient(135deg, var(--joy-rose-tint, #fce8ec), var(--joy-apricot-tint, #fbeede));
  border-color: transparent;
}
.rp-kpi[data-hue="rose"]    { border-left: 3px solid var(--joy-rose-ink); }
.rp-kpi[data-hue="sage"]    { border-left: 3px solid var(--joy-sage-ink); }
.rp-kpi[data-hue="sky"]     { border-left: 3px solid var(--joy-sky-ink); }
.rp-kpi[data-hue="apricot"] { border-left: 3px solid var(--joy-apricot-ink); }
.rp-kpi[data-hue="plum"]    { border-left: 3px solid var(--joy-plum-ink); }
.rp-kpi[data-hue="gold"]    { border-left: 3px solid var(--joy-gold-ink); }

.rp-kpi-num {
  font-family: var(--font-serif, 'Cormorant Garamond', Georgia, serif);
  font-size: 2.2rem; font-weight: 500; line-height: 1.1;
  color: var(--text-primary, #2a2520);
}
.rp-kpi-num-xl { font-size: 3rem; }
.rp-kpi-num-currency { font-size: 1.6rem; }
.rp-kpi-pct {
  font-size: .55em; opacity: .65; margin-left: 4px;
  font-weight: 400;
}
.rp-kpi-sub {
  font-size: .78rem;
  color: var(--text-muted, #8a7f72);
  letter-spacing: .02em;
}

/* Progress bar */
.rp-progress-bar {
  height: 5px; border-radius: 3px;
  background: rgba(0,0,0,.06);
  overflow: hidden;
  margin: 4px 0 2px;
}
.rp-progress-fill {
  height: 100%;
  background: var(--joy-rose-ink, #c2546b);
  border-radius: 3px;
  transition: width .35s ease;
}

.rp-header-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 8px;
  border-top: 1px solid var(--border, #ece6dd);
  padding-top: 18px;
}

/* ============================================
   TIMELINE FRIEZE — horizontal life-line
   ============================================ */
.rp-frieze {
  padding: 22px 28px 30px;
}
.rp-frieze-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.rp-frieze-sub {
  font-size: .78rem; color: var(--text-muted);
  letter-spacing: .03em;
}
/* Horizontal scroll container — receives the pinch/ctrl-wheel listeners and
   lets the inner .rp-frieze-track expand to width=100%*zoom when zoomed in. */
.rp-frieze-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 -14px;       /* bleed to card edge for full grab area */
  padding: 0 14px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  touch-action: pan-x;   /* allow horizontal pan, we hijack 2-finger pinch */
}
.rp-frieze-scroll::-webkit-scrollbar { height: 6px; }
.rp-frieze-scroll::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.15);
  border-radius: 3px;
}

.rp-frieze-track {
  position: relative;
  height: 78px;
  padding: 0 14px;
  min-width: 100%;
  transition: width .18s ease;
}

/* Zoom controls (right side of the frieze header) */
.rp-frieze-zoom {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--color-border, #E7DFD4);
  border-radius: 999px;
  padding: 3px;
  background: var(--color-bg-card, #fff);
}
.rp-frieze-zoom-btn,
.rp-frieze-zoom-reset {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: var(--color-text, #2a2520);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  line-height: 1;
  transition: background .15s ease;
}
.rp-frieze-zoom-btn { font-weight: 600; min-width: 28px; }
.rp-frieze-zoom-btn:hover:not(:disabled),
.rp-frieze-zoom-reset:hover:not(:disabled) {
  background: var(--color-bg-subtle, #FBF8F3);
}
.rp-frieze-zoom-btn:disabled,
.rp-frieze-zoom-reset:disabled {
  opacity: .4; cursor: not-allowed;
}
.rp-frieze-zoom-reset {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted, #8A8076);
  min-width: 44px;
}

.rp-frieze-hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--color-text-muted, #8A8076);
  font-style: italic;
  text-align: right;
}
.rp-frieze-rail {
  position: absolute;
  top: 38px; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(to right,
    var(--joy-sage-tint, #e3ecd9) 0%,
    var(--joy-sky-tint, #d9e7f0) 50%,
    var(--joy-rose-tint, #fce8ec) 100%);
  border-radius: 2px;
}
.rp-frieze-grad {
  position: absolute;
  top: 32px;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center;
  pointer-events: none;
}
.rp-frieze-grad-tick {
  width: 1px; height: 14px;
  background: var(--border, #c9c0b3);
}
.rp-frieze-grad-label {
  margin-top: 4px;
  font-size: .68rem;
  letter-spacing: .05em;
  color: var(--text-muted);
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.rp-frieze-grad.is-jourj .rp-frieze-grad-tick {
  width: 2px; height: 22px; margin-top: -4px;
  background: var(--joy-rose-ink);
}
.rp-frieze-grad.is-jourj .rp-frieze-grad-label {
  color: var(--joy-rose-ink);
  font-weight: 700;
  font-family: var(--font-serif, 'Cormorant Garamond', Georgia, serif);
  font-size: .82rem;
}

.rp-frieze-today {
  position: absolute;
  top: 0; bottom: 0;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 2;
}
.rp-frieze-today-line {
  position: absolute;
  top: 18px; bottom: 24px;
  left: 50%;
  width: 2px;
  background: var(--joy-gold-ink);
  transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(184, 134, 11, .4);
}
.rp-frieze-today-pill {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  background: var(--joy-gold-ink);
  color: #fff;
  font-size: .65rem; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.rp-frieze-pin {
  position: absolute;
  top: 30px;
  transform: translateX(-50%);
  width: 22px; height: 22px;
  border: 0; background: transparent;
  padding: 0; cursor: pointer;
  z-index: 3;
}
.rp-frieze-pin-dot {
  display: block;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--joy-gold-ink);
  border: 2px solid var(--surface, #fff);
  margin: 5px auto;
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.rp-frieze-pin:hover .rp-frieze-pin-dot {
  transform: scale(1.35);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.rp-frieze-pin.rp-event-hue-rose    .rp-frieze-pin-dot { background: var(--joy-rose-ink); }
.rp-frieze-pin.rp-event-hue-sage    .rp-frieze-pin-dot { background: var(--joy-sage-ink); }
.rp-frieze-pin.rp-event-hue-sky     .rp-frieze-pin-dot { background: var(--joy-sky-ink); }
.rp-frieze-pin.rp-event-hue-apricot .rp-frieze-pin-dot { background: var(--joy-apricot-ink); }
.rp-frieze-pin.rp-event-hue-plum    .rp-frieze-pin-dot { background: var(--joy-plum-ink); }
.rp-frieze-pin.rp-event-hue-gold    .rp-frieze-pin-dot { background: var(--joy-gold-ink); }
.rp-frieze-pin.is-done .rp-frieze-pin-dot { opacity: .55; }
.rp-frieze-pin.is-overdue .rp-frieze-pin-dot {
  background: #c0392b;
  animation: rp-pulse 1.4s ease-in-out infinite;
}
@keyframes rp-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192,57,43,.55); }
  50%      { box-shadow: 0 0 0 6px rgba(192,57,43,0); }
}

/* ============================================
   FILTER CHIPS
   ============================================ */
.rp-filters {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 2px 2px;
}
.rp-chip {
  border: 1px solid var(--border, #ece6dd);
  background: var(--surface, #fff);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: .82rem;
  cursor: pointer;
  transition: all .15s ease;
  font-family: inherit;
  letter-spacing: .01em;
}
.rp-chip:hover { background: var(--surface-alt, #fbf9f6); color: var(--text-primary); }
.rp-chip.is-active {
  background: var(--text-primary, #2a2520);
  color: #fff;
  border-color: var(--text-primary, #2a2520);
}

/* Event flash highlight when arriving from frieze click */
.rp-event-flash {
  animation: rp-flash 1.6s ease-out;
}
@keyframes rp-flash {
  0%   { background: var(--joy-gold-tint, #f6ebd0); box-shadow: 0 0 0 3px var(--joy-gold-ink); }
  100% { background: var(--surface-alt, #fbf9f6); box-shadow: none; }
}

/* ============================================
   ALERTES
   ============================================ */
.rp-alerts {
  display: flex; flex-direction: column; gap: 8px;
}
.rp-alert {
  display: flex; gap: 14px; align-items: center;
  padding: 12px 16px;
  border-radius: 10px;
  border-left: 3px solid var(--joy-rose-ink);
  background: var(--joy-rose-tint, #fce8ec);
}
.rp-alert-critical { border-left-color: #c0392b; background: #fdecea; }
.rp-alert-high     { border-left-color: var(--joy-apricot-ink); background: var(--joy-apricot-tint, #fbeede); }
.rp-alert-icon {
  font-size: 1.3rem; line-height: 1;
  flex-shrink: 0;
}
.rp-alert-title { font-weight: 600; color: var(--text-primary); }
.rp-alert-desc { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }

/* ============================================
   BUCKETS — 3 colonnes (À venir / À planifier / Acquis)
   ============================================ */
.rp-buckets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}
.rp-bucket {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #ece6dd);
  border-radius: 14px;
  padding: 20px 18px 22px;
  min-height: 200px;
}
.rp-bucket-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.rp-bucket-count {
  background: var(--surface-alt, #fbf9f6);
  border: 1px solid var(--border, #ece6dd);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.rp-bucket-empty {
  margin-top: 16px;
  font-style: italic; color: var(--text-muted);
  font-size: .88rem;
}
.rp-bucket.is-empty { opacity: .65; }

.rp-bucket-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 14px;
}

/* Variant per bucket: subtle tint on header */
.rp-bucket-upcoming  { border-top: 3px solid var(--joy-sky-ink); }
.rp-bucket-unplanned { border-top: 3px solid var(--joy-gold-ink); }
.rp-bucket-past      { border-top: 3px solid var(--joy-sage-ink); }

/* ============================================
   EVENT CARDS
   ============================================ */
.rp-event {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-alt, #fbf9f6);
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
  transition: all .15s ease;
}
.rp-event:hover {
  border-color: var(--border, #ece6dd);
  background: #fff;
  transform: translateX(2px);
}
.rp-event.is-done { opacity: .72; }
.rp-event.is-done .rp-event-title { text-decoration: line-through; text-decoration-thickness: 1px; }
.rp-event.is-overdue { background: var(--joy-rose-tint, #fce8ec); }

.rp-event-marker {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding-top: 2px;
  width: 22px; flex-shrink: 0;
}
.rp-event-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--joy-gold-ink);
}
.rp-event-icon {
  font-size: 11px; line-height: 1; opacity: .55;
}
.rp-event-hue-rose    .rp-event-dot { background: var(--joy-rose-ink); }
.rp-event-hue-sage    .rp-event-dot { background: var(--joy-sage-ink); }
.rp-event-hue-sky     .rp-event-dot { background: var(--joy-sky-ink); }
.rp-event-hue-apricot .rp-event-dot { background: var(--joy-apricot-ink); }
.rp-event-hue-plum    .rp-event-dot { background: var(--joy-plum-ink); }
.rp-event-hue-gold    .rp-event-dot { background: var(--joy-gold-ink); }

.rp-event-body { flex: 1; min-width: 0; }
.rp-event-title {
  font-weight: 600;
  color: var(--text-primary, #2a2520);
  font-size: .94rem;
  margin-bottom: 2px;
}
.rp-event-desc {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rp-event-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: .72rem; color: var(--text-muted);
}
.rp-event-date {
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  font-weight: 500;
}
.rp-event-dleft {
  background: var(--joy-rose-tint);
  color: var(--joy-rose-ink);
  padding: 1px 8px; border-radius: 999px;
  font-weight: 600;
}
.rp-event.is-overdue .rp-event-dleft {
  background: #c0392b; color: #fff;
}
.rp-event-source {
  opacity: .7;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: .65rem;
}
.rp-event-source-custom {
  color: var(--joy-gold-ink);
  font-weight: 600;
}

.rp-event-edit {
  position: absolute;
  top: 8px; right: 8px;
  opacity: 0;
  transition: opacity .15s ease;
}
.rp-event:hover .rp-event-edit { opacity: 1; }

/* ============================================
   FORM — custom event modal
   ============================================ */
.rp-form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.rp-hue-picker {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 6px 0;
}
.rp-hue-option {
  cursor: pointer;
  position: relative;
}
.rp-hue-option input { position: absolute; opacity: 0; pointer-events: none; }
.rp-hue-swatch {
  display: block;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: transform .12s ease, border-color .12s ease;
}
.rp-hue-option input:checked + .rp-hue-swatch {
  border-color: var(--text-primary, #2a2520);
  transform: scale(1.12);
}

/* ============================================
   VISIBILITY TOGGLE — internal vs client (Phase F)
   ============================================ */
.rp-visibility-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 4px;
}
.rp-vis-option {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border, #ece6dd);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.rp-vis-option:has(input:checked) {
  border-color: var(--joy-rose-ink);
  background: var(--joy-rose-tint, #fce8ec);
}
.rp-vis-option input { margin: 0; flex-shrink: 0; }
.rp-vis-option span { display: flex; flex-direction: column; gap: 2px; }
.rp-vis-option strong { font-size: .88rem; color: var(--text-primary); }
.rp-vis-option small { font-size: .72rem; color: var(--text-muted); }

.rp-event-shared {
  background: var(--joy-rose-tint, #fce8ec);
  color: var(--joy-rose-ink);
  padding: 1px 8px; border-radius: 999px;
  font-size: .68rem; font-weight: 600;
  letter-spacing: .02em;
}

/* ============================================
   QUICKVIEW — mini-modale d'infos (événements dérivés)
   Reste dans le cockpit : lecture seule + lien optionnel vers la fiche.
   ============================================ */
.rp-quickview {
  border-left: 3px solid var(--joy-gold-ink);
  padding-left: 16px;
}
.rp-quickview.rp-event-hue-rose    { border-left-color: var(--joy-rose-ink); }
.rp-quickview.rp-event-hue-sage    { border-left-color: var(--joy-sage-ink); }
.rp-quickview.rp-event-hue-sky     { border-left-color: var(--joy-sky-ink); }
.rp-quickview.rp-event-hue-apricot { border-left-color: var(--joy-apricot-ink); }
.rp-quickview.rp-event-hue-plum    { border-left-color: var(--joy-plum-ink); }
.rp-quickview.rp-event-hue-gold    { border-left-color: var(--joy-gold-ink); }
.rp-quickview-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.rp-quickview-source {
  text-transform: uppercase; letter-spacing: .08em;
  font-size: .68rem; font-weight: 600; color: var(--text-muted);
}
.rp-quickview-status {
  margin-left: auto;
  padding: 2px 10px; border-radius: 999px;
  font-size: .7rem; font-weight: 600;
  background: var(--surface-muted, #f4f0e9); color: var(--text-secondary);
}
.rp-quickview-status.rp-status-done    { background: var(--joy-sage-tint, #e7f0ea); color: var(--joy-sage-ink); }
.rp-quickview-status.rp-status-overdue { background: var(--joy-rose-tint, #fce8ec); color: var(--joy-rose-ink); }
.rp-quickview-title {
  margin: 0 0 6px; font-size: 1.15rem; font-weight: 500;
  color: var(--text-primary);
}
.rp-quickview-date {
  margin: 0 0 10px; font-size: .85rem; color: var(--text-secondary);
}
.rp-quickview-dleft { color: var(--text-muted); }
.rp-quickview-desc {
  margin: 0; font-size: .9rem; line-height: 1.5; color: var(--text-secondary);
  white-space: pre-wrap;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 720px) {
  .rp-header { padding: 20px 18px; }
  .rp-kpi-num { font-size: 1.8rem; }
  .rp-kpi-num-xl { font-size: 2.3rem; }
  .rp-buckets { grid-template-columns: 1fr; }
  .rp-form-row { grid-template-columns: 1fr; }
  .rp-frieze { padding: 18px 16px 24px; }
  .rp-frieze-grad-label { font-size: .6rem; }
  .rp-frieze-track { height: 70px; }
  .rp-visibility-toggle { grid-template-columns: 1fr; }
}
