/* ================================================
   Modern Calendar Design - AJAX Version
   ================================================ */

/* Calendar Container */
.calendar-wrapper {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  margin: 20px auto;
  max-width: 1200px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Calendar Title */
.calendar-title {
  text-align: center;
  margin-bottom: 30px;
}

.calendar-title h2 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
  color: #1e293b;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.calendar-title h2::before {
  content: "";
  width: 4px;
  height: 30px;
  background: linear-gradient(180deg, #0066cc 0%, #4cc9f0 100%);
  border-radius: 2px;
}

.calendar-title h2 i {
  color: #0066cc;
  font-size: 0.9em;
}

/* ================================================
   Navigation - Redesigned
   ================================================ */
.nav-calendrier {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.cal-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: white;
  color: #475569;
  text-decoration: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  font-family: inherit;
}

.cal-nav-btn:hover:not(:disabled) {
  background: #0066cc;
  color: white;
  border-color: #0066cc;
  box-shadow: 0 8px 20px rgba(0, 102, 204, 0.2);
}

.cal-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cal-today-btn {
  background: linear-gradient(135deg, #0066cc, #0052a3);
  color: white;
  border-color: #0066cc;
}

.cal-today-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #004080, #003366);
  border-color: #004080;
}

.cal-current-month {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 180px;
}

.cal-month-text {
  font-size: 1.8rem;
  font-weight: 700;
  color: #0066cc;
  line-height: 1.2;
  text-transform: capitalize;
}

.cal-year-text {
  font-size: 0.9rem;
  color: #94a3b8;
  font-weight: 500;
}

/* ================================================
   Grid Wrapper & Loading
   ================================================ */
.cal-grid-wrapper {
  position: relative;
  min-height: 400px;
  overflow: hidden;
}

.cal-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(248, 250, 252, 0.85);
  backdrop-filter: blur(4px);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  border-radius: 16px;
}

.cal-loading.visible {
  opacity: 1;
  pointer-events: auto;
}

.cal-loading span {
  font-size: 0.9rem;
  color: #64748b;
  font-weight: 500;
}

.cal-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e2e8f0;
  border-top-color: #0066cc;
  border-radius: 50%;
  animation: calSpin 0.7s linear infinite;
}

@keyframes calSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ================================================
   Calendar Table
   ================================================ */
.cal-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 8px;
  background: transparent;
  margin-top: 0;
}

.cal-table th {
  background: linear-gradient(135deg, #0066cc 0%, #004080 100%);
  color: white;
  padding: 16px 10px;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
}

.cal-table td {
  background: white;
  border: 1px solid #e2e8f0;
  padding: 12px 10px;
  min-height: 130px;
  height: 130px;
  vertical-align: top;
  position: relative;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cal-table td:hover:not(.cal-empty) {
  border-color: #0066cc;
}

.cal-table td.cal-empty {
  background: #f8fafc;
  box-shadow: none;
  border-color: transparent;
}

.cal-table td.cal-empty:hover {
  transform: none;
  box-shadow: none;
}

/* Today Highlight */
.cal-table td.cal-today {
  border-color: #0066cc;
  box-shadow:
    0 0 0 2px rgba(0, 102, 204, 0.15),
    0 2px 8px rgba(0, 0, 0, 0.04);
}

.cal-table td.cal-today .day-number {
  background: linear-gradient(135deg, #0066cc 0%, #4cc9f0 100%);
  color: white;
}

/* Day Number */
.day-number {
  font-weight: 700;
  font-size: 1.1rem;
  color: #1e293b;
  margin-bottom: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

/* Events Container in cell */
.cal-events {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Events */
.event {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.4;
  font-weight: 500;
  position: relative;
  border-left: 3px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: opacity 0.15s ease;
}

.event:hover {
  opacity: 0.85;
}

/* Event Subscribed Indicator */
.event-sub-icon {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.65rem;
  opacity: 0.6;
}

.cal-event-subscribed {
  position: relative;
}

.cal-event-subscribed::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  background: #0066cc;
  border-radius: 50%;
}

/* Event Display */
.event-title {
  display: block;
  line-height: 1.3;
}

/* Event Club Name */
.event-club {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.7;
  font-style: italic;
  margin-top: 2px;
}

/* Campus Colors - Modern Palette */
.campus-calais {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%) !important;
  border-left-color: #dc3545 !important;
  color: #991b1b !important;
}

.campus-longuenesse {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%) !important;
  border-left-color: #0066cc !important;
  color: #1e40af !important;
}

.campus-boulogne {
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%) !important;
  border-left-color: #28a745 !important;
  color: #166534 !important;
}

.campus-dunkerque {
  background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%) !important;
  border-left-color: #eab308 !important;
  color: #854d0e !important;
}

