/* =============================================================================
   comptes.css — Page Agrégation bancaire Powens
   ============================================================================= */

/* ============================================================================
   HERO — Bandeau patrimoine live
   ============================================================================ */
.comptes-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 28px 32px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--fv-night-800, #0f2233) 0%, var(--fv-night-700, #1b3449) 100%);
  color: #ffffff;
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-lg, 0 10px 25px rgba(0, 0, 0, 0.1));
  flex-wrap: wrap;
}

.comptes-hero__left {
  min-width: 0;
  flex: 1 1 260px;
}

.comptes-hero__label {
  margin: 0 0 6px;
  font-size: 0.82rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.comptes-hero__amount {
  margin: 0 0 8px;
  font-size: 2.6rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.comptes-hero__meta {
  margin: 0;
  font-size: 0.88rem;
  color: #cbd5e1;
}

.comptes-hero__right {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.comptes-hero__cta {
  background: var(--fv-honey-500, #d99a3b);
}

.comptes-hero__cta:hover {
  background: var(--fv-honey-700, #9b6820);
}

/* ============================================================================
   CARD (section générique)
   ============================================================================ */
.comptes-card {
  background: #ffffff;
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-md, 0 4px 6px rgba(0, 0, 0, 0.05));
  padding: 24px;
  margin-bottom: 24px;
}

.comptes-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.comptes-card__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #0f172a;
}

/* ============================================================================
   EMPTY STATE
   ============================================================================ */
.comptes-empty {
  text-align: center;
  padding: 48px 24px;
}

.comptes-empty__icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
}

.comptes-empty__title {
  margin: 0 0 12px;
  font-size: 1.2rem;
  color: #0f172a;
  font-weight: 600;
}

.comptes-empty__text {
  margin: 0 auto 24px;
  max-width: 460px;
  color: #64748b;
  line-height: 1.6;
  font-size: 0.95rem;
}

/* ============================================================================
   CONNECTIONS — accordéon de banques
   ============================================================================ */
.comptes-connections {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.connection {
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  background: #ffffff;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.connection[open] {
  border-color: #cbd5e1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.connection__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
  transition: background 0.15s ease;
}

.connection__header::-webkit-details-marker {
  display: none;
}

.connection__header:hover {
  background: #f8fafc;
}

.connection__left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 auto;
}

.connection__icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}

.connection__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connection__meta {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: #64748b;
}

.connection__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.connection__body {
  border-top: 1px solid #e2e8f0;
  padding: 8px 0;
  background: #f8fafc;
}

.connection__empty {
  margin: 16px 20px;
  color: #94a3b8;
  font-style: italic;
  font-size: 0.9rem;
}

/* ============================================================================
   ACCOUNT ROW
   ============================================================================ */
.account-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-top: 1px solid #f1f5f9;
  transition: background 0.15s ease;
}

.account-row:first-child {
  border-top: none;
}

.account-row:hover {
  background: #ffffff;
}

.account-row--excluded {
  opacity: 0.55;
}

.account-row__left {
  min-width: 0;
}

.account-row__type {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f172a;
}

.account-row__iban {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: #64748b;
  font-family: var(--font-mono, ui-monospace, monospace);
}

.account-row__middle {
  display: flex;
  align-items: center;
}

.account-row__right {
  display: flex;
  gap: 8px;
}

/* ============================================================================
   STATUS BADGE + TAGS
   ============================================================================ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  background: #f1f5f9;
  color: #475569;
}

.status--ok {
  background: #dcfce7;
  color: #166534;
}

.status--warn {
  background: #fef3c7;
  color: #92400e;
}

.status--err {
  background: #fee2e2;
  color: #991b1b;
}

.status--muted {
  background: #e2e8f0;
  color: #475569;
}

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tag--pending {
  background: #fef3c7;
  color: #92400e;
}

.tag--muted {
  background: #e2e8f0;
  color: #64748b;
}

/* ============================================================================
   BUTTONS — chips, mini, icon-only
   ============================================================================ */
.btn-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-chip:hover {
  border-color: #0f172a;
  color: #0f172a;
}

.btn-chip.is-active {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}

.btn-mini {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 8px 12px;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.15s ease;
}

.btn-mini:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.btn-icon-only {
  background: transparent;
  border: 1px solid #e2e8f0;
  color: #64748b;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-icon-only:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.btn-icon-only--danger:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #dc2626;
}

