/* ============================================================
   KOST GROUP — DASHBOARD V2 (glassmorphism, modern)
   ============================================================ */

/* ─── Variables ─── */
:root {
  --d-bg:           #f5f7fb;
  --d-bg-2:         #eef1f7;
  --d-card:         rgba(255, 255, 255, 0.72);
  --d-card-strong:  rgba(255, 255, 255, 0.92);
  --d-border:       rgba(255, 255, 255, 0.6);
  --d-border-soft:  rgba(15, 28, 63, 0.06);
  --d-shadow:       0 4px 24px -8px rgba(15, 28, 63, 0.10),
                    0 2px 6px -2px rgba(15, 28, 63, 0.06);
  --d-shadow-hover: 0 8px 32px -8px rgba(15, 28, 63, 0.18),
                    0 4px 10px -2px rgba(15, 28, 63, 0.10);

  --d-text:         #0f1c3f;
  --d-text-soft:    #5b6478;
  --d-text-muted:   #8b94a8;

  --d-blue:         #2563eb;
  --d-cyan:         #06b6d4;
  --d-violet:       #7c3aed;
  --d-orange:       #f97316;
  --d-red:          #ef4444;
  --d-green:        #10b981;
  --d-amber:        #f59e0b;

  --d-grad-blue:    linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  --d-grad-violet:  linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
  --d-grad-orange:  linear-gradient(135deg, #f97316 0%, #fbbf24 100%);
  --d-grad-green:   linear-gradient(135deg, #10b981 0%, #34d399 100%);
  --d-grad-red:     linear-gradient(135deg, #ef4444 0%, #f97316 100%);
  --d-grad-bg:      radial-gradient(at 8% 0%, rgba(124, 58, 237, 0.08) 0px, transparent 50%),
                    radial-gradient(at 95% 5%, rgba(6, 182, 212, 0.10) 0px, transparent 45%),
                    radial-gradient(at 50% 100%, rgba(249, 115, 22, 0.06) 0px, transparent 55%);

  --d-radius-lg:    18px;
  --d-radius-md:    14px;
  --d-radius-sm:    10px;
}

/* ─── Page background (only on dashboard active) ─── */
#page-dashboard.active {
  background: var(--d-bg);
  background-image: var(--d-grad-bg);
  min-height: 100%;
  padding: 24px 28px 48px;
}

/* ─── Header ─── */
.dash-v2-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.dash-v2-title h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--d-text);
  margin: 0 0 4px;
}
.dash-v2-title p {
  color: var(--d-text-muted);
  font-size: 0.9rem;
  margin: 0;
}
.dash-v2-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}
.dash-v2-controls select,
.dash-v2-controls button {
  background: var(--d-card-strong);
  border: 1px solid var(--d-border-soft);
  border-radius: var(--d-radius-sm);
  padding: 8px 14px;
  font-size: 0.85rem;
  color: var(--d-text);
  cursor: pointer;
  transition: all .15s ease;
  font-weight: 500;
}
.dash-v2-controls select:hover,
.dash-v2-controls button:hover {
  background: white;
  box-shadow: var(--d-shadow);
}

