/* ═══════════════════════════════════════════════════
   style.css — Styles communs à toutes les pages
   Police : DM Sans + DM Mono (chargées via <link> dans chaque page)
═══════════════════════════════════════════════════ */

/* ─── Reset & Variables ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:        #1D9E75;
  --green-light:  #E1F5EE;
  --green-mid:    #0F6E56;
  --red:          #D85A30;
  --red-light:    #FAECE7;
  --amber:        #BA7517;
  --amber-light:  #FAEEDA;
  --bg:           #F7F6F2;
  --surface:      #FFFFFF;
  --surface2:     #F1EFE9;
  --border:       rgba(0,0,0,0.1);
  --border-strong:rgba(0,0,0,0.18);
  --text:         #1A1A18;
  --text-muted:   #6B6B66;
  --text-faint:   #A0A09A;
  --radius:       10px;
  --radius-sm:    6px;
  --mono:         'DM Mono', monospace;
  --sans:         'DM Sans', sans-serif;
  --sidebar-w:    210px;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
  display: flex;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.logo {
  padding: 1.4rem 1.25rem 1.1rem;
  border-bottom: 0.5px solid var(--border);
}
.logo-name {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.4px;
}
.logo-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}

.nav {
  padding: .75rem 0;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 1.25rem;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all .12s;
  user-select: none;
  text-decoration: none;
}
.nav-item:hover {
  color: var(--text);
  background: var(--surface2);
}
.nav-item.active {
  color: var(--text);
  font-weight: 500;
  border-left-color: var(--green);
  background: var(--surface2);
}
.nav-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: .55;
}
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: .9rem 1.25rem;
  border-top: 0.5px solid var(--border);
  font-size: 11px;
  color: var(--text-faint);
}

/* ─── Main layout ─── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  padding: .85rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 5;
}
.page-title {
  font-size: 15px;
  font-weight: 500;
}

.page-content {
  padding: 1.5rem 1.75rem;
  flex: 1;
}

/* ─── Buttons ─── */
.btn-primary {
  background: var(--green);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.btn-primary:hover { background: var(--green-mid); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-outline {
  background: none;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 12px;
  font-family: var(--sans);
  color: var(--text-muted);
  cursor: pointer;
}
.btn-outline:hover { background: var(--surface2); }
.btn-outline.active {
  background: var(--amber-light);
  border-color: var(--amber);
  color: var(--amber);
}

.btn-cancel {
  background: none;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 18px;
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  color: var(--text-muted);
}
.btn-cancel:hover { background: var(--surface2); }

.btn-submit {
  background: var(--green);
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 18px;
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  color: white;
}
.btn-submit:hover { background: var(--green-mid); }
.btn-submit:disabled { opacity: .6; cursor: not-allowed; }

.btn-danger {
  background: none;
  border: 0.5px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 7px 18px;
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  color: var(--red);
}
.btn-danger:hover { background: var(--red-light); }

.card-btn {
  background: none;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 12px;
  font-family: var(--sans);
  color: var(--text-muted);
  cursor: pointer;
}
.card-btn:hover { background: var(--surface2); }
.card-btn.danger:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }

/* ─── Section labels ─── */
.section-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: .7rem;
  margin-top: 1.5rem;
}
.section-label:first-child { margin-top: 0; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .7rem;
  margin-top: 1.5rem;
}
.section-header:first-child { margin-top: 0; }
.section-header .section-label { margin: 0; }

/* ─── Cards génériques ─── */
.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
}

/* ─── Account cards (dashboard) ─── */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
}

.account-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 15px;
  transition: box-shadow .15s, opacity .15s, transform .1s;
}
.accounts-grid.mode-click .account-card { cursor: pointer; }
.accounts-grid.mode-click .account-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.accounts-grid.mode-edit .account-card { cursor: grab; }
.accounts-grid.mode-edit .account-card:active { cursor: grabbing; }
.accounts-grid.mode-edit .account-card:hover { outline: 1.5px dashed var(--amber); outline-offset: 2px; }
.account-card.dragging { opacity: .35; }
.account-card.drag-over { box-shadow: 0 0 0 2px var(--green); }
.account-card.liquid { border-left: 2px solid var(--green); }
.account-card.invest { border-left: 2px solid var(--amber); }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  gap: 6px;
}
.account-name {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 99px;
  flex-shrink: 0;
}
.badge-liquid { background: var(--green-light); color: var(--green-mid); }
.badge-invest { background: var(--amber-light); color: var(--amber); }

