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

:root {
  --green: #2d6a4f;
  --green-light: #52b788;
  --green-pale: #d8f3dc;
  --bureau1: #52b788;
  --bureau2: #74c69d;
  --text: #1b4332;
  --gray: #6c757d;
  --bg: #f8fffe;
  --white: #ffffff;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.1);
}

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

.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* LOGIN */
.login-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 40px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
}

.logo { text-align: center; margin-bottom: 20px; }
.logo-icon { font-size: 56px; margin-bottom: 12px; }
.logo h1 { font-size: 24px; color: var(--green); font-weight: 700; }
.logo p { color: var(--gray); font-size: 14px; margin-top: 4px; }

.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-weight: 600; font-size: 14px; color: var(--text); }

select, input[type="password"], input[type="time"] {
  padding: 14px 16px;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius);
  font-size: 16px;
  background: var(--white);
  color: var(--text);
  width: 100%;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
select:focus, input:focus {
  outline: none;
  border-color: var(--green);
}

.btn-primary {
  background: var(--green);
  color: white;
  border: none;
  padding: 16px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s;
}
.btn-primary:hover { background: #1b4332; }
.btn-secondary {
  background: transparent;
  color: var(--gray);
  border: 2px solid #e0e0e0;
  padding: 14px;
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
  width: 100%;
}

.error { color: #e63946; font-size: 14px; text-align: center; padding: 8px; }

/* NAV */
nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 1px solid #e0e0e0;
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}
.nav-btn {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: none;
  font-size: 12px;
  color: var(--gray);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}
.nav-btn.active { color: var(--green); font-weight: 600; }

/* SCREEN HEADER */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 12px;
  background: var(--white);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.screen-header button {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--green);
  padding: 4px 12px;
}
.screen-header h2 { font-size: 18px; text-transform: capitalize; }

/* LÉGENDE */
.bureaux-legend {
  display: flex;
  gap: 12px;
  padding: 8px 16px;
  background: var(--white);
}
.legend-item {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.bureau-1 { background: #c7f0d8; color: #1b4332; }
.bureau-2 { background: #a8dab5; color: #1b4332; }

/* CALENDRIER */
.calendar-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-header {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray);
  padding: 6px 0;
  text-transform: uppercase;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--white);
  border: 1px solid #e8e8e8;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 2px;
  transition: transform 0.1s;
  overflow: hidden;
  min-height: 50px;
}
.cal-day:active { transform: scale(0.95); }
.cal-day.empty { background: transparent; border: none; cursor: default; }
.cal-day.today { border-color: var(--green); border-width: 2px; }
.cal-day.past { opacity: 0.5; }

.cal-day-num {
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 3px;
}

.cal-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: center;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.dot.b1 { background: var(--bureau1); }
.dot.b2 { background: var(--bureau2); }

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
}
.modal-content {
  background: var(--white);
  border-radius: 20px 20px 0 0;
  padding: 24px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; }
.modal-header button {
  background: #f0f0f0;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 14px;
}
.modal-actions { margin-top: 16px; }

/* RÉSERVATIONS DANS MODAL */
.reservation-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 8px;
}
.res-b1 { background: #c7f0d8; }
.res-b2 { background: #a8dab5; }
.res-info { flex: 1; }
.res-bureau { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--gray); }
.res-therapeute { font-size: 15px; font-weight: 600; }
.res-horaire { font-size: 13px; color: var(--gray); }
.btn-delete {
  background: none;
  border: none;
  color: #e63946;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

/* PERMANENCES */
.permanences-list { padding: 16px; }
.perm-day {
  background: var(--white);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.perm-day-header {
  background: var(--green);
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.perm-day-title { font-weight: 600; font-size: 15px; text-transform: capitalize; }
.perm-count { font-size: 12px; opacity: 0.8; }
.perm-inscriptions { padding: 12px 16px; }
.perm-therapeute {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}
.perm-therapeute:last-child { border-bottom: none; }
.btn-perm-rejoindre {
  width: 100%;
  padding: 12px;
  background: var(--green-pale);
  color: var(--green);
  border: 2px dashed var(--green-light);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.btn-perm-quitter {
  background: none;
  border: none;
  color: #e63946;
  cursor: pointer;
  font-size: 16px;
}

/* COMPTE */
.compte-container { padding: 24px 16px; max-width: 500px; margin: 0 auto; }
.compte-header { text-align: center; margin-bottom: 24px; }
.avatar { font-size: 48px; margin-bottom: 8px; }
.compte-header h2 { font-size: 22px; font-weight: 700; }
.heures-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.heures-label { font-size: 14px; color: var(--gray); }
.heures-value { font-size: 28px; font-weight: 700; color: var(--green); }
.mes-reservations { margin: 20px 0; }
.mes-reservations h3 { font-size: 16px; margin-bottom: 12px; }

/* HEADER STATIQUE permanences */
.screen-header-static {
  padding: 20px 16px 12px;
  background: var(--white);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.screen-header-static h2 { font-size: 18px; }

/* SECTION PERMANENCES */
.perm-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-transform: capitalize;
}
.perm-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: none;
}
.perm-badge.readonly { background: #e9ecef; color: #6c757d; }
.perm-badge.open     { background: #d8f3dc; color: #1b4332; }
.perm-badge.closed   { background: #ffe8e8; color: #c0392b; }

/* AUTO-INSCRIPTIONS */
.perm-auto { opacity: 0.75; }
.perm-auto-badge {
  font-size: 10px;
  background: #e9ecef;
  color: #6c757d;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
  vertical-align: middle;
}

/* BARRES CALENDRIER (remplace dots) */
.cal-bars {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 2px;
}
.cal-bar {
  height: 5px;
  border-radius: 3px;
  width: 100%;
}
.cal-bar.b1 { background: var(--bureau1); }
.cal-bar.b2 { background: var(--bureau2); }
.cal-bar.tp { opacity: 0.5; background-image: repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(255,255,255,0.4) 2px, rgba(255,255,255,0.4) 4px); }
.cal-bar-more { font-size: 9px; color: var(--gray); text-align: center; line-height: 1; }

/* LÉGENDE FILTRE */
.legend-item { cursor: pointer; transition: opacity 0.2s, box-shadow 0.2s; }
.legend-item.active { box-shadow: 0 0 0 2px #2d6a4f; }
.legend-item:hover { opacity: 0.8; }

/* BADGE TP */
.badge-tp {
  display: inline-block;
  font-size: 10px;
  background: #fff3cd;
  color: #856404;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
  vertical-align: middle;
}

/* COMPTE */
.compte-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gray);
  letter-spacing: 0.5px;
  padding: 16px 0 6px;
}
.heures-row { display: flex; gap: 10px; }
.heures-card.half { flex: 1; }
.heures-value.tp { color: #856404; }
.heures-value.solde-pos { color: #2d6a4f; }
.heures-value.solde-neg { color: #e63946; }
.heures-value { font-size: 22px; font-weight: 700; color: var(--green); }