/* ─── Card primitive ─── */
.glass-card {
  background: var(--d-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--d-border);
  border-radius: var(--d-radius-lg);
  box-shadow: var(--d-shadow);
  padding: 20px;
  transition: box-shadow .25s ease, transform .25s ease;
}
.glass-card:hover {
  box-shadow: var(--d-shadow-hover);
}
.glass-card-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--d-text-muted);
  font-weight: 600;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.glass-card-title .badge-count {
  background: var(--d-orange);
  color: white;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.72rem;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════
   ZONE 1 — Trésorerie (héro)
═══════════════════════════════════════════════════════ */
.tresorerie-section {
  display: grid;
  grid-template-columns: 1.2fr 2fr;
  gap: 18px;
  margin-bottom: 22px;
}
@media (max-width: 1100px) {
  .tresorerie-section { grid-template-columns: 1fr; }
}

.tresorerie-total {
  background: var(--d-grad-blue);
  color: white;
  border-radius: var(--d-radius-lg);
  padding: 26px 28px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 40px -12px rgba(37, 99, 235, 0.45);
}
.tresorerie-total::before {
  content: "";
  position: absolute;
  top: -40%; right: -20%;
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, transparent 60%);
  pointer-events: none;
}
.tresorerie-total .label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
  font-weight: 600;
}
.tresorerie-total .amount {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 8px 0 4px;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.tresorerie-total .amount-unit {
  font-size: 1.2rem;
  font-weight: 500;
  opacity: 0.85;
  margin-left: 6px;
}
.tresorerie-total .sub {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 6px;
}

.tresorerie-breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.tresorerie-mini {
  background: var(--d-card-strong);
  backdrop-filter: blur(20px);
  border: 1px solid var(--d-border-soft);
  border-radius: var(--d-radius-md);
  padding: 18px 16px;
  position: relative;
}
.tresorerie-mini .icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: white;
  margin-bottom: 10px;
}
.tresorerie-mini.especes .icon { background: var(--d-grad-orange); }
.tresorerie-mini.ccp .icon     { background: var(--d-grad-violet); }
.tresorerie-mini.banque .icon  { background: var(--d-grad-blue); }
.tresorerie-mini .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--d-text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
}
.tresorerie-mini .amount {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--d-text);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.tresorerie-mini .trend {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--d-text-soft);
  display: flex;
  align-items: center;
  gap: 4px;
}
.tresorerie-mini .trend.up    { color: var(--d-green); }
.tresorerie-mini .trend.down  { color: var(--d-red); }
.tresorerie-mini .spark {
  position: absolute;
  bottom: 8px; right: 8px;
  width: 80px; height: 30px;
  opacity: 0.85;
}

/* Évolution 30j chart */
.chart-evolution {
  margin-top: 16px;
}
.chart-evolution .chart-mount {
  min-height: 230px;
}

/* ═══════════════════════════════════════════════════════
   ZONE 2 — À valider + Échéances (2 colonnes)
═══════════════════════════════════════════════════════ */
.actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
@media (max-width: 900px) {
  .actions-row { grid-template-columns: 1fr; }
}

.action-list { display: flex; flex-direction: column; gap: 10px; }
.action-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  background: var(--d-card-strong);
  border: 1px solid var(--d-border-soft);
  border-radius: var(--d-radius-md);
  transition: all .2s ease;
  position: relative;
}
.action-item:hover {
  background: white;
  transform: translateX(2px);
  box-shadow: var(--d-shadow);
}
.action-item .ai-icon {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: var(--d-grad-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.action-item.ai-ech .ai-icon  { background: var(--d-grad-violet); }
.action-item.ai-form .ai-icon { background: var(--d-grad-green); }
.action-item .ai-body { flex: 1; min-width: 0; }
.action-item .ai-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--d-text);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.action-item .ai-meta {
  font-size: 0.78rem;
  color: var(--d-text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.action-item .ai-meta .dot { color: var(--d-text-muted); }
.action-item .ai-amount {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--d-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.action-item .ai-amount.danger { color: var(--d-red); }
.action-item .ai-validate-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--d-green);
  border: none;
  color: white;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .15s ease;
}
.action-item .ai-validate-btn:hover {
  background: #0ca877;
  transform: scale(1.05);
  box-shadow: 0 4px 12px -2px rgba(16, 185, 129, 0.45);
}
.action-item .ai-validate-btn:disabled {
  background: var(--d-text-muted);
  cursor: not-allowed;
}
.action-item.ai-validating { animation: validateOut .45s ease forwards; }
@keyframes validateOut {
  to { opacity: 0; transform: translateX(60px); height: 0; padding: 0; margin: 0; }
}

.action-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--d-text-muted);
  font-size: 0.85rem;
}
.action-empty i {
  font-size: 2rem;
  color: var(--d-green);
  display: block;
  margin-bottom: 8px;
}

