/* ============================================================
   components.css — Composants spécifiques BacTracker Maroc
   Cartes écoles, badges de statut, barre de progression,
   modals, tableaux de candidatures, calendrier, stats.
   ============================================================ */

/* --- Hero (page d'accueil) --- */
.hero {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: var(--color-white);
  padding: 70px 0 90px;
  text-align: center;
}

.hero__logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.hero__logo .logo-badge-lg {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.6rem;
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 14px;
}

.hero p {
  font-size: 1.05rem;
  opacity: 0.92;
  max-width: 560px;
  margin: 0 auto 32px;
}

.hero__actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.hero .btn-primary {
  background: var(--color-white);
  color: var(--color-primary-dark);
}

.hero .btn-primary:hover {
  background: #f0f0f0;
}

.hero .btn-outline {
  border-color: rgba(255, 255, 255, 0.7);
  color: var(--color-white);
}

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

/* --- Bandeau statistiques (page d'accueil) --- */
.stats-band {
  margin-top: -50px;
  padding-bottom: 40px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.stat-card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 26px 18px;
  text-align: center;
}

.stat-card__value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-primary-dark);
}

.stat-card__label {
  color: var(--color-gray);
  font-size: 0.88rem;
  margin-top: 6px;
}

/* --- Pourquoi BacTracker (page accueil) --- */
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 30px;
}

.feature-card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 26px 22px;
}

.feature-card__icon {
  font-size: 1.8rem;
  margin-bottom: 12px;
}

.feature-card h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.feature-card p {
  color: var(--color-gray);
  font-size: 0.9rem;
}

/* --- Dashboard : cartes statistiques --- */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.dash-stat {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.dash-stat__icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.dash-stat__value {
  font-size: 1.5rem;
  font-weight: 800;
}

.dash-stat__label {
  font-size: 0.82rem;
  color: var(--color-gray);
}

/* --- Barre de progression --- */
.progress-card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 28px;
}

.progress-card__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.progress-card__title {
  font-weight: 600;
}

.progress-card__percent {
  font-weight: 800;
  color: var(--color-primary-dark);
  font-size: 1.1rem;
}

.progress-bar-track {
  width: 100%;
  height: 12px;
  background: var(--color-gray-light);
  border-radius: 20px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-dark));
  border-radius: 20px;
  transition: width 0.4s ease;
}

/* --- Filtres (page écoles) --- */
.filters-bar {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.filters-bar .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 160px;
}

