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

:root {
  --primary: #2c3e50;
  --primary-light: #34495e;
  --accent: #e74c3c;
  --accent-hover: #c0392b;
  --success: #27ae60;
  --warning: #f39c12;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #dcdde1;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

/* ─── Header ───────────────────────────────────────────────────── */
header {
  background: var(--primary);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

header h1 { font-size: 1.3rem; }
header a { color: #ecf0f1; text-decoration: none; }
header a:hover { color: white; text-decoration: underline; }
header nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
header .current { color: #bdc3c7; font-weight: 600; }

.subtitle { color: var(--text-light); font-size: 0.95rem; margin-bottom: 1.5rem; }

/* ─── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.stage-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s;
  border-left: 4px solid var(--accent);
}

.stage-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.stage-card h3 { margin-bottom: 0.25rem; }
.stage-card .arrow { color: var(--accent); font-weight: 600; font-size: 0.9rem; }

.stage-list { display: flex; flex-direction: column; gap: 0.75rem; }

.login-card { max-width: 420px; margin: 2rem auto; text-align: center; }
.login-card h2 { margin-bottom: 0.5rem; }

.empty-state { text-align: center; color: var(--text-light); padding: 2rem; }

/* ─── Forms ────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-group label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-light);
}

input, select, textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

.form-inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.input-code {
  font-size: 1.2rem;
  text-align: center;
  letter-spacing: 0.1em;
  width: 200px;
}

/* ─── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #219a52; }

.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #bdc3c7; }

.btn-danger { background: var(--accent); color: white; }
.btn-danger:hover { background: var(--accent-hover); }

.btn-outline {
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.5);
}

.btn-outline:hover { background: rgba(255,255,255,0.1); }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1.1rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Tables ───────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

.expense-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.expense-table th {
  background: var(--primary);
  color: white;
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-size: 0.85rem;
}

.expense-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.expense-table tr:last-child td { border-bottom: none; }
.expense-table tr:hover { background: #f8f9fa; }

.amount { font-weight: 700; text-align: right; white-space: nowrap; }

.total-bar {
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
  text-align: right;
  font-size: 1.15rem;
  margin-bottom: 1rem;
}

.upload-row { background: #fff8e1; }
.upload-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.25rem 0;
}

/* ─── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-required { background: #fde8e8; color: var(--accent); }
.badge-optional { background: #e8f4fd; color: #2980b9; }
.badge-success { background: #d4edda; color: #155724; }
.badge-error { background: #fde8e8; color: #721c24; }
.badge-draft { background: #fff3cd; color: #856404; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-missing { background: #fde8e8; color: #c0392b; animation: pulse 1.5s infinite; }
.badge-type { background: #ecf0f1; color: var(--primary); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ─── Alerts ───────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-weight: 500;
}

.alert-error { background: #fde8e8; color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

/* ─── Utils ────────────────────────────────────────────────────── */
.text-muted { color: var(--text-light); }
.text-error { color: var(--accent); }
.meta { color: var(--text-light); font-size: 0.85rem; }
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

.info-box {
  background: #eaf2f8;
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1rem;
}

.info-box h3 { margin-bottom: 0.5rem; }
.info-box ul { list-style: none; padding: 0; }
.info-box li {
  padding: 0.3rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}


.stage-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.stage-lieu {
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 500;
}

.stage-dates {
  margin-bottom: 0.5rem;
}

/* Couleurs : rouge (vide), orange (en cours), vert (clôturé) */
.stage-red { border-left-color: #e74c3c !important; background: #fff5f5; }
.stage-orange { border-left-color: #f39c12 !important; background: #fffdf5; }
.stage-green { border-left-color: #27ae60 !important; background: #f5fff8; }

.action-bar {
  text-align: center;
  margin: 1.5rem 0;
}

.archived-row { opacity: 0.55; }
.archived-row:hover { opacity: 1; }

/* ─── Footer ───────────────────────────────────────────────────── */
footer {
  text-align: center;
  color: var(--text-light);
  font-size: 0.8rem;
  padding: 2rem 0 1rem;
}

/* ─── Responsive ───────────────────────────────────────────────── */
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-inline { flex-direction: column; align-items: stretch; }
  .input-code { width: 100%; }
  header { flex-direction: column; text-align: center; }
  .expense-table { font-size: 0.8rem; }
  .expense-table th, .expense-table td { padding: 0.4rem; }
}

/* ─── Catégories d'événements (stages / événements / autres) ─────────────── */
.cat-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin: 0 0 1.25rem;
}
.cat-tab {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .9rem;
    border: 1px solid rgba(0, 0, 0, .15);
    border-radius: 999px;
    font-size: .9rem;
    text-decoration: none;
    color: inherit;
    background: rgba(255, 255, 255, .6);
    transition: background .15s, border-color .15s;
}
.cat-tab:hover { background: rgba(0, 0, 0, .05); }
.cat-tab.active {
    background: #1f4e79;
    border-color: #1f4e79;
    color: #fff;
    font-weight: 600;
}
.cat-count {
    display: inline-block;
    min-width: 1.4em;
    padding: 0 .35em;
    border-radius: 999px;
    background: rgba(0, 0, 0, .12);
    font-size: .78rem;
    text-align: center;
}
.cat-tab.active .cat-count { background: rgba(255, 255, 255, .28); }

.cat-badge {
    display: inline-block;
    padding: .12rem .5rem;
    margin-right: .5rem;
    border-radius: 4px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
    background: rgba(0, 0, 0, .08);
}
.cat-stage     { background: #dce9f7; color: #14456e; }
.cat-evenement { background: #fde7d0; color: #8a4a08; }
.cat-autre     { background: #e6e2ef; color: #4a3b6b; }
