/* ============================================================
   Agenda Philippe Martin — styles globaux
   Mobile-first, responsive
   ============================================================ */

:root {
  --color-primary:    #2563eb;
  --color-primary-h:  #1d4ed8;
  --color-danger:     #dc2626;
  --color-success:    #16a34a;
  --color-warning:    #d97706;
  --color-option:     #f97316;
  --color-confirme:   #dc2626;
  --color-indispo:    #6b7280;
  --color-bg:         #f9fafb;
  --color-surface:    #ffffff;
  --color-border:     #e5e7eb;
  --color-text:       #111827;
  --color-muted:      #6b7280;
  --radius:           8px;
  --shadow:           0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --header-h:         56px;
}

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

html { font-size: 16px; }

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

/* ── Header ──────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #1e3a5f;
  color: #fff;
  height: var(--header-h);
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.header-title h1 {
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.org-name {
  font-size: .85rem;
  opacity: .9;
  white-space: nowrap;
}

/* ── Légende admin ───────────────────────────────────────────────────────── */
.legend-bar {
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  padding: .5rem 1rem;
  font-size: .8rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.legend-org-item {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  border-radius: 20px;
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
}

/* ── Légende statuts ─────────────────────────────────────────────────────── */
.status-legend {
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  padding: .4rem 1rem;
  font-size: .8rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: .35rem;
  color: var(--color-muted);
}
.legend-color {
  display: inline-block;
  width: 24px;
  height: 14px;
  border-radius: 3px;
}
.option-example {
  background: var(--color-option);
}
.option-example-admin {
  background: var(--color-option);
  background-image: repeating-linear-gradient(
    45deg,
    transparent 0px,
    transparent 10px,
    rgba(255,255,255,.9) 10px,
    rgba(255,255,255,.9) 11px
  );
}
.confirme-example { background: var(--color-confirme); }
.indispo-example  { background: var(--color-indispo); }

/* ── Page principale ─────────────────────────────────────────────────────── */
.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

#calendar {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .75rem;
}

/* Mobile : calendrier pleine hauteur, sans padding superflu */
@media (max-width: 700px) {
  /* Décale l'ancre native pour que scrollIntoView respecte les barres sticky */
  html { scroll-padding-top: 116px; } /* 56px header + ~52px fc-toolbar + 8px */
  .app-main {
    padding: 0;
  }
  #calendar {
    border-radius: 0;
    box-shadow: none;
    padding: .25rem;
    min-height: calc(100dvh - 160px); /* hauteur restante après header + légendes */
  }
  /* Barre FullCalendar fixe en vue liste sur mobile */
  .fc .fc-header-toolbar {
    position: sticky;
    top: var(--header-h);   /* colle sous le header de la page (56px) */
    z-index: 50;
    background: #fff;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0;
    padding: .35rem .5rem;
  }
  .fc .fc-toolbar { padding: .4rem .5rem; }
  .fc .fc-toolbar-title { font-size: .95rem !important; }
}

/* FullCalendar overrides */
.fc .fc-toolbar-title   { font-size: 1.1rem !important; }
.fc .fc-button           { text-transform: none !important; }
.fc .fc-button-primary   {
  background: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
}
.fc .fc-button-primary:hover {
  background: var(--color-primary-h) !important;
  border-color: var(--color-primary-h) !important;
}
.fc .fc-button-primary:not(:disabled).fc-button-active {
  background: var(--color-primary-h) !important;
  border-color: var(--color-primary-h) !important;
}
.fc .fc-daygrid-event    { cursor: pointer; font-size: .78rem; }
.fc .fc-list-event                 { cursor: pointer; }
.fc .fc-list-event-time            { display: none; }   /* masquer "all-day" */
.fc .fc-list-event-dot             { display: none; }   /* le badge JS suffit */

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  padding: 1rem;
}
.login-container {
  background: var(--color-surface);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #1e3a5f;
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
  margin-bottom: .75rem;
}
.login-logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
}
.login-logo p {
  font-size: .85rem;
  color: var(--color-muted);
  margin-top: .25rem;
}
.login-form { display: flex; flex-direction: column; gap: .875rem; }