.balance {
  font-size: clamp(13px, 2.8vw, 18px);
  font-weight: 500;
  font-family: var(--mono);
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.balance.pos { color: var(--green); }
.balance.neg { color: var(--red); }

.detail-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 0.5px solid var(--border);
  display: none;
}
.detail-panel.open { display: block; }
.detail-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
}
.detail-row:last-child { margin-bottom: 0; }
.detail-label { font-size: 11px; color: var(--text-faint); }
.detail-val {
  font-size: 11px;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--text-muted);
  white-space: nowrap;
}

.edit-mode-banner {
  display: none;
  background: var(--amber-light);
  border: 0.5px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--amber);
  margin-bottom: .75rem;
  align-items: center;
  gap: 8px;
}
.edit-mode-banner.show { display: flex; }

/* ─── Totals row ─── */
.totals-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.total-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
}
.total-label { font-size: 11px; color: var(--text-faint); margin-bottom: 5px; }
.total-value {
  font-size: clamp(13px, 2.5vw, 20px);
  font-weight: 500;
  font-family: var(--mono);
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.total-value.pos { color: var(--green); }
.total-value.neg { color: var(--red); }
.total-sub { font-size: 10px; color: var(--text-faint); margin-top: 3px; }

/* ─── Flux cards ─── */
.flux-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.flux-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
}
.flux-label { font-size: 11px; color: var(--text-faint); margin-bottom: 4px; }
.flux-val {
  font-size: 16px;
  font-weight: 500;
  font-family: var(--mono);
}
.flux-val.pos { color: var(--green); }
.flux-val.neg { color: var(--red); }

/* ─── Transactions table ─── */
.tx-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 12px;
  flex-wrap: wrap;
}
.tx-pills { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.pill {
  padding: 5px 13px;
  border-radius: 99px;
  font-size: 12px;
  border: 0.5px solid var(--border-strong);
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--sans);
  white-space: nowrap;
}
.pill:hover { background: var(--surface2); }
.pill.active { background: var(--green); color: white; border-color: var(--green); }

