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

:root {
  --primary:   #1565C0;
  --primary-d: #0D47A1;
  --accent:    #FF6F00;
  --green:     #2E7D32;
  --red:       #C62828;
  --orange:    #E65100;
  --blue:      #1565C0;
  --bg:        #F5F7FA;
  --card-bg:   #FFFFFF;
  --text:      #212121;
  --text-sub:  #757575;
  --border:    #E0E0E0;
  --radius:    12px;
  --shadow:    0 2px 8px rgba(0,0,0,.10);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Screens (login / app) ──────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* ── LOGIN ──────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-d) 100%);
}

.login-logo {
  text-align: center;
  color: #fff;
  margin-bottom: 28px;
}
.logo-circle {
  font-size: 52px;
  margin-bottom: 8px;
}
.login-logo h1 { font-size: 24px; font-weight: 700; }
.login-logo p  { font-size: 13px; opacity: .8; margin-top: 4px; }

.login-wrap .card { width: 100%; max-width: 380px; }
.login-hint {
  font-size: 12px;
  color: var(--text-sub);
  text-align: center;
  margin-top: 12px;
}

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 14px;
}
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 10px; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}
.form-group input:focus { border-color: var(--primary); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:active { opacity: .85; transform: scale(.98); }
.btn-full   { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-pay     { background: var(--accent); color: #fff; font-size: 16px; padding: 14px; }
.btn-icon {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}
.alert-error   { background: #FFEBEE; color: var(--red); border-left: 3px solid var(--red); }
.alert-success { background: #E8F5E9; color: var(--green); border-left: 3px solid var(--green); }
.alert-info    { background: #E3F2FD; color: var(--blue); border-left: 3px solid var(--blue); }
.alert-warn    { background: #FFF3E0; color: var(--orange); border-left: 3px solid var(--orange); }

/* ── App layout ─────────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--primary);
  padding: 12px 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.header-name  { display: block; color: #fff; font-weight: 700; font-size: 15px; }
.header-classe { display: block; color: rgba(255,255,255,.75); font-size: 12px; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,.08);
}
.nav-tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px;
  border: none; background: transparent;
  color: var(--text-sub);
  font-size: 10px;
  cursor: pointer;
  transition: color .15s;
  gap: 2px;
}
.nav-tab.active { color: var(--primary); }
.nav-icon { font-size: 20px; }
.nav-label { font-weight: 500; }

.app-content {
  padding: 14px 14px 80px;  /* bottom = nav height */
}

/* ── Tab content ────────────────────────────────────────────────────────── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── KPI cards ──────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.kpi-card {
  border-radius: var(--radius);
  padding: 14px;
  color: #fff;
}
.kpi-value { font-size: 22px; font-weight: 700; line-height: 1.1; }
.kpi-label { font-size: 11px; opacity: .85; margin-top: 4px; }
.kpi-red    { background: var(--red); }
.kpi-green  { background: var(--green); }
.kpi-blue   { background: var(--blue); }
.kpi-orange { background: var(--orange); }

/* ── Section title ──────────────────────────────────────────────────────── */
.section-title {
  font-size: 14px; font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 16px 0 8px;
}

/* ── Notes list (dashboard) ─────────────────────────────────────────────── */
.note-item {
  display: flex; align-items: center;
  background: var(--card-bg);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 6px;
  box-shadow: var(--shadow);
  gap: 10px;
}
.note-matiere { flex: 1; font-size: 14px; font-weight: 500; }
.note-trim    { font-size: 11px; color: var(--text-sub); }
.note-avg {
  font-size: 18px; font-weight: 700;
  min-width: 40px; text-align: right;
}
.note-avg.green { color: var(--green); }
.note-avg.orange{ color: var(--orange); }
.note-avg.red   { color: var(--red); }

/* ── Paiements list ─────────────────────────────────────────────────────── */
.pai-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card-bg);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 6px;
  box-shadow: var(--shadow);
}
.pai-left  { display: flex; flex-direction: column; gap: 2px; }
.pai-date  { font-size: 12px; color: var(--text-sub); }
.pai-mode  { font-size: 13px; font-weight: 500; }
.pai-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.pai-montant { font-size: 16px; font-weight: 700; color: var(--green); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase;
}
.badge-green  { background: #E8F5E9; color: var(--green); }
.badge-orange { background: #FFF3E0; color: var(--orange); }
.badge-red    { background: #FFEBEE; color: var(--red); }
.badge-blue   { background: #E3F2FD; color: var(--blue); }

/* ── Notes table ────────────────────────────────────────────────────────── */
.trim-selector {
  display: flex; gap: 8px;
  margin-bottom: 14px;
}
.trim-btn {
  flex: 1;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 13px; font-weight: 600;
  cursor: pointer; color: var(--text-sub);
  transition: all .15s;
}
.trim-btn.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

.notes-table {
  width: 100%; border-collapse: collapse;
  background: #fff; border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.notes-table th {
  background: var(--primary); color: #fff;
  font-size: 12px; padding: 10px 8px;
  text-align: left;
}
.notes-table td {
  padding: 10px 8px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.notes-table tr:last-child td { border-bottom: none; }
.notes-table tr:nth-child(even) td { background: #F9FAFB; }

/* ── Paiement tab ───────────────────────────────────────────────────────── */
.solde-banner {
  background: var(--red);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  color: #fff;
  margin-bottom: 14px;
}
.solde-label  { font-size: 13px; opacity: .85; }
.solde-amount { font-size: 32px; font-weight: 700; }

.provider-choice {
  display: flex; gap: 10px;
  margin: 12px 0;
}
.provider-btn {
  flex: 1; padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 14px; font-weight: 600;
  cursor: pointer; text-align: center;
  transition: all .15s;
}
.provider-btn.active.mtn    { border-color: #FFD600; background: #FFFDE7; color: #F57F17; }
.provider-btn.active.orange { border-color: #FF6F00; background: #FFF3E0; color: #E65100; }
.pay-hint { font-size: 12px; color: var(--text-sub); margin-bottom: 10px; }

/* Spinner */
.progress-anim { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 10px 0; }
.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Absences ───────────────────────────────────────────────────────────── */
.abs-item {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
}
.abs-item.injustifie { border-left-color: var(--red); }
.abs-item.justifie   { border-left-color: var(--green); }
.abs-date { font-size: 12px; color: var(--text-sub); }
.abs-type { font-size: 14px; font-weight: 600; margin: 2px 0; }
.abs-desc { font-size: 13px; color: var(--text-sub); }

/* ── Messages ───────────────────────────────────────────────────────────── */
.msg-compose { background: var(--card-bg); border-radius: 10px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.msg-compose h3 { font-size: 15px; margin-bottom: 10px; color: var(--primary); }
.msg-compose .form-input { width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: var(--bg); color: var(--text); }
.msg-card { background: var(--card-bg); border-radius: 10px; padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow); border-left: 4px solid var(--border); }
.msg-card.msg-unread { border-left-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--card-bg)); }
.msg-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.msg-from { font-weight: 700; font-size: 13px; color: var(--primary); }
.msg-date { font-size: 12px; color: var(--text-sub); }
.msg-sujet { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.msg-contenu { font-size: 13px; color: var(--text-sub); white-space: pre-wrap; }
.badge { background: var(--red); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 5px; margin-left: 4px; }

/* ── Documents ──────────────────────────────────────────────────────────── */
.doc-request { background: var(--card-bg); border-radius: 10px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.doc-request h3 { font-size: 15px; margin-bottom: 10px; color: var(--primary); }
.doc-request .form-input { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: var(--bg); color: var(--text); }
.documents-list table { width: 100%; border-collapse: collapse; }
.documents-list td, .documents-list th { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; text-align: left; }
.empty-state { text-align: center; color: var(--text-sub); padding: 30px 0; font-size: 14px; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 360px) {
  .kpi-value { font-size: 18px; }
  .solde-amount { font-size: 26px; }
}
