/* ==========================================================================
   FAMIVEST DASHBOARD — Styles spécifiques
   --------------------------------------------------------------------------
   Complète famivest-components.css pour les sections dynamiques du dashboard.
   0% de style inline — tout passe par les variables --fv-* et data-fv-tone.
   ========================================================================== */

/* ──────────────────────────────────────────────────────────────────────────
   SECTION WRAPPERS — héritage font Inter
────────────────────────────────────────────────────────────────────────── */

#db-section,
#db-section-bottom {
  font-family: var(--fv-font-sans);
  margin-bottom: 2rem;
}

/* ──────────────────────────────────────────────────────────────────────────
   GREETING — phrase personnalisée (remplace l'ancien titre)
────────────────────────────────────────────────────────────────────────── */

.db-greeting {
  margin-bottom: 1.5rem;
}

.db-intro-phrase {
  font-family: var(--fv-font-sans);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fv-fg-1);
  line-height: 1.45;
  max-width: 780px;
  min-height: 1.4em;
  letter-spacing: -0.01em;
}

.db-intro-phrase.is-loading {
  color: transparent;
  background: linear-gradient(90deg, var(--fv-stone-100) 25%, var(--fv-stone-50) 50%, var(--fv-stone-100) 75%);
  background-size: 200% 100%;
  animation: db-shimmer 1.4s infinite;
  border-radius: 6px;
  width: 65%;
  height: 1.6rem;
  display: block;
}

/* ──────────────────────────────────────────────────────────────────────────
   TITRE "EXPLORER VOS MODULES"
────────────────────────────────────────────────────────────────────────── */

.db-modules-title {
  font-family: var(--fv-font-sans);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fv-fg-3);
  margin-bottom: 0.75rem;
  margin-top: 0.25rem;
}

/* ──────────────────────────────────────────────────────────────────────────
   SKELETON LOADERS
────────────────────────────────────────────────────────────────────────── */

@keyframes db-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.db-skeleton {
  background: linear-gradient(90deg, var(--fv-stone-100) 25%, var(--fv-stone-50) 50%, var(--fv-stone-100) 75%);
  background-size: 200% 100%;
  animation: db-shimmer 1.4s infinite;
  border-radius: 8px;
}

/* KPI skeletons */
.db-kpi-skeleton {
  background: #fff;
  border: 1px solid var(--fv-border-1);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--fv-shadow-sm);
}

.db-kpi-skeleton-label {
  height: 10px;
  width: 55%;
  margin-bottom: 12px;
}

.db-kpi-skeleton-val {
  height: 28px;
  width: 70%;
  margin-bottom: 8px;
}

.db-kpi-skeleton-hint {
  height: 10px;
  width: 45%;
}

/* Table skeleton rows */
.db-table-skeleton-row {
  height: 52px;
  width: 100%;
  margin-bottom: 1px;
}

.db-table-skeleton-body {
  padding: 0 0 12px;
}

.db-side-skeleton {
  height: 54px;
  margin-bottom: 8px;
  border-radius: 10px;
}

/* ──────────────────────────────────────────────────────────────────────────
   AI CALLOUT — ÉTATS
────────────────────────────────────────────────────────────────────────── */

.db-ai-loading .fv-ai-title,
.db-ai-loading .fv-ai-text {
  color: transparent;
  background: linear-gradient(90deg, var(--fv-stone-100) 25%, var(--fv-stone-50) 50%, var(--fv-stone-100) 75%);
  background-size: 200% 100%;
  animation: db-shimmer 1.4s infinite;
  border-radius: 4px;
  display: block;
}

.db-ai-loading .fv-ai-title {
  height: 20px;
  width: 55%;
  margin-bottom: 8px;
}

.db-ai-loading .fv-ai-text {
  height: 40px;
  width: 90%;
}

.db-ai-loading .fv-ai-actions {
  visibility: hidden;
}

.db-ai-quota-badge {
  font-size: 11px;
  color: var(--fv-fg-3);
  margin-left: 8px;
}

/* ──────────────────────────────────────────────────────────────────────────
   ALERTE : variante danger (DPE)
────────────────────────────────────────────────────────────────────────── */

.fv-alert-dot.danger {
  background: var(--fv-danger);
}

/* ──────────────────────────────────────────────────────────────────────────
   ALERTE FISCALE — bannière proéminente (avril → 15 juin)
────────────────────────────────────────────────────────────────────────── */

