/* =============================================
   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);
  border-bottom: none;
  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;
  margin-left: auto;
}

.lang-toggle {
  display: flex;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}
.lang-toggle-opt {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink-soft);
  line-height: 1;
}
.lang-toggle-opt:hover { color: var(--ink); }
.lang-toggle-opt.active { background: var(--blue); color: #fff; }

.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;
  text-decoration: none;
  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;
}
/* Toujours caché en desktop — seulement visible via @media mobile */
@media (min-width: 769px) {
  .nav-hamburger { display: none !important; }
  .nav-drawer { display: none !important; }
}
.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;
  padding-bottom: 16px;
  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: flex !important;
    gap: 10px;
  }
  /* Masquer nom, role, déconnexion sur mobile — garder toggle + avatar */
  .nav-right .user-info { display: none; }
  .nav-right .btn { display: none; }
  .nav-hamburger { display: none; }

  /* 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; }
}


/* =============================================
   BOUTONS FLOTTANTS FIXES
   ============================================= */
.floating-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg);
  backdrop-filter: blur(12px);
}

.floating-actions .btn {
  padding: 13px 36px;
  border-radius: 50px;
  font-size: 14.5px;
  font-weight: 600;
  min-width: 140px;
  transition: transform .15s, box-shadow .15s;
}

.floating-actions .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}

/* Ajouter du padding en bas du contenu pour que la barre flottante ne cache pas le contenu */
.main-content {
  padding-bottom: 96px;
}

@media (max-width: 768px) {
  .floating-actions { padding: 12px 16px; gap: 8px; }
  .floating-actions .btn { flex: 1; min-width: 0; padding: 13px 16px; justify-content: center; }
}

/* =============================================
   BOUTONS FLOTTANTS — 3 boutons
   ============================================= */
.floating-actions.three {
  gap: 8px;
}
.floating-actions.three .btn {
  padding: 13px 20px;
  min-width: 0;
  flex: 1;
  justify-content: center;
}

/* =============================================
   APPLE PAY STYLE — Améliorations visuelles
   ============================================= */

/* Solde centré et dominant */
.wallet-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 0 32px;
}
.wallet-hero .balance-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 12px;
}
.wallet-hero .balance-amount {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 10px;
}
.wallet-hero .balance-change {
  font-size: 14px;
  color: var(--ink-soft);
}

/* Sparkline container */
.sparkline-wrap {
  width: 100%;
  max-width: 400px;
  margin: 24px auto 0;
  height: 48px;
  opacity: .5;
}

/* Photo de profil */
.avatar-img {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

/* Transactions — couleurs */
.amount.positive { color: var(--green); }
.amount.negative { color: #e6453c; }

/* Modale */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal-sheet {
  background: var(--bg-panel);
  border-radius: 24px 24px 0 0;
  padding: 32px 28px 48px;
  width: 100%;
  max-width: 560px;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}
.modal-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 4px;
  margin: 0 auto 24px;
}
.modal-title {
  font-family: "Inter Tight", sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 24px;
  text-align: center;
}
.modal-input {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
  font-size: 28px;
  font-family: "Inter Tight", sans-serif;
  font-weight: 600;
  text-align: center;
  outline: none;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}
.modal-sub {
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  margin-bottom: 24px;
}

/* Confirmation animée */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.confirm-overlay.show {
  opacity: 1;
  pointer-events: all;
}
.confirm-check {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: #fff;
  transform: scale(0);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.confirm-overlay.show .confirm-check {
  transform: scale(1);
}

/* PIN overlay */
.pin-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
}
.pin-title {
  font-family: "Inter Tight", sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
}
.pin-dots {
  display: flex;
  gap: 14px;
}
.pin-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--border);
  transition: background .15s;
}
.pin-dot.filled { background: var(--blue); }
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  grid-template-rows: repeat(4, 72px);
  gap: 12px;
}
.pin-key {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 22px;
  font-weight: 600;
  font-family: "Inter Tight", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .1s, background .15s;
  user-select: none;
}
.pin-key:active { transform: scale(.92); background: var(--border); }
.pin-key.del { font-size: 18px; }
.pin-key.empty { visibility: hidden; }

@media (max-width: 768px) {
  .wallet-hero .balance-amount { font-size: 52px; }
}

/* =============================================
   WALLET HERO — Mobile
   ============================================= */