.action-footer {
  margin-top: 14px;
  text-align: center;
}
.action-footer a {
  font-size: 0.82rem;
  color: var(--d-blue);
  text-decoration: none;
  font-weight: 500;
}
.action-footer a:hover { text-decoration: underline; }

/* Justificatif badge sur action */
.ai-justif-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
}
.ai-justif-pill.ok      { background: rgba(16, 185, 129, 0.12); color: #047857; }
.ai-justif-pill.missing { background: rgba(239, 68, 68, 0.12);  color: #b91c1c; }

/* Échéances — alerte couleurs */
.ai-deadline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: 0.75rem;
}
.ai-deadline.urgent { color: var(--d-red); }
.ai-deadline.soon   { color: var(--d-amber); }
.ai-deadline.ok     { color: var(--d-text-muted); }

/* ═══════════════════════════════════════════════════════
   ZONE 3 — Santé du mois + Répartition CA
═══════════════════════════════════════════════════════ */
.health-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
@media (max-width: 1100px) {
  .health-row { grid-template-columns: 1fr; }
}

.health-card .health-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
@media (max-width: 700px) {
  .health-card .health-grid { grid-template-columns: 1fr 1fr; }
}
.health-metric {
  padding: 14px 0;
}
.health-metric .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--d-text-muted);
  letter-spacing: 0.05em;
  font-weight: 600;
}
.health-metric .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--d-text);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.health-metric .delta {
  margin-top: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 10px;
}
.health-metric .delta.up    { background: rgba(16, 185, 129, 0.12); color: #047857; }
.health-metric .delta.down  { background: rgba(239, 68, 68, 0.12); color: #b91c1c; }
.health-metric .delta.flat  { background: rgba(107, 114, 128, 0.12); color: #4b5563; }

.health-progress {
  height: 8px;
  background: var(--d-bg-2);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 14px;
}
.health-progress > div {
  height: 100%;
  background: var(--d-grad-green);
  transition: width .8s ease;
  border-radius: 6px;
}

.repartition-card .chart-mount {
  min-height: 240px;
}

/* ═══════════════════════════════════════════════════════
   ZONE 4 — Impayés + Dettes + Équipe
═══════════════════════════════════════════════════════ */
.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
@media (max-width: 1100px) {
  .bottom-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .bottom-row { grid-template-columns: 1fr; }
}

.bottom-card .big-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--d-text);
  font-variant-numeric: tabular-nums;
  margin: 4px 0 2px;
}
.bottom-card .big-number.danger { color: var(--d-red); }
.bottom-card .big-sub {
  font-size: 0.82rem;
  color: var(--d-text-muted);
}
.bottom-card ul {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bottom-card ul li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--d-bg-2);
  border-radius: 8px;
  font-size: 0.85rem;
}
.bottom-card ul li .name { color: var(--d-text); font-weight: 500; }
.bottom-card ul li .val  {
  font-weight: 700;
  color: var(--d-text);
  font-variant-numeric: tabular-nums;
}

/* Status pastilles */
.dot-status {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.dot-status.green  { background: var(--d-green); }
.dot-status.red    { background: var(--d-red); }
.dot-status.amber  { background: var(--d-amber); }
.dot-status.blue   { background: var(--d-blue); }

/* ─── Skeleton loader ─── */
.skeleton {
  background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
  background-size: 200% 100%;
  animation: skeletonShine 1.4s ease-in-out infinite;
  border-radius: 4px;
  display: inline-block;
}
@keyframes skeletonShine {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Mobile finishing touches ─── */
@media (max-width: 640px) {
  #page-dashboard.active { padding: 16px 12px 32px; }
  .tresorerie-total .amount { font-size: 2rem; }
  .tresorerie-mini .amount { font-size: 1.1rem; }
  .health-metric .value { font-size: 1.2rem; }
  .glass-card { padding: 16px; }
  .action-item { padding: 12px; }
  .action-item .ai-amount { font-size: 0.95rem; }
  .action-item .ai-validate-btn { width: 32px; height: 32px; }
}