.btn-small {
  padding: 7px 12px;
  font-size: 0.82rem;
}

.btn-warn {
  background: var(--fv-honey-500, #d99a3b);
  color: #ffffff;
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius-sm, 6px);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease;
}

.btn-warn:hover {
  background: var(--fv-honey-700, #9b6820);
}

/* ============================================================================
   CHARTS
   ============================================================================ */
.comptes-chart__controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.comptes-chart__wrapper {
  position: relative;
  height: 320px;
  margin-top: 16px;
}

/* ============================================================================
   MODALS — overrides et variantes
   ============================================================================ */
.modal-card--wide {
  max-width: 880px;
  width: 92%;
}

.modal-card--small {
  max-width: 440px;
  width: 92%;
}

.modal-card-body--flush {
  padding: 0;
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

.modal-card-foot--info {
  justify-content: flex-start;
  background: #f8fafc;
}

.modal-card-foot__info {
  margin: 0;
  font-size: 0.82rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-card-foot__info .icon-lock {
  color: #0ea5e9;
}

.modal-card-body__info {
  margin: 8px 0 18px;
  padding: 12px 14px;
  background: #f0f9ff;
  border-left: 3px solid #0ea5e9;
  font-size: 0.88rem;
  color: #0c4a6e;
  line-height: 1.55;
  border-radius: 4px;
}

/* ============================================================================
   ADD BANK MODAL — états (popup + fallback redirection)
   ============================================================================ */
.addbank-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px 20px;
  text-align: center;
  min-height: 240px;
}

.addbank-state__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #0f172a;
}

.addbank-state__text {
  margin: 0;
  color: #475569;
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 420px;
}

.addbank-state__icon {
  font-size: 2.8rem;
}

.addbank-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e2e8f0;
  border-top-color: var(--fv-honey-500, #d99a3b);
  border-radius: 50%;
  animation: addbank-spin 0.8s linear infinite;
}

@keyframes addbank-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================================
   MAPPING — formulaire
   ============================================================================ */
.mapping-account-summary {
  padding: 12px 14px;
  background: #f1f5f9;
  border-radius: var(--radius-sm, 6px);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.88rem;
  color: #0f172a;
  margin-bottom: 16px;
}

.mapping-hint {
  margin: 0 0 20px;
  color: #64748b;
  font-size: 0.88rem;
  line-height: 1.5;
}

.mapping-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-input-with-action {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.form-input-with-action .form-input {
  flex: 1;
  min-width: 0;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group--half {
  min-width: 0;
}

.required {
  color: #dc2626;
  margin-left: 2px;
}

/* ============================================================================
   DETAIL MODAL
   ============================================================================ */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e2e8f0;
}

.detail-grid__label {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 500;
}

.detail-grid__value {
  margin: 0;
  font-size: 0.92rem;
  color: #0f172a;
  font-weight: 500;
  word-break: break-word;
}

.detail-section-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f172a;
}

.detail-chart {
  margin-bottom: 24px;
}

.detail-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
  margin-top: 8px;
}

/* ============================================================================
   SNAPSHOT PREVIEW
   ============================================================================ */
.snapshot-preview {
  max-height: 360px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm, 6px);
  margin-top: 12px;
}

.snapshot-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.snapshot-table thead {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  z-index: 1;
}

.snapshot-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #475569;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid #e2e8f0;
}

.snapshot-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #0f172a;
  vertical-align: middle;
}

.snapshot-table tr:last-child td {
  border-bottom: none;
}

.snapshot-action--new {
  color: #166534;
  font-weight: 600;
}

.snapshot-action--upd {
  color: #92400e;
  font-weight: 600;
}

.snapshot-empty {
  text-align: center;
  padding: 32px 16px;
  color: #64748b;
  font-style: italic;
}

/* ============================================================================
   CALLBACK PAGE (powens-callback.html)
   ============================================================================ */
.callback-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #f8fafc;
}

.callback-card {
  background: #ffffff;
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-md, 0 4px 6px rgba(0, 0, 0, 0.05));
  padding: 40px 32px;
  text-align: center;
  max-width: 420px;
  width: 100%;
}

.callback-icon {
  font-size: 2.8rem;
  margin: 0 0 16px;
}

.callback-title {
  margin: 0 0 10px;
  font-size: 1.3rem;
  font-weight: 600;
  color: #0f172a;
}

