/* =============================================
   HALO — Design System
   Couleurs, typographie, composants
   ============================================= */

/* --- Variables mode clair (défaut) --- */
:root,
[data-theme="light"] {
  --bg:        #ffffff;
  --bg-panel:  #fafbfc;
  --border:    #eef0f3;
  --ink:       #0b1220;
  --ink-soft:  #9aa3ad;
  --blue:      #007AFF;
  --blue-bg:   #e8f2ff;
  --green:     #1cb35c;
  --green-bg:  #eaf6ee;
  --orange:    #b3690a;
  --orange-bg: #fff4e5;
  --shadow:    rgba(10, 30, 60, .06);
}

/* --- Variables mode sombre --- */
[data-theme="dark"] {
  --bg:        #0b0f17;
  --bg-panel:  #111722;
  --border:    #1c212c;
  --ink:       #f4f6f8;
  --ink-soft:  #6b7480;
  --blue:      #3d9bff;
  --blue-bg:   #0d2040;
  --green:     #34d47a;
  --green-bg:  #0d2e1a;
  --orange:    #f5a623;
  --orange-bg: #2a1c06;
  --shadow:    rgba(0, 0, 0, .3);
}

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

html { font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  transition: background .2s, color .2s;
}

a { text-decoration: none; color: inherit; }

/* =============================================
   NAVIGATION HORIZONTALE
   ============================================= */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 40px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.nav-brand .ring {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 3.5px solid var(--blue);
  transition: border-color .2s;
}

.nav-brand span {
  font-family: 'Inter Tight', sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-item {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-soft);
  transition: background .15s, color .15s;
}

.nav-item:hover {
  background: var(--border);
  color: var(--ink);
}

.nav-item.active {
  background: var(--bg);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px var(--shadow);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.theme-toggle {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink-soft);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}

.theme-toggle:hover { color: var(--ink); background: var(--border); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.user-role { font-size: 11.5px; color: var(--ink-soft); }

/* =============================================
   CONTENU PRINCIPAL
   ============================================= */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 40px;
}

/* =============================================
   DASHBOARD — EN-TÊTE SOLDE
   ============================================= */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 48px;
}

.balance-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.balance-amount {
  font-family: 'Inter Tight', sans-serif;
  font-size: 52px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1;
}

.balance-amount .cents {
  font-size: 26px;
  color: var(--ink-soft);
  font-weight: 500;
}

.balance-change {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

.balance-change b { color: var(--ink); font-weight: 600; }

.dashboard-actions {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

/* =============================================
   BOUTONS
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  border: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}

.btn:hover { opacity: .88; }
.btn:active { transform: scale(.97); }

.btn-dark {
  background: var(--ink);
  color: var(--bg);
}

.btn-light {
  background: var(--bg-panel);
  color: var(--ink);
  border: 1px solid var(--border);
}

/* =============================================
   TABLEAU DE TRANSACTIONS
   ============================================= */
.section-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 20px;
}

.tx-table {
  width: 100%;
  border-collapse: collapse;
}

.tx-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.tx-table th:last-child,
.tx-table td:last-child { text-align: right; }

.tx-table td {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--ink);
}

.tx-table td.date { color: var(--ink-soft); font-size: 13px; }

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

/* Montants */
.amount { font-weight: 600; white-space: nowrap; }
.amount.positive::before { content: "+ "; }
.amount.negative::before { content: "− "; }

/* =============================================
   BADGES / STATUTS
   ============================================= */
.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 20px;
  white-space: nowrap;
}

.badge-green  { background: var(--green-bg);  color: var(--green);  }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue);   }

/* =============================================
   UTILITAIRES
   ============================================= */
.divider {
  height: 1px;
  background: var(--border);
  margin: 40px 0;
}

.text-soft { color: var(--ink-soft); }
.text-small { font-size: 12.5px; }

/* =============================================
   RESPONSIVE — Mobile first (≤768px)
   ============================================= */

/* --- Hamburger bouton --- */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  flex-shrink: 0;
}
.nav-hamburger span {
  display: block;
  height: 2px;
  width: 22px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform .25s, opacity .2s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* --- Drawer mobile --- */
.nav-drawer {
  display: none;
  position: fixed;
  top: 64px; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  z-index: 99;
  padding: 24px 24px 40px;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
.nav-drawer.open { display: flex; }

.nav-drawer .nav-item {
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-soft);
}
.nav-drawer .nav-item.active {
  background: var(--bg-panel);
  color: var(--ink);
  font-weight: 600;
}

.nav-drawer-foot {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-drawer-foot .nav-user { display: flex; align-items: center; gap: 10px; }

@media (max-width: 768px) {

  /* Nav */
  .topnav {
    padding: 0 20px;
    gap: 0;
    justify-content: space-between;
  }
  .nav-links { display: none; }
  .nav-right { display: none; }
  .nav-hamburger { display: flex; }

  /* Contenu */
  .main-content { padding: 28px 20px; }

  /* Dashboard header — empilé sur mobile */
  .dashboard-header {
    flex-direction: column;
    gap: 24px;
    margin-bottom: 32px;
  }
  .balance-amount { font-size: 42px; }
  .balance-amount .cents { font-size: 22px; }
  .dashboard-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .dashboard-actions .btn { justify-content: center; width: 100%; }

  /* Tableau → cartes empilées */
  .tx-table thead { display: none; }
  .tx-table, .tx-table tbody, .tx-table tr, .tx-table td {
    display: block;
    width: 100%;
  }
  .tx-table tr {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 10px;
  }
  .tx-table tr:last-child { margin-bottom: 0; }
  .tx-table td {
    border: none;
    padding: 3px 0;
    font-size: 14px;
  }
  .tx-table td:last-child { text-align: left; }
  .tx-table td.date { font-size: 12px; }
  .tx-table td[data-label="Montant"] {
    font-size: 17px;
    font-weight: 700;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }

  /* Cagnottes / Solidaire — déjà en cards, OK */

  /* Section label */
  .section-label { margin-bottom: 14px; }

  /* Divider */
  .divider { margin: 28px 0; }

  /* Bouton déconnexion dans drawer */
  .drawer-logout {
    display: inline-flex;
    align-items: center;
    padding: 9px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    background: var(--bg-panel);
    color: var(--ink);
    border: 1px solid var(--border);
    text-decoration: none;
  }
}

@media (max-width: 420px) {
  .balance-amount { font-size: 36px; }
  .balance-amount .cents { font-size: 18px; }
  .main-content { padding: 20px 16px; }
}