@media (max-width: 768px) {
  .wallet-hero {
    padding: 32px 0 24px;
  }
  .wallet-hero .balance-amount {
    font-size: 52px;
  }
  .wallet-hero .balance-amount .cents {
    font-size: 24px;
  }
  .sparkline-wrap {
    max-width: 100%;
    padding: 0 8px;
  }

  /* Modale pleine largeur sur mobile */
  .modal-sheet {
    border-radius: 24px 24px 0 0;
    padding: 24px 20px 40px;
  }
  .modal-input {
    font-size: 24px;
  }

  /* PIN clavier adapté mobile */
  .pin-pad {
    grid-template-columns: repeat(3, 80px);
    grid-template-rows: repeat(4, 80px);
  }
  .pin-key {
    width: 80px;
    height: 80px;
    font-size: 24px;
  }

  /* Tableau transactions → cartes sur mobile */
  .tx-table td[data-label="Montant"] {
    font-size: 16px;
  }
}

@media (max-width: 420px) {
  .wallet-hero .balance-amount { font-size: 44px; }
  .wallet-hero .balance-amount .cents { font-size: 20px; }
  .pin-pad {
    grid-template-columns: repeat(3, 72px);
    grid-template-rows: repeat(4, 72px);
  }
  .pin-key { width: 72px; height: 72px; font-size: 22px; }
}

/* Toggle thème visible dans le drawer mobile */
@media (max-width: 768px) {
  .nav-drawer {
    min-height: calc(100vh - 64px);
  }
  .theme-toggle {
    width: 42px;
    height: 42px;
    font-size: 18px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--ink);
  }
  .nav-drawer-foot {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    padding: 16px 0;
  }
}

/* Fix drawer footer caché par les boutons flottants */
@media (max-width: 768px) {
  .nav-drawer {
    padding-bottom: 100px !important;
  }
  .nav-drawer-foot {
    position: fixed;
    bottom: 80px;
    left: 0;
    right: 0;
    padding: 16px 24px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
  }
}

/* =============================================
   ADMIN — Responsive Mobile
   ============================================= */
@media (max-width: 768px) {

  /* Nav admin */
  .admin-nav {
    padding: 0 16px;
    gap: 0;
    justify-content: space-between;
    flex-wrap: wrap;
    height: auto;
    min-height: 56px;
  }
  .admin-links {
    display: none;
  }
  .admin-nav > a:last-child {
    font-size: 12px;
    padding: 6px 10px;
  }

  /* Stats grid */
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  /* Admin content */
  .admin-content {
    padding: 20px 16px !important;
  }

  /* Tables → cartes */
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody,
  .admin-table tr, .admin-table td {
    display: block;
    width: 100%;
  }
  .admin-table tr {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
    background: var(--bg-panel);
  }
  .admin-table td {
    border: none;
    padding: 4px 0;
    font-size: 13px;
  }
  .admin-table td:first-child {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
  }
  .admin-table td:last-child {
    text-align: left;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }

  /* Actions en colonne */
  .admin-table form {
    flex-direction: column !important;
    gap: 8px !important;
    margin-top: 8px;
  }
  .action-btn {
    width: 100%;
    padding: 10px !important;
    text-align: center;
  }

  /* Section titles */
  .section-title {
    font-size: 16px !important;
  }

  /* Admin section */
  .admin-section, [style*="background:var(--bg-panel);border:1px solid var(--border);border-radius:16px"] {
    padding: 16px !important;
  }
}

@media (max-width: 420px) {
  .admin-brand span:not(.admin-badge) {
    display: none;
  }
}

/* =============================================
   ADMIN — Tables responsive (toutes les pages)
   ============================================= */
@media (max-width: 768px) {
  .admin-content { padding: 16px !important; }
  .stats-grid { grid-template-columns: 1fr !important; gap: 12px; }

  /* Toutes les tables admin → cartes */
  table { display: block; width: 100%; }
  table thead { display: none; }
  table tbody { display: block; }
  table tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
    background: var(--bg-panel);
  }
  table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border: none;
    font-size: 13px;
    color: var(--ink);
    border-bottom: 1px solid var(--border);
  }
  table td:last-child { border-bottom: none; }
  table td:first-child { font-weight: 600; font-size: 14px; }

  /* Formulaires actions → pleine largeur */
  table form { flex-direction: column !important; width: 100%; }
  .action-btn { width: 100% !important; padding: 10px !important; text-align: center; margin-top: 4px; }

  /* Recherche admin */
  form[method=\"GET\"] {
    flex-direction: column !important;
    width: 100%;
  }
  form[method=\"GET\"] input { width: 100% !important; }
  form[method=\"GET\"] button { width: 100%; }

  /* Header section admin */
  [style*=\"display:flex;justify-content:space-between\"] {
    flex-direction: column !important;
    gap: 12px;
  }

  /* Profil upgrade — grid 1 colonne */
  [style*=\"grid-template-columns:1fr 1fr\"] {
    grid-template-columns: 1fr !important;
  }

  /* Boutons Pro/Admin plus grands */
  .stat-card { padding: 16px !important; }
  .stat-value { font-size: 26px !important; }
}