/* ================================================
   Legend / Filters
   ================================================ */
.legend {
  margin-top: 30px;
  padding: 25px 30px;
  background: white;
  border-radius: 16px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: #f8fafc;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-weight: 500;
  font-size: 0.9rem;
  color: #475569;
}

.legend-item:hover {
  background: #e2e8f0;
}

.legend-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #0066cc;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid rgba(0, 0, 0, 0.1);
}

/* ================================================
   Event Detail Modal
   ================================================ */
.cal-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background 0.25s ease;
}

.cal-modal-overlay.visible {
  background: rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.cal-modal {
  background: white;
  border-radius: 16px;
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
  transform: translateY(30px) scale(0.95);
  opacity: 0;
  transition:
    transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.3s ease;
  padding: 28px;
}

.cal-modal-overlay.visible .cal-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.cal-modal-header {
  position: relative;
  margin-bottom: 24px;
}

.cal-modal-title {
  margin: 0 0 10px 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  line-height: 1.4;
  padding-right: 50px;
}

.cal-modal-campus {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cal-modal-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 20px;
}

.cal-modal-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.cal-modal-icon {
  width: 40px;
  height: 40px;
  background: #f0f9ff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #0284c7;
  font-size: 0.95rem;
}

.cal-modal-info {
  flex: 1;
}

.cal-modal-label {
  font-size: 0.7rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
  font-weight: 500;
}

.cal-modal-value {
  font-weight: 500;
  color: #111827;
  font-size: 0.95rem;
}

.cal-modal-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: #eff6ff;
  color: #0066cc;
  text-decoration: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  margin-bottom: 8px;
}

.cal-modal-link:hover {
  background: #dbeafe;
}

.cal-modal-close {
  width: 100%;
  padding: 12px 20px;
  background: #f3f4f6;
  color: #374151;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
  font-family: inherit;
}

.cal-modal-close:hover {
  background: #e5e7eb;
}

/* Subscription Buttons in Modal */
.cal-sub-btn,
.cal-sub-btn-active {
  position: absolute;
  top: 0;
  right: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.25s ease;
}

.cal-sub-btn {
  background: #eff6ff;
  color: #2563eb;
}

.cal-sub-btn:hover {
  background: #dbeafe;
  transform: scale(1.1);
}

.cal-sub-btn-active {
  background: #fef2f2;
  color: #dc2626;
}

.cal-sub-btn-active:hover {
  background: #fee2e2;
  transform: scale(1.1);
}

.cal-sub-loading {
  opacity: 0.5;
  pointer-events: none;
}

.cal-login-link {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 0.75rem;
  color: #64748b;
  text-decoration: none;
  transition: all 0.2s ease;
  font-weight: 500;
}

.cal-login-link:hover {
  background: #e2e8f0;
  color: #475569;
}

/* ================================================
   Reminders
   ================================================ */
.cal-reminders-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1500;
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  max-width: 360px;
}

.cal-reminder {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #f59e0b;
  padding: 16px 20px;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  animation: reminderSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.cal-reminder-exit {
  animation: reminderSlideOut 0.4s ease forwards;
}

.cal-reminder-icon {
  width: 36px;
  height: 36px;
  background: rgba(245, 158, 11, 0.15);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #d97706;
  font-size: 0.95rem;
}

.cal-reminder-text {
  flex: 1;
  font-size: 0.85rem;
  color: #78350f;
  line-height: 1.5;
}

.cal-reminder-text strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.9rem;
}