/* --- Grille des écoles --- */
.schools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.school-card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.school-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.school-card__header {
  padding: 18px 20px 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.school-card__logo {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}

.school-card__title {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.3;
  overflow-wrap: break-word;
  word-break: break-word;
}

.school-card__city {
  color: var(--color-gray);
  font-size: 0.82rem;
  margin-top: 2px;
}

.school-card__body {
  padding: 14px 20px;
  flex: 1;
}

.school-card__desc {
  color: var(--color-gray);
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.school-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tag {
  background: var(--color-gray-light);
  color: var(--color-gray);
  font-size: 0.76rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.school-card__dates {
  font-size: 0.8rem;
  color: var(--color-gray);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.school-card__footer {
  padding: 14px 20px 20px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid var(--color-border);
  margin-top: 12px;
}

.school-card__footer .btn {
  flex: 1;
  min-width: fit-content;
}

/* --- Badges de statut --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 700;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge--open {
  background: #e6f6ec;
  color: var(--color-success);
}

.badge--soon {
  background: #fdf3df;
  color: var(--color-warning);
}

.badge--closed {
  background: #fbe9e8;
  color: var(--color-danger);
}

.badge--results {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.badge--followed {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.badge--registered {
  background: #e6f6ec;
  color: var(--color-success);
}

/* --- Détail école --- */
.detail-header {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 28px;
  margin-bottom: 24px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .detail-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 20px;
  }

  .detail-header .flex {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .detail-header .btn {
    flex: 1;
  }
}

.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.detail-section {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 20px;
}

.detail-section h3 {
  font-size: 1.05rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.timeline-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-primary);
  margin-top: 4px;
  flex-shrink: 0;
}

.timeline-item__label {
  font-weight: 600;
  font-size: 0.9rem;
}

.timeline-item__date {
  color: var(--color-gray);
  font-size: 0.85rem;
}

/* --- Tableau candidatures --- */
.table-wrapper {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Indicateur discret de scroll horizontal sur mobile */
@media (max-width: 768px) {
  .table-wrapper {
    position: relative;
  }
  .table-wrapper::after {
    content: "← défiler →";
    display: block;
    text-align: center;
    font-size: 0.72rem;
    color: var(--color-gray);
    padding: 6px;
    border-top: 1px solid var(--color-border);
    background: var(--color-gray-light);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
  }
}

table.app-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.app-table th {
  text-align: left;
  padding: 14px 18px;
  background: var(--color-gray-light);
  color: var(--color-gray);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.app-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.92rem;
}

.app-table tr:last-child td {
  border-bottom: none;
}

.days-left {
  font-weight: 700;
}

.days-left--urgent {
  color: var(--color-danger);
}

.days-left--soon {
  color: var(--color-warning);
}

.days-left--ok {
  color: var(--color-success);
}

/* --- Calendrier --- */
.calendar-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

#monthNav {
  flex-wrap: wrap;
}

#monthLabel {
  white-space: nowrap;
}

.view-toggle {
  display: flex;
  background: var(--color-white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.view-toggle button {
  padding: 9px 18px;
  border: none;
  background: transparent;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--color-gray);
}

.view-toggle button.active {
  background: var(--color-primary);
  color: var(--color-white);
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.month-grid .weekday-label {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-gray);
  padding-bottom: 6px;
}

.day-cell {
  background: var(--color-white);
  border-radius: var(--radius-sm);
  min-height: 86px;
  padding: 8px;
  box-shadow: var(--shadow-sm);
  font-size: 0.78rem;
  overflow: hidden; /* empêche tout débordement hors de la cellule */
  min-width: 0;     /* essentiel en grille CSS pour éviter le débordement */
}

.day-cell.empty {
  background: transparent;
  box-shadow: none;
}

.day-cell__num {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--color-gray);
}

.day-cell.today .day-cell__num {
  color: var(--color-primary-dark);
}

.day-cell.today {
  border: 2px solid var(--color-primary);
}

.day-event {
  font-size: 0.68rem;
  padding: 2px 5px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: block;
}

.day-event--more {
  background: var(--color-gray-light) !important;
  color: var(--color-gray) !important;
  font-style: italic;
  font-size: 0.62rem;
}

.list-events {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-event-item {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.list-event-item__content {
  flex: 1 1 200px;
  min-width: 0;
}

.list-event-item__content strong {
  display: block;
  overflow-wrap: break-word;
  word-break: break-word;
}

.list-event-item .badge,
.list-event-item .btn {
  flex-shrink: 0;
}

.list-event-date {
  width: 64px;
  text-align: center;
  flex-shrink: 0;
}

.list-event-date .day-num {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-primary-dark);
  line-height: 1;
}

.list-event-date .month-name {
  font-size: 0.72rem;
  color: var(--color-gray);
  text-transform: uppercase;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-box {
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: 28px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-box__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--color-gray);
}

/* --- Admin table --- */
.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .features-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-stats {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .month-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 3px;
  }

  .day-cell {
    min-height: 52px;
    padding: 3px;
    font-size: 0.62rem;
  }

  .day-cell__num {
    font-size: 0.72rem;
  }

  .day-event {
    font-size: 0.58rem;
    padding: 1px 3px;
  }

  .weekday-label {
    font-size: 0.6rem;
  }

  .filters-bar {
    flex-direction: column;
  }

  .school-card__footer .btn {
    flex: 1 1 100%;
  }

  .list-event-item {
    padding: 14px 16px;
  }

  .calendar-toolbar {
    justify-content: flex-start;
  }

  .view-toggle {
    width: 100%;
  }

  .view-toggle button {
    flex: 1;
  }
}

@media (max-width: 380px) {
  .month-grid {
    gap: 2px;
  }

  .day-cell {
    min-height: 42px;
    font-size: 0.55rem;
    padding: 2px;
  }

  .day-event {
    display: none;
  }

  .day-cell.has-event .day-cell__num::after {
    content: "•";
    color: var(--color-primary);
    margin-left: 3px;
  }
}
