/* Correctif responsive global + lisibilité calendrier
   Uniquement présentation : aucune logique métier modifiée. */

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

.content,
.app-shell,
.planning-page,
.card,
.table-responsive {
  max-width: 100%;
  min-width: 0;
}

/* Header moderne : éviter les débordements sur tablette/mobile */
.modern-topbar,
.topbar-left,
.topbar-center,
.topbar-right {
  min-width: 0 !important;
}

.modern-topbar .fw-bold,
.modern-topbar .mini-muted,
.top-pill span,
.profile-text strong,
.profile-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* FullCalendar : textes mieux ajustés */
.fc,
.fc * {
  box-sizing: border-box;
}

.fc {
  max-width: 100% !important;
}

.fc .fc-toolbar {
  flex-wrap: wrap !important;
  gap: 8px !important;
}

.fc .fc-toolbar-chunk {
  min-width: 0 !important;
  display: flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
}

.fc .fc-toolbar-title {
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: normal !important;
  line-height: 1.15 !important;
  text-align: center;
}

.fc .fc-button,
.fc .fc-button-primary {
  white-space: nowrap !important;
  line-height: 1.15 !important;
}

.fc .fc-event,
.fc .fc-daygrid-event,
.fc .fc-timegrid-event,
.fc .fc-list-event-title,
.fc .fc-list-event-time {
  max-width: 100% !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}

.fc .fc-event-main,
.fc .fc-event-main-frame,
.fc .fc-event-title,
.fc .fc-event-time {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  line-height: 1.2 !important;
}

.fc .fc-daygrid-event {
  display: block !important;
  padding: 3px 5px !important;
}

.fc .fc-daygrid-event-dot {
  display: none !important;
}

.fc .fc-daygrid-day-frame {
  min-width: 0 !important;
}

.fc .fc-daygrid-day-events {
  min-height: 1.5em !important;
}

.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number {
  max-width: 100% !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
}

/* Table véhicules disponibles */
.availability-table-wrap {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

.availability-table {
  min-width: 760px;
}

.availability-table th,
.availability-table td {
  vertical-align: middle !important;
}

.vehicle-title,
.muted-small,
.status-pill,
.quick-action {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Tablette : simplifier le calendrier et les menus */
@media (max-width: 992px) {
  .content {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .modern-topbar {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .topbar-center {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .top-pill {
    min-width: 0 !important;
    padding: 0 8px !important;
  }

  .planning-header-card {
    align-items: flex-start !important;
  }

  .planning-calendar-card {
    padding: 12px !important;
    overflow-x: hidden !important;
  }

  .fc .fc-toolbar.fc-header-toolbar,
  .fc .fc-toolbar.fc-footer-toolbar {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .fc .fc-toolbar-chunk {
    justify-content: center !important;
    width: 100% !important;
  }

  .fc .fc-toolbar-title {
    font-size: 1.15rem !important;
    width: 100% !important;
  }

  .fc .fc-button {
    font-size: .78rem !important;
    padding: 7px 9px !important;
    border-radius: 10px !important;
  }

  .fc .fc-daygrid-day-frame {
    min-height: 92px !important;
  }

  .fc .fc-daygrid-event {
    font-size: .72rem !important;
    line-height: 1.15 !important;
  }
}

/* Mobile : priorité à la lecture, pas au débordement */
@media (max-width: 768px) {
  .content {
    padding: 72px 10px 16px !important;
  }

  .planning-header-card h3,
  h3 {
    font-size: 1.25rem !important;
    line-height: 1.2 !important;
  }

  .planning-header-card .d-flex.gap-2,
  .planning-header-card .btn {
    width: 100% !important;
  }

  .planning-header-card .d-flex.gap-2 {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .availability-card {
    padding: 12px !important;
  }

  .availability-table {
    min-width: 680px;
  }

  .fc .fc-toolbar-title {
    font-size: 1rem !important;
  }

  .fc .fc-button {
    min-height: 36px !important;
    font-size: .72rem !important;
    padding: 6px 8px !important;
  }

  .fc .fc-list-table {
    table-layout: fixed !important;
    width: 100% !important;
  }

  .fc .fc-list-event-time {
    width: 68px !important;
    min-width: 68px !important;
    max-width: 68px !important;
    font-size: .72rem !important;
    white-space: normal !important;
  }

  .fc .fc-list-event-title {
    font-size: .82rem !important;
    line-height: 1.25 !important;
  }

  .fc .fc-list-event td {
    padding: 9px 6px !important;
  }

  .fc .fc-daygrid-day-frame {
    min-height: 78px !important;
  }

  .fc .fc-daygrid-day-number,
  .fc .fc-col-header-cell-cushion {
    font-size: .72rem !important;
    padding: 3px !important;
  }

  .fc .fc-daygrid-event {
    font-size: .66rem !important;
    padding: 2px 3px !important;
    margin-top: 1px !important;
  }
}

@media (max-width: 520px) {
  .topbar-left .fw-bold.fs-5 {
    font-size: .98rem !important;
  }

  .topbar-app-icon {
    width: 38px !important;
    height: 38px !important;
    font-size: 1rem !important;
  }

  .topbar-center {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  .top-pill {
    height: 42px !important;
    padding: 0 4px !important;
  }

  .top-pill span {
    display: none !important;
  }

  .profile-chip {
    max-width: calc(100vw - 86px) !important;
  }

  .profile-text strong {
    max-width: 155px !important;
  }

  .planning-calendar-card {
    padding: 8px !important;
    border-radius: 16px !important;
  }

  .fc .fc-toolbar-chunk {
    gap: 4px !important;
  }

  .fc .fc-button {
    font-size: .68rem !important;
    padding: 6px 7px !important;
    min-width: 34px !important;
  }

  .fc .fc-toolbar-title {
    font-size: .94rem !important;
  }
}