.cal-reminder-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: #b45309;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.cal-reminder-close:hover {
  opacity: 1;
}

@keyframes reminderSlideIn {
  from {
    opacity: 0;
    transform: translateX(80px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes reminderSlideOut {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(80px) scale(0.9);
  }
}

/* ================================================
   Toast Notifications
   ================================================ */
.cal-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}

.cal-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.cal-toast-success {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  color: #166534;
  border: 1px solid #22c55e;
}

.cal-toast-info {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #1e40af;
  border: 1px solid #3b82f6;
}

.cal-toast-error {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #991b1b;
  border: 1px solid #ef4444;
}

/* ================================================
   Error State
   ================================================ */
.cal-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
  text-align: center;
  color: #64748b;
}

.cal-error i {
  font-size: 2.5rem;
  color: #f59e0b;
}

.cal-error p {
  font-size: 1rem;
  margin: 0;
}

.cal-retry-btn {
  padding: 10px 24px;
  background: #0066cc;
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.cal-retry-btn:hover {
  background: #004080;
}

/* ================================================
   Responsive Design
   ================================================ */

@media (max-width: 992px) {
  .calendar-wrapper {
    padding: 20px;
    margin: 15px;
    border-radius: 16px;
  }

  .cal-table {
    border-spacing: 5px;
  }

  .cal-table th {
    padding: 12px 5px;
    font-size: 0.8rem;
  }

  .cal-table td {
    padding: 8px 5px;
    min-height: 100px;
    height: 100px;
  }

  .event {
    font-size: 0.75rem;
    padding: 6px 8px;
  }
}

@media (max-width: 768px) {
  .calendar-wrapper {
    padding: 15px;
    margin: 10px;
  }

  .calendar-title h2 {
    font-size: 1.4rem;
  }

  .nav-calendrier {
    gap: 10px;
  }

  .cal-nav-btn {
    padding: 10px 16px;
    font-size: 0.85rem;
  }

  .cal-month-text {
    font-size: 1.4rem;
  }

  .cal-current-month {
    min-width: 140px;
  }

  .cal-table {
    border-spacing: 3px;
  }

  .cal-table th {
    padding: 10px 3px;
    font-size: 0.7rem;
    letter-spacing: 0;
  }

  .cal-table td {
    padding: 5px;
    min-height: 80px;
    height: 80px;
    border-radius: 8px;
  }

  .day-number {
    font-size: 0.9rem;
    width: 26px;
    height: 26px;
  }

  .event {
    font-size: 0.7rem;
    padding: 4px 6px;
    margin: 2px 0;
  }

  .legend {
    padding: 15px;
    gap: 10px;
  }

  .legend-item {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .cal-modal {
    width: calc(100vw - 24px);
    padding: 20px;
  }

  .cal-reminders-stack {
    right: 12px;
    bottom: 12px;
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 480px) {
  .calendar-wrapper {
    padding: 10px;
    margin: 5px;
    border-radius: 12px;
  }

  .calendar-title h2 {
    font-size: 1.2rem;
  }

  .nav-calendrier {
    flex-direction: column;
    gap: 8px;
  }

  .cal-nav-btn {
    width: 100%;
    justify-content: center;
  }

  .cal-current-month {
    order: -1;
  }

  .cal-table th {
    padding: 8px 2px;
    font-size: 0.65rem;
  }

  .cal-table td {
    padding: 3px;
    min-height: 70px;
    height: 70px;
  }

  .day-number {
    font-size: 0.8rem;
    width: 22px;
    height: 22px;
  }

  .event {
    font-size: 0.65rem;
    padding: 3px 4px;
    border-left-width: 2px;
  }

  .event-sub-icon {
    display: none;
  }

  .legend-item span {
    display: none;
  }
}

/* Legacy wrapper compatibility */
.calendrier-wrapper {
  width: 90%;
  max-width: 1200px;
  background-color: white;
  padding: 30px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  margin: 20px auto;
}

.page-accueil {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 20px;
}