.fv-alert--fiscal {
  border: 1px solid var(--fv-warning);
  border-left: 3px solid var(--fv-warning);
  gap: 10px;
  align-items: flex-start;
}
.fv-alert-fiscal-icon {
  color: var(--fv-warning);
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ──────────────────────────────────────────────────────────────────────────
   SNAPSHOT DATE HINT
────────────────────────────────────────────────────────────────────────── */

.db-snap-hint {
  font-size: 10.5px;
  color: var(--fv-fg-4);
  margin-top: 2px;
}

/* ──────────────────────────────────────────────────────────────────────────
   "PAS DE DONNÉES" STATES
────────────────────────────────────────────────────────────────────────── */

.db-no-data {
  text-align: center;
  padding: 2rem;
  color: var(--fv-fg-3);
  font-size: 13.5px;
}

.db-no-data i {
  display: block;
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  opacity: 0.4;
}

.db-snapshot-pending {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fv-fg-3);
  padding: 6px 0;
}

.db-snapshot-pending i {
  width: 15px;
  height: 15px;
  color: var(--fv-fg-4);
}

/* ──────────────────────────────────────────────────────────────────────────
   BOUTON "VOIR TOUTES LES NOTIFICATIONS"
────────────────────────────────────────────────────────────────────────── */

.db-alerts-footer {
  margin-top: 4px;
}

.db-alerts-footer .fv-btn i {
  width: 14px;
  height: 14px;
}

/* ──────────────────────────────────────────────────────────────────────────
   FILTRE PLEINE PROPRIÉTÉ
────────────────────────────────────────────────────────────────────────── */

.db-assets-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.db-filter-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--fv-fg-2);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.db-filter-toggle input[type="checkbox"] {
  accent-color: var(--fv-forest-600, #2a7a3b);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ──────────────────────────────────────────────────────────────────────────
   ICÔNE CARTE (cliquable pour les biens fonciers)
────────────────────────────────────────────────────────────────────────── */

.fv-row-ic.db-ic-map {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: none;
  background: none;
  padding: 0;
}

.fv-row-ic.db-ic-map:hover {
  transform: scale(1.12);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.fv-row-ic.db-ic-nomap {
  cursor: default;
  pointer-events: none;
}

/* Badge type de détention (NP, usufruit) */
.db-detention-badge {
  font-size: 10px;
  color: var(--fv-fg-3);
  font-style: italic;
}

/* ──────────────────────────────────────────────────────────────────────────
   KPI CARDS — liens cliquables
────────────────────────────────────────────────────────────────────────── */

.db-kpi-link {
  text-decoration: none;
  color: inherit;
  display: block;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
}

.db-kpi-link:hover .fv-kpi {
  border-color: var(--fv-forest-300, #86b892);
  transform: translateY(-2px);
  box-shadow: var(--fv-shadow-md);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

/* ──────────────────────────────────────────────────────────────────────────
   COLONNES PÉRIODE (2 ans / 5 ans / 10 ans — affichées seulement avec toggle)
────────────────────────────────────────────────────────────────────────── */

.db-col-period {
  white-space: nowrap;
}

@media (max-width: 900px) {
  .db-col-period {
    display: none;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   TABLEAU ÉLARGI (mode Évolution immo — 4 colonnes de période)
────────────────────────────────────────────────────────────────────────── */

.db-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Colonnes de période : police légèrement réduite pour tenir */
.db-period-col {
  font-size: 12px;
  white-space: nowrap;
  min-width: 56px;
}

/* En mode large le tableau peut déborder — on le laisse scroller */
.db-table-wide .fv-table {
  min-width: 860px;
}

/* ──────────────────────────────────────────────────────────────────────────
   RESPONSIVE
────────────────────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .db-intro-phrase {
    font-size: 1.05rem;
  }

  .db-assets-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (max-width: 560px) {
  #db-section,
  #db-section-bottom {
    margin-bottom: 1.25rem;
  }

  .db-intro-phrase {
    font-size: 0.95rem;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   MODAL DÉTAIL BIEN
────────────────────────────────────────────────────────────────────────── */

.db-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 400;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.db-modal-overlay.is-open {
  opacity: 1;
  pointer-events: all;
}

.db-modal {
  background: #fff;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transform: translateY(40px);
  transition: transform 0.25s ease;
}

.db-modal-overlay.is-open .db-modal {
  transform: translateY(0);
}

@media (min-width: 640px) {
  .db-modal-overlay {
    align-items: center;
    padding: 20px;
  }

  .db-modal {
    border-radius: 20px;
    transform: translateY(12px) scale(0.97);
    transition: transform 0.22s ease, opacity 0.22s ease;
    opacity: 0;
  }

  .db-modal-overlay.is-open .db-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.db-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--fv-border-1);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
  border-radius: 20px 20px 0 0;
}

.db-modal-title {
  font-family: var(--fv-font-sans);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fv-fg-1);
  margin: 4px 0 2px;
  line-height: 1.3;
}

.db-modal-addr {
  font-size: 12px;
  color: var(--fv-fg-3);
}

.db-modal-close {
  flex-shrink: 0;
  margin-top: 2px;
}

.db-modal-body {
  padding: 16px 22px 32px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
}

.db-modal-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--fv-border-1);
}

.db-modal-section:last-child {
  border-bottom: none;
}

.db-modal-section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fv-fg-3);
  margin-bottom: 12px;
}

.db-modal-kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
}