.callback-text {
  margin: 0;
  color: #64748b;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ============================================================================
   IS-HIDDEN utility
   ============================================================================ */
.is-hidden {
  display: none !important;
}

/* ============================================================================
   FIX MODAL COUPÉ EN DEUX (barre grise indésirable)
   Cible toutes les modales de cette page pour éviter le footer collapse
   ============================================================================ */
#addBankModal.is-active .modal-card-foot,
#mappingModal.is-active .modal-card-foot,
#createListeModal.is-active .modal-card-foot,
#accountDetailModal.is-active .modal-card-foot,
#closeExerciceModal.is-active .modal-card-foot {
  flex-shrink: 0 !important;
  margin-top: auto !important;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 768px) {
  .comptes-hero {
    padding: 20px;
    flex-direction: column;
    align-items: flex-start;
  }

  .comptes-hero__amount {
    font-size: 2rem;
  }

  .comptes-hero__right {
    width: 100%;
  }

  .comptes-hero__right .btn-primary,
  .comptes-hero__right .btn-secondary {
    flex: 1;
  }

  .comptes-card {
    padding: 16px;
  }

  .connection__header {
    padding: 14px 16px;
    flex-wrap: wrap;
  }

  .account-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .account-row__right {
    width: 100%;
    justify-content: flex-end;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .detail-grid__label {
    margin-bottom: -8px;
    font-weight: 600;
  }

  .comptes-chart__wrapper {
    height: 240px;
  }

  .snapshot-table {
    font-size: 0.78rem;
  }

  .snapshot-table th,
  .snapshot-table td {
    padding: 8px 6px;
  }
}

/* ============================================================================
   [EVOL-011] CONSENTEMENT — partage bancaire avec un conseiller
   ============================================================================ */
.advisor-consent__intro {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--fv-fg-2, #3c4f52);
  line-height: 1.55;
}

.advisor-consent__list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.advisor-consent__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: var(--fv-bg-2, #fff);
  border: 1px solid var(--fv-border-1, #e6e2d7);
  border-radius: var(--fv-r-md, 10px);
}

.advisor-consent__info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.advisor-consent__name {
  font-weight: 600;
  color: var(--fv-fg-1, #152223);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.advisor-consent__meta {
  font-size: 0.8125rem;
  color: var(--fv-fg-3, #67757a);
}

/* Interrupteur (toggle) — pur CSS, aucun style inline (CSP) */
.advisor-consent__switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.advisor-consent__switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.advisor-consent__slider {
  position: absolute;
  inset: 0;
  background: var(--fv-bg-4, #ece8dd);
  border-radius: 999px;
  transition: background 0.2s ease;
}

.advisor-consent__slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.advisor-consent__switch input:checked + .advisor-consent__slider {
  background: var(--fv-primary, #2a4827);
}

.advisor-consent__switch input:checked + .advisor-consent__slider::before {
  transform: translateX(20px);
}

.advisor-consent__switch input:disabled + .advisor-consent__slider {
  opacity: 0.5;
  cursor: wait;
}

/* ============================================================================
   [EVOL-011] MODE PRO — consultation bancaire en lecture seule
   ============================================================================ */
.pro-readonly-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--fv-primary-soft, #f0f6ef);
  border: 1px solid var(--fv-primary, #2a4827);
  border-radius: var(--fv-r-md, 10px);
  color: var(--fv-primary, #2a4827);
  font-size: 0.9rem;
  font-weight: 600;
}

/* Masquage UX de tous les contrôles mutants (le back bloque déjà toute mutation) */
body.is-pro-readonly #btnAddBank,
body.is-pro-readonly #btnAddBankEmpty,
body.is-pro-readonly #btnCloseExercice,
body.is-pro-readonly #btnRefreshAll,
body.is-pro-readonly #toggleIncludeBtn,
body.is-pro-readonly #remapBtn,
body.is-pro-readonly [data-action="refresh-connection"],
body.is-pro-readonly [data-action="reauth-connection"],
body.is-pro-readonly [data-action="delete-connection"],
body.is-pro-readonly [data-action="map-account"] {
  display: none !important;
}

.pro-bank-noaccess {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.pro-bank-noaccess__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--fv-fg-1, #152223);
  margin: 0 0 0.5rem;
}

.pro-bank-noaccess__text {
  font-size: 0.9rem;
  color: var(--fv-fg-3, #67757a);
  max-width: 34rem;
  margin: 0 auto;
  line-height: 1.55;
}
