/* =====================================================================
   ExpenseTracker — CSS principal
   Variables → Reset → Layout → Composants → Utilitaires
   ===================================================================== */

:root {
  --primary:      #2563eb;
  --primary-dark: #1d4ed8;
  --success:      #16a34a;
  --warning:      #d97706;
  --danger:       #dc2626;
  --info:         #0891b2;
  --gray-50:      #f8fafc;
  --gray-100:     #f1f5f9;
  --gray-200:     #e2e8f0;
  --gray-400:     #94a3b8;
  --gray-600:     #475569;
  --gray-800:     #1e293b;
  --white:        #ffffff;
  --font:         'Inter', system-ui, -apple-system, sans-serif;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }
body { font-family: var(--font); background: var(--gray-50); color: var(--gray-800); line-height: 1.5; }
a    { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ── Navbar ──────────────────────────────────────────────────── */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 56px;
  gap: 24px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.navbar-brand a { display: flex; align-items: center; text-decoration: none; }
.navbar-title { font-weight: 700; font-size: 1.1rem; color: var(--primary); }
.navbar-logo  { height: 32px; }
.navbar-menu  { display: flex; gap: 4px; flex: 1; }
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius);
  color: var(--gray-600);
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s;
}
.nav-link:hover, .nav-link.active {
  background: var(--gray-100);
  color: var(--primary);
  text-decoration: none;
}
.navbar-user { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.user-name   { font-size: .88rem; color: var(--gray-600); }
.dropdown { position: relative; }
.dropdown-toggle {
  background: none; border: none; cursor: pointer;
  padding: 4px 8px; color: var(--gray-600);
}
.dropdown-menu {
  display: none; position: absolute; right: 0; top: 110%;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  min-width: 180px; z-index: 200;
}
.dropdown:hover .dropdown-menu { display: block; }
.dropdown-item {
  display: block; padding: 10px 16px;
  font-size: .9rem; color: var(--gray-800);
}
.dropdown-item:hover { background: var(--gray-50); text-decoration: none; }
.dropdown-divider { border-top: 1px solid var(--gray-200); my-1: 4px; }
.text-danger { color: var(--danger); }

/* ── Layout principal ────────────────────────────────────────── */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px;
}
.footer {
  text-align: center;
  padding: 24px;
  font-size: .8rem;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-200);
  margin-top: 48px;
}

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header h2 { font-size: 1.4rem; font-weight: 700; }
.page-header-actions { display: flex; gap: 8px; align-items: center; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-header {
  padding: 14px 20px 0;
  border-bottom: 1px solid var(--gray-100);
  padding-bottom: 14px;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }
.card--info { border-color: #bfdbfe; background: #eff6ff; }

/* ── KPI Grid ────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-grid--sm .kpi-value { font-size: 1.3rem; }
.kpi-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.kpi-card--blue   { border-left: 4px solid var(--primary); }
.kpi-card--orange { border-left: 4px solid var(--warning); }
.kpi-card--green  { border-left: 4px solid var(--success); }
.kpi-label { font-size: .8rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--gray-800); }

/* ── 2-col grid ──────────────────────────────────────────────── */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: .9rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all .15s;
  text-decoration: none; line-height: 1.4;
}
.btn-primary  { background: var(--primary); color: var(--white); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-ghost    { background: transparent; color: var(--gray-600); border-color: var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); text-decoration: none; }
.btn-outline  { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: #eff6ff; text-decoration: none; }
.btn-block    { width: 100%; justify-content: center; }
.btn-sm       { padding: 5px 12px; font-size: .82rem; }
.btn-icon     { background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.btn-icon:hover { background: var(--gray-100); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .88rem; font-weight: 500; margin-bottom: 6px; color: var(--gray-600); }
.form-control {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  font-size: .9rem; color: var(--gray-800);
  background: var(--white); transition: border-color .15s;
}
.form-control:focus  { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback    { font-size: .8rem; color: var(--danger); margin-top: 4px; }
.form-control-sm     { padding: 5px 10px; font-size: .85rem; }
.form-row            { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-section-title  { font-size: .95rem; font-weight: 600; margin: 20px 0 12px; padding-top: 16px; border-top: 1px solid var(--gray-200); }
.form-actions        { display: flex; gap: 12px; margin-top: 20px; }
.filters-form        { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }

/* ── Alerts ──────────────────────────────────────────────────── */
.flash-container { max-width: 1280px; margin: 12px auto 0; padding: 0 24px; }
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 12px; display: flex; justify-content: space-between;
  font-size: .9rem; border: 1px solid transparent;
}
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.alert-close   { background: none; border: none; cursor: pointer; font-size: 1.2rem; opacity: .5; }
.alert-close:hover { opacity: 1; }

/* ── Table ───────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
  padding: 10px 14px; text-align: left;
  font-size: .78rem; font-weight: 600; color: var(--gray-400);
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--gray-200);
}
.table td  { padding: 10px 14px; border-bottom: 1px solid var(--gray-100); }
.table-hover tbody tr:hover td { background: var(--gray-50); }
.table-sm th, .table-sm td { padding: 7px 12px; }
.text-right   { text-align: right; }
.font-bold    { font-weight: 700; }
.tfoot-totals td { background: var(--gray-50); border-top: 2px solid var(--gray-200); }
.row-doublon  { opacity: .6; font-style: italic; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 999px; font-size: .75rem; font-weight: 600;
}
.badge-done       { background: #dcfce7; color: #166534; }
.badge-pending    { background: #fef9c3; color: #854d0e; }
.badge-processing { background: #dbeafe; color: #1e40af; }
.badge-error      { background: #fee2e2; color: #991b1b; }
.badge-doublon    { background: #f3e8ff; color: #6b21a8; }

/* ── Dropzone ────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--gray-200);
  border-radius: 12px; padding: 48px 24px;
  text-align: center; cursor: pointer;
  transition: all .2s; background: var(--gray-50);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary); background: #eff6ff;
}
.dropzone-icon { font-size: 2.5rem; margin-bottom: 12px; }
.dropzone-text { font-size: 1rem; color: var(--gray-600); }
.dropzone-hint { font-size: .82rem; color: var(--gray-400); margin-top: 4px; }
.link-style    { cursor: pointer; color: var(--primary); }

/* ── File list ───────────────────────────────────────────────── */
.file-list   { margin-top: 16px; }
.file-list ul { list-style: none; }
.file-item   {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius); margin-bottom: 8px;
  background: var(--white);
}
.file-name   { flex: 1; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size   { font-size: .8rem; color: var(--gray-400); flex-shrink: 0; }
.file-chip   { font-size: .8rem; color: var(--gray-600); cursor: default; }

/* ── Auth pages ──────────────────────────────────────────────── */
.auth-page { background: var(--gray-100); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-container { width: 100%; max-width: 440px; padding: 24px; }
.auth-container--wide { max-width: 640px; }
.auth-card { background: var(--white); border-radius: 12px; box-shadow: var(--shadow-md); padding: 36px; }
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-logo   { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.auth-subtitle { color: var(--gray-400); font-size: .9rem; margin-top: 4px; }
.auth-form   { display: flex; flex-direction: column; gap: 4px; }
.auth-links  { text-align: center; margin-top: 20px; font-size: .88rem; display: flex; justify-content: center; gap: 12px; color: var(--gray-400); }

/* ── Info box ────────────────────────────────────────────────── */
.info-box {
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: var(--radius); padding: 16px 20px;
  font-size: .88rem; color: #1e40af;
}
.info-box ol { padding-left: 20px; margin-top: 8px; }
.info-box li { margin-bottom: 4px; }

/* ── Progress bar mini ───────────────────────────────────────── */
.progress-bar-mini {
  display: flex; align-items: center; gap: 8px; min-width: 120px;
}
.progress-fill {
  height: 6px; background: var(--primary); border-radius: 3px;
  min-width: 4px; flex-shrink: 0;
}
.progress-bar-mini span { font-size: .78rem; color: var(--gray-600); flex-shrink: 0; }

/* ── Code display ────────────────────────────────────────────── */
.code-display { margin-top: 12px; }
.code-value   {
  font-size: 2rem; font-weight: 800; letter-spacing: .2em;
  color: var(--primary); text-align: center; padding: 16px;
  background: var(--gray-50); border-radius: var(--radius);
  border: 2px dashed var(--gray-200);
}

/* ── Misc ────────────────────────────────────────────────────── */
.text-muted  { color: var(--gray-400); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 20px; }
.mb-4 { margin-bottom: 20px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.empty-state  { padding: 48px; text-align: center; color: var(--gray-400); }

code { background: var(--gray-100); padding: 1px 6px; border-radius: 4px; font-size: .85em; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2col { grid-template-columns: 1fr; }
  .form-row  { grid-template-columns: 1fr; }
  .navbar-menu { display: none; }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .main-content { padding: 16px; }
  .auth-card { padding: 24px 20px; }
}