.db-modal-kv {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.db-modal-kv-label {
  font-size: 10.5px;
  color: var(--fv-fg-3);
}

.db-modal-kv-val {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fv-fg-1);
}

/* Équipements (chips) */
.db-modal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.db-modal-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--fv-fg-2);
  background: var(--fv-stone-50);
  border: 1px solid var(--fv-border-1);
  border-radius: 20px;
  padding: 3px 10px 3px 8px;
}

.db-modal-chip i {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* Description libre */
.db-modal-desc {
  font-size: 13px;
  line-height: 1.6;
  color: var(--fv-fg-2);
  margin-top: 14px;
  white-space: pre-line;
}

/* DPE badges */
.db-modal-dpe {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}

.db-modal-dpe-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  padding: 2px 12px;
  border-radius: 6px;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.db-modal-dpe-badge[data-class="A"] { background: #009966; color: #fff; }
.db-modal-dpe-badge[data-class="B"] { background: #33cc66; color: #fff; }
.db-modal-dpe-badge[data-class="C"] { background: #99cc00; color: #fff; }
.db-modal-dpe-badge[data-class="D"] { background: #ffcc00; color: #333; }
.db-modal-dpe-badge[data-class="E"] { background: #ff9900; color: #fff; }
.db-modal-dpe-badge[data-class="F"] { background: #ff6600; color: #fff; }
.db-modal-dpe-badge[data-class="G"] { background: #cc3300; color: #fff; }

/* Contacts */
.db-modal-contacts {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.db-modal-contact-card {
  background: var(--fv-stone-50);
  border: 1px solid var(--fv-border-1);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.db-modal-contact-role {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fv-fg-1);
  display: flex;
  align-items: center;
  gap: 6px;
}

.db-modal-contact-role i {
  width: 14px;
  height: 14px;
  color: var(--fv-fg-3);
  flex-shrink: 0;
}

.db-modal-contact-meta {
  font-size: 11.5px;
  color: var(--fv-fg-3);
  margin-left: 20px;
}

.db-modal-contact-info {
  font-size: 12px;
  color: var(--fv-fg-2);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 20px;
  margin-top: 2px;
}

.db-modal-contact-info i {
  width: 12px;
  height: 12px;
  color: var(--fv-fg-4);
  flex-shrink: 0;
}

/* Liste générique (prêts, assurances) */
.db-modal-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.db-modal-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--fv-border-1);
}

.db-modal-list-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.db-modal-list-main {
  flex: 1;
  min-width: 0;
}

.db-modal-list-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--fv-fg-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-modal-list-meta {
  font-size: 11.5px;
  color: var(--fv-fg-3);
  margin-top: 2px;
}

.db-modal-list-val {
  text-align: right;
  flex-shrink: 0;
}

.db-modal-list-val-main {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--fv-fg-1);
  font-variant-numeric: tabular-nums;
}

.db-modal-list-val-sub {
  font-size: 10.5px;
  color: var(--fv-fg-4);
  margin-top: 1px;
}

.db-modal-link-btn {
  flex-shrink: 0;
}

/* IA zone */
.db-modal-ai {
  background: var(--fv-stone-50);
  border-radius: 12px;
  padding: 14px 16px;
  border: none;
  margin-top: 4px;
}

.db-modal-ai-content {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.db-modal-ai-heading {
  font-size: 12px;
  font-weight: 700;
  color: var(--fv-fg-1);
  margin: 10px 0 4px;
  line-height: 1.4;
}

.db-modal-ai-heading:first-child {
  margin-top: 0;
}

.db-modal-ai-para {
  font-size: 13px;
  line-height: 1.65;
  color: var(--fv-fg-2);
  margin: 0 0 4px;
}

.db-modal-ai-para:last-child {
  margin-bottom: 0;
}

.db-modal-ai-empty {
  font-size: 13px;
  color: var(--fv-fg-4);
  font-style: italic;
  margin: 0;
}

/* Tableau markdown dans les blocs IA */
.db-ai-table-wrap {
  overflow-x: auto;
  margin: 8px 0;
  border-radius: 8px;
  border: 1px solid var(--fv-border);
}

.db-ai-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.5;
}

.db-ai-table th {
  background: var(--fv-stone-100);
  color: var(--fv-fg-1);
  font-weight: 600;
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--fv-border);
  white-space: nowrap;
}

.db-ai-table td {
  padding: 6px 10px;
  color: var(--fv-fg-2);
  border-bottom: 1px solid var(--fv-border);
  vertical-align: top;
}

.db-ai-table tbody tr:last-child td {
  border-bottom: none;
}

.db-ai-table tbody tr:nth-child(even) {
  background: var(--fv-stone-50);
}

/* Skeletons modal */
.db-modal-skeleton-block {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--fv-stone-100) 25%, var(--fv-stone-50) 50%, var(--fv-stone-100) 75%);
  background-size: 200% 100%;
  animation: db-shimmer 1.4s infinite;
}

.db-modal-skeleton-title {
  height: 22px;
  width: 55%;
  margin: 4px 0 6px;
}

.db-modal-skeleton-label {
  height: 10px;
  width: 30%;
  margin-bottom: 14px;
}

.db-modal-skeleton-sm {
  height: 10px;
  width: 60%;
  margin-bottom: 4px;
}

.db-modal-skeleton-md {
  height: 16px;
  width: 80%;
}

.db-modal-skeleton-ai {
  height: 80px;
  width: 100%;
  border-radius: 8px;
}

@media (max-width: 560px) {
  .db-modal-kv-grid {
    grid-template-columns: 1fr;
  }

  .db-modal-header {
    padding: 16px 16px 14px;
  }

  .db-modal-body {
    padding: 12px 16px 28px;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   LISTE AVEC ICÔNE (breakdown patrimoine, forêts, etc.)
────────────────────────────────────────────────────────────────────────── */

.db-modal-list-main.db-with-icon {
  display: flex;
  align-items: center;
  gap: 10px;
}

.db-modal-list-icon {
  width: 16px;
  height: 16px;
  color: var(--fv-fg-3);
  flex-shrink: 0;
}

.db-modal-list-total .db-modal-list-name,
.db-modal-list-total .db-modal-list-val-main {
  font-size: 14px;
}

.db-modal-list-total {
  border-top: 2px solid var(--fv-border-1);
  border-bottom: none;
  margin-top: 4px;
  padding-top: 12px;
}

.db-val-neg {
  color: var(--fv-danger, #c0392b);
}

/* ──────────────────────────────────────────────────────────────────────────
   SPARKLINE — graphe SVG évolution patrimoine
────────────────────────────────────────────────────────────────────────── */

.db-sparkline-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.db-sparkline {
  width: 100%;
  height: 64px;
  overflow: visible;
}

.db-sparkline-line {
  stroke: var(--fv-forest-500, #3a8a4d);
}

.db-sparkline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--fv-fg-4);
}

/* ──────────────────────────────────────────────────────────────────────────
   MODAL AI LOADING STATE (dans les sections IA des KPI modals)
────────────────────────────────────────────────────────────────────────── */

.db-modal-ai-loading {
  min-height: 60px;
}

/* ──────────────────────────────────────────────────────────────────────────
   MODAL FOOTER LINK (lien vers page complète, ex: IR)
────────────────────────────────────────────────────────────────────────── */

.db-modal-footer-link {
  padding-top: 12px;
}

/* ──────────────────────────────────────────────────────────────────────────
   AI UPGRADE BLOCK — accès restreint ou quota dépassé
────────────────────────────────────────────────────────────────────────── */

.db-ai-upgrade {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--fv-stone-50);
  border: 1px solid var(--fv-border-1);
  border-radius: 10px;
  padding: 12px 14px;
  flex-wrap: wrap;
}

.db-ai-upgrade-icon {
  color: var(--fv-fg-3);
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.db-ai-upgrade-text {
  flex: 1;
  min-width: 120px;
  font-size: 13px;
  color: var(--fv-fg-2);
  line-height: 1.5;
}

.db-ai-upgrade-text strong {
  display: block;
  color: var(--fv-fg-1);
  margin-bottom: 2px;
}

.db-btn-plan {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ──────────────────────────────────────────────────────────────────────────
   BREAKDOWN BAR CHART (répartition actifs dans la modal patrimoine)
────────────────────────────────────────────────────────────────────────── */

.db-bar-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.db-bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 36px;
  align-items: center;
  gap: 10px;
}

.db-bar-label {
  font-size: 12px;
  color: var(--fv-fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-bar-track {
  height: 8px;
  background: var(--fv-stone-100);
  border-radius: 4px;
  overflow: hidden;
}

.db-bar-fill {
  height: 100%;
  border-radius: 4px;
  width: var(--bar-pct, 0%);
  transition: width 0.5s ease;
}

.db-bar-immo    { background: var(--fv-forest-500, #3a8a4d); }
.db-bar-epargne { background: var(--fv-sky-500, #0284c7); }
.db-bar-societes { background: var(--fv-honey-500, #d97706); }
.db-bar-vehicules { background: var(--fv-clay-500, #8b5e3c); }

.db-bar-pct {
  font-size: 11px;
  color: var(--fv-fg-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