/* ── Formulaires ─────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.form-group label {
  font-size: .85rem;
  font-weight: 600;
  color: #374151;
}
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group input[type=date],
.form-group textarea,
.form-group select {
  padding: .55rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: .9rem;
  color: var(--color-text);
  transition: border-color .15s;
  background: #fff;
  width: 100%;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem;
}
.form-group-full { grid-column: 1 / -1; }
.color-picker-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.color-picker-row input[type=color] {
  width: 40px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
}

/* ── Boutons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .55rem 1.1rem;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}
.btn:active { transform: scale(.97); }
.btn-full    { width: 100%; }
.btn-sm      { padding: .35rem .75rem; font-size: .8rem; }
.btn-xs      { padding: .2rem .5rem;  font-size: .75rem; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-h); }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-secondary:hover { background: #d1d5db; }
.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}
.btn-outline:hover { background: #eff6ff; }
.btn-danger  { background: var(--color-danger);  color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-warning { background: var(--color-warning); color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #15803d; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1rem;
}
.alert-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .25rem .6rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-option   { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.badge-confirme { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge-admin    { background: #1e3a5f; color: #fff; }
.badge-inactif  { background: #f3f4f6; color: #6b7280; }
.org-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  padding: .2rem .5rem;
  border-radius: 20px;
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
@media (min-width: 640px) {
  .modal { align-items: center; }
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
}
.modal-content {
  position: relative;
  background: var(--color-surface);
  border-radius: 12px 12px 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
  box-shadow: 0 25px 60px rgba(0,0,0,.3);
}
@media (min-width: 640px) {
  .modal-content { border-radius: 12px; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.modal-header h2 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--color-muted);
  padding: .2rem .4rem;
  border-radius: 4px;
  line-height: 1;
}
.modal-close:hover { background: #f3f4f6; color: #111; }
.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .875rem;
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: .75rem;
  border-top: 1px solid var(--color-border);
  margin-top: .5rem;
}
.modal-footer-right { display: flex; gap: .5rem; }
body.modal-open { overflow: hidden; }

/* Statut toggle (option/confirmé) */
.statut-toggle {
  display: flex;
  gap: .5rem;
}
.statut-option { display: flex; }
.statut-option input[type=radio] { display: none; }
.statut-label {
  padding: .45rem .9rem;
  border-radius: 6px;
  border: 2px solid var(--color-border);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.statut-option input:checked + .statut-label.option {
  background: #fff7ed;
  border-color: var(--color-option);
  color: #c2410c;
}
.statut-option input:checked + .statut-label.confirme {
  background: #f0fdf4;
  border-color: var(--color-confirme);
  color: #15803d;
}
.statut-label:hover { border-color: #9ca3af; }

/* Vue lecture seule (réservation autre organisme) */
.readonly-status {
  text-align: center;
  padding: 1rem 0;
}
.readonly-status .badge { font-size: .875rem; padding: .4rem 1rem; margin-bottom: .75rem; }
.readonly-status p { color: var(--color-muted); font-size: .875rem; }

/* ── Admin page ──────────────────────────────────────────────────────────── */
.admin-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
}
.card-header h2 { font-size: 1rem; font-weight: 700; }

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table th,
.table td {
  padding: .6rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.table th { font-weight: 600; background: #f9fafb; color: #374151; }
.table tr:hover td { background: #f9fafb; }
.row-inactive td { opacity: .5; }
.actions-cell { display: flex; gap: .25rem; flex-wrap: wrap; }
.color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: .25rem;
}

/* Responsive table */
@media (max-width: 640px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: .5rem; }
  .table td { border: none; padding: .4rem 1rem; }
  .actions-cell { padding: .5rem 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-row  { grid-template-columns: 1fr; }
}

/* Hint sous les champs */
.field-hint {
  font-size: .75rem;
  color: var(--color-muted);
  margin-top: .2rem;
}

/* Utilitaires */
.hidden { display: none !important; }