.tx-filter-select {
  display: none;
  font-family: var(--sans);
  font-size: 13px;
  padding: 6px 10px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.tx-balance-display {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.tx-balance-label { color: var(--text-faint); }
.tx-balance-value { font-weight: 500; font-family: var(--mono); }
.tx-balance-value.pos { color: var(--green); }
.tx-balance-value.neg { color: var(--red); }

.tx-table {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tx-header {
  display: grid;
  grid-template-columns: 75px 1fr 130px 120px 90px;
  gap: 8px;
  padding: 9px 15px;
  background: var(--surface2);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 0.5px solid var(--border);
}
.tx-row {
  display: grid;
  grid-template-columns: 75px 1fr 130px 120px 90px;
  gap: 8px;
  padding: 11px 15px;
  border-bottom: 0.5px solid var(--border);
  align-items: center;
  font-size: 13px;
  transition: background .1s;
  cursor: pointer;
}
.tx-row:last-child { border-bottom: none; }
.tx-row:hover { background: var(--surface2); }
.tx-row.coming { background: #FAFAF7; }
.tx-date { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.tx-account-col { font-size: 12px; color: var(--text-muted); }
.tx-amount { font-family: var(--mono); text-align: right; }
.tx-amount.pos { color: var(--green); }
.tx-amount.neg { color: var(--red); }
.tx-status { text-align: center; }
.tx-empty {
  padding: 2rem;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}

/* ─── Tags / Badges ─── */
.tag {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 99px;
  display: inline-block;
}
.tag-done { background: var(--surface2); color: var(--text-muted); }
.tag-coming { background: var(--amber-light); color: var(--amber); }

/* ─── Projection ─── */
.proj-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.proj-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
}
.proj-card.highlight { border-color: var(--green); }
.proj-label { font-size: 11px; color: var(--text-faint); margin-bottom: 5px; }
.proj-value {
  font-size: clamp(13px, 2.5vw, 20px);
  font-weight: 500;
  font-family: var(--mono);
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.proj-value.pos { color: var(--green); }
.proj-value.neg { color: var(--red); }

.upcoming-table {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.upcoming-header {
  display: grid;
  grid-template-columns: 1fr 100px 120px;
  gap: 8px;
  padding: 9px 15px;
  background: var(--surface2);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 0.5px solid var(--border);
}
.upcoming-row {
  display: grid;
  grid-template-columns: 1fr 100px 120px;
  gap: 8px;
  padding: 11px 15px;
  border-bottom: 0.5px solid var(--border);
  align-items: center;
  font-size: 13px;
}
.upcoming-row:last-child { border-bottom: none; }
.upcoming-row:hover { background: var(--surface2); }

.recur-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 8px;
}
.dot-recur { background: var(--amber); }
.dot-once  { background: var(--border-strong); }
.recur-label { font-size: 11px; }
.recur-label.r { color: var(--amber); }
.recur-label.o { color: var(--text-faint); }

/* ─── Comptes list ─── */
.accounts-list { display: flex; flex-direction: column; gap: 8px; }
.account-list-row {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.account-list-info { flex: 1; min-width: 0; }
.account-list-name { font-size: 14px; font-weight: 500; }
.account-list-meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.account-list-balance {
  font-size: 18px;
  font-weight: 500;
  font-family: var(--mono);
  flex-shrink: 0;
}
.account-list-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ─── Forms ─── */
.form-group { margin-bottom: 1rem; }
.form-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 5px;
  display: block;
}
.form-control {
  width: 100%;
  padding: 8px 10px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  appearance: none;
}
.form-control:focus { border-color: var(--green); }

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

/* ─── Overlays / Modals ─── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.overlay.open { display: flex; }

.overlay-modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 440px;
  margin: 1rem;
  max-height: 90vh;
  overflow-y: auto;
}
.overlay-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 1.25rem;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 1.25rem;
  align-items: center;
}

/* Balance adjust box */
.balance-adjust-box {
  background: var(--green-light);
  border: 0.5px solid var(--green);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 8px;
  display: none;
}
.balance-adjust-box.show { display: block; }
.balance-adjust-info { font-size: 13px; color: var(--green-mid); margin-bottom: 10px; }
.balance-adjust-info span { font-weight: 500; font-family: var(--mono); }
.balance-adjust-box.negative { background: var(--red-light); border-color: var(--red); }
.balance-adjust-box.negative .balance-adjust-info { color: var(--red); }

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--text);
  color: white;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  transform: translateY(8px);
  transition: all .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-faint);
}
.empty-state p { font-size: 14px; margin-bottom: 1rem; }
.empty-state .empty-icon {
  font-size: 32px;
  margin-bottom: 1rem;
  opacity: .4;
}

/* ─── Spinner ─── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

/* ─── Global btn (dashboard détails) ─── */
.global-btn {
  background: none;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 11px;
  font-family: var(--sans);
  color: var(--text-muted);
  cursor: pointer;
}
.global-btn:hover { background: var(--surface2); }

/* ─── Loading overlay ─── */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity .2s;
}
.page-loader.hidden { opacity: 0; pointer-events: none; }
.page-loader-inner { text-align: center; color: var(--text-faint); font-size: 13px; }
.loader-ring {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 12px;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — Mobile (<768px) : bottom nav bar
═══════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: 56px;
    flex-direction: row;
    border-right: none;
    border-top: 0.5px solid var(--border);
    position: fixed;
    bottom: 0;
    top: auto;
    overflow: hidden;
  }
  .logo { display: none; }
  .nav {
    display: flex;
    flex-direction: row;
    padding: 0;
    flex: 1;
  }
  .nav-item {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    padding: 8px 4px;
    font-size: 10px;
    border-left: none;
    border-top: 2px solid transparent;
    justify-content: center;
    text-align: center;
  }
  .nav-item.active {
    border-top-color: var(--green);
    border-left-color: transparent;
  }
  .sidebar-footer { display: none; }
  .main {
    margin-left: 0;
    margin-bottom: 56px;
  }

  /* Tables */
  .tx-header,
  .tx-row { grid-template-columns: 65px 1fr 90px; }
  .tx-header span:nth-child(3),
  .tx-row .tx-account-col { display: none; }

  /* Grids */
  .totals-row,
  .proj-grid { grid-template-columns: 1fr; }
  .flux-grid  { grid-template-columns: 1fr; }

  /* Accounts */
  .account-list-actions { flex-direction: column; }

  /* Transactions filter */
  .tx-pills { display: none; }
  .tx-filter-select { display: block; }

  /* Page content padding */
  .page-content { padding: 1rem; }
  .topbar { padding: .75rem 1rem; }
}
