* {
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  color: #333;
}

.main-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2px;
  min-height: 100vh;
}

.header {
  text-align: center;
  margin-bottom: 3px;
  color: rgb(41, 14, 14);
}

.header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 10px 0;
}

.header p {
  font-size: 1.1rem;
  opacity: 0.9;
  margin: 0;
}

.calendar-controls {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 20px;
}

.legend-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.25rem;
  margin-bottom: 1.25rem;
}

.legend-inline {
  width: 100%;
  justify-content: center;
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
}

.legend-item {
  --legend-bg: #f3f4f6;
  --legend-border: #d1d5db;
  --legend-text: #1f2937;
  --legend-accent: #374151;
  --legend-active-bg: var(--legend-bg);
  --legend-hover-bg: var(--legend-active-bg);
  --legend-focus: rgba(79, 70, 229, 0.35);

  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg);
  color: var(--legend-text);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
  box-shadow: none;
 }

.legend-check {
  display: inline-block;
  margin-left: 6px;
  vertical-align: middle;
}

.legend-check-icon {
  color: #22c55e;
  font-size: 1.1em;
  font-weight: bold;
  margin-left: 2px;
  transition: opacity 0.2s;
}

.legend-item:hover {
  background: var(--legend-hover-bg);
  border-color: var(--legend-accent);
}

.legend-item.active {
  background: var(--legend-active-bg);
  border-color: var(--legend-accent);
  color: var(--legend-text);
  font-weight: 600;
}

.legend-item:focus-visible {
  outline: 2px solid var(--legend-focus);
  outline-offset: 2px;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  background: var(--legend-accent);
}

.legend-color--all {
  background: var(--legend-accent, #4b5563);
}

.legend-item--all {
  --legend-bg: #f5f5f5;
  --legend-border: #d1d5db;
  --legend-text: #374151;
  --legend-accent: #4b5563;
  --legend-active-bg: #e5e7eb;
  --legend-hover-bg: #e5e7eb;
  --legend-focus: rgba(75, 85, 99, 0.45);
}

.legend-item.event-school-period {
  --legend-bg: #e0f2fe;
  --legend-border: #bfdbfe;
  --legend-text: #1d4ed8;
  --legend-accent: #2563eb;
  --legend-active-bg: #bfdbfe;
  --legend-hover-bg: #dbeafe;
  --legend-focus: rgba(37, 99, 235, 0.35);
}

.legend-item.event-holiday {
  --legend-bg: #fee2e2;
  --legend-border: #fecaca;
  --legend-text: #b91c1c;
  --legend-accent: #dc2626;
  --legend-active-bg: #fecaca;
  --legend-hover-bg: #fee2e2;
  --legend-focus: rgba(220, 38, 38, 0.35);
}

.legend-item.event-special {
  --legend-bg: #fef3c7;
  --legend-border: #fde68a;
  --legend-text: #b45309;
  --legend-accent: #d97706;
  --legend-active-bg: #fde68a;
  --legend-hover-bg: #fef3c7;
  --legend-focus: rgba(217, 119, 6, 0.35);
}

.legend-item.event-public-holiday {
  --legend-bg: #ede9fe;
  --legend-border: #ddd6fe;
  --legend-text: #6d28d9;
  --legend-accent: #7c3aed;
  --legend-active-bg: #ddd6fe;
  --legend-hover-bg: #ede9fe;
  --legend-focus: rgba(124, 58, 237, 0.35);
}

.legend-item.event-other {
  --legend-bg: #dcfce7;
  --legend-border: #bbf7d0;
  --legend-text: #047857;
  --legend-accent: #10b981;
  --legend-active-bg: #bbf7d0;
  --legend-hover-bg: #dcfce7;
  --legend-focus: rgba(16, 185, 129, 0.35);
}

.calendar-wrapper {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(15px);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
}

.calendar-wrapper::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

@media (min-width: 1024px) {
  .calendar-controls {
    background: transparent;
    backdrop-filter: none;
    border-radius: 0;
    box-shadow: none;
    border: 0;
    padding: 0;
    gap: 1.25rem;
  }

  .calendar-wrapper {
    background: transparent;
    backdrop-filter: none;
    border-radius: 0;
    border: 0;
  }

  .calendar-wrapper::before {
    content: none;
  }
}

#calendar {
  min-height: 180px;
  border-radius: 6px;
  overflow: hidden;
}

/* FullCalendar Customizations */
.fc {
  font-family: inherit;
}

.fc-toolbar {
  margin-bottom: 20px !important;
}

.fc-header-toolbar {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
  flex-wrap: wrap;
}

.fc-header-toolbar .fc-toolbar-chunk {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fc-header-toolbar .fc-toolbar-chunk:first-child {
  flex: 1 1 auto;
  justify-content: center;
}

.fc-header-toolbar .fc-toolbar-chunk:first-child .fc-button-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fc-header-toolbar .fc-toolbar-chunk:first-child .fc-toolbar-title {
  font-size: 1.4rem !important;
  font-weight: 700 !important;
  margin: 0 8px;
  min-width: 110px;
  text-align: center;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.fc-header-toolbar .fc-toolbar-chunk:first-child .fc-toolbar-title .fc-toolbar-title-line--month {
  font-size: 1.4rem !important;
}

.fc-header-toolbar .fc-toolbar-chunk:first-child .fc-toolbar-title .fc-toolbar-title-line--year {
  font-size: 0.9rem !important;
  font-weight: 600 !important;
}

.fc-header-toolbar .fc-toolbar-chunk:first-child .fc-button {
  border-radius: 9999px !important;
  padding: 8px 12px !important;
}

.fc-header-toolbar .fc-toolbar-chunk:last-child .fc-button-group {
  display: inline-flex;
  border: 1px solid #4f46e5;
  border-radius: 9999px;
  overflow: hidden;
  padding: 2px;
  background: #fff;
  gap: 0;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.fc-header-toolbar .fc-toolbar-chunk:last-child .fc-button-group .fc-button {
  background: transparent !important;
  color: #4f46e5 !important;
  box-shadow: none !important;
  margin: 0 !important;
  border-radius: 9999px !important;
  padding: 6px 16px !important;
  font-weight: 600 !important;
}

.fc-header-toolbar .fc-toolbar-chunk:last-child .fc-button-group .fc-button:hover {
  background: rgba(79, 70, 229, 0.08) !important;
  transform: none !important;
}

.fc-header-toolbar .fc-toolbar-chunk:last-child .fc-button-group .fc-button.fc-button-active {
  background: #4f46e5 !important;
  color: #fff !important;
}

.fc .fc-multimonth td[data-date] {
  position: relative;
  transition: background 0.2s ease;
}

.fc .fc-multimonth td[data-date].year-cell-painted {
  background: var(--year-cell-bg, rgba(79, 70, 229, 0.1)) !important;
  box-shadow: inset 0 0 0 2px
    var(--year-cell-border, rgba(79, 70, 229, 0.35));
  border-radius: 8px;
}

.fc .fc-multimonth td[data-date].year-cell-painted::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--year-cell-dot, rgba(79, 70, 229, 0.65));
}

.fc-toolbar-title {
  font-size: 1.2rem !important;
  font-weight: 700 !important;
  color: #1f2937 !important;
}

.fc-button {
  background: #6e68d8 !important;
  border: none !important;
  border-radius: 10px !important;
  padding: 2px 6px !important;
  font-weight: 600 !important;
  transition: all 0.3s ease !important;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3) !important;
}

.fc-button:hover:not(:disabled) {
  background: #3730a3 !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4) !important;
}

.fc-button-primary:not(:disabled).fc-button-active {
  background: #1e1b4b !important;
}

.fc-daygrid-day {
  min-width: 100px !important;
}

.fc-daygrid-day-number {
  color: #4f46e5 !important;
  font-weight: 600 !important;
  font-size: 1rem !important;
}

.fc-col-header-cell {
  background: rgba(79, 70, 229, 0.05) !important;
  font-weight: 700 !important;
  color: #374151 !important;
}

.fc-daygrid-day.fc-day-today {
  background: rgba(79, 70, 229, 0.1) !important;
}

.fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
  background: #4f46e5 !important;
  color: white !important;
  border-radius: 50% !important;
  width: 28px !important;
  height: 28px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.fc-event {
  border: none !important;
  border-radius: 8px !important;
  padding: 4px 8px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.fc-event:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.fc-event-title {
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.fc-more-link {
  background: #6366f1 !important;
  color: white !important;
  border-radius: 15px !important;
  padding: 4px 12px !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  border: none !important;
  transition: all 0.2s ease !important;
}

.fc-more-link:hover {
  background: #4f46e5 !important;
  transform: scale(1.05) !important;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  z-index: 5000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.calendar-event-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: white;
  border-radius: 20px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease;
}

.modal-overlay.show .calendar-event-modal {
  transform: translate(-50%, -50%) scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e5e7eb;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  flex: 1;
  padding-right: 15px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #6b7280;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: #f3f4f6;
  color: #374151;
  transform: scale(1.1);
}

.modal-info {
  display: grid;
  gap: 15px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 10px;
  border-left: 4px solid #4f46e5;
}

.info-icon {
  color: #4f46e5;
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.info-content {
  flex: 1;
}

.info-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.info-value {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
}

/* Popover Styles */
.fc-popover {
  display: none !important;
  border: none !important;
  border-radius: 15px !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2) !important;
  backdrop-filter: blur(10px) !important;
  background: rgba(255, 255, 255, 0.98) !important;
  z-index: 9999 !important;
}

.fc-popover-header {
  background: linear-gradient(135deg, #4f46e5, #7c3aed) !important;
  color: white !important;
  border-radius: 15px 15px 0 0 !important;
  padding: 15px !important;
  font-weight: 700 !important;
}

.fc-popover .fc-popover- event-title {
  color: #1f2937 !important;
  font-size: 0.9rem !important;
  font-weight: 600 !important;
  white-space: normal !important;
}

.popover-backdrop {
  backdrop-filter: blur(3px) !important;
  z-index: 9998;
}

/* Loading State */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: #6b7280;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e5e7eb;
  border-top: 4px solid #4f46e5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Medium screen adjustments for 14-inch laptops */
@media (max-width: 1600px) {
  .main-container {
    max-width: 1100px;
    padding: 10px;
  }

  .header h2 {
    font-size: 1.6rem;
    margin-bottom: 6px;
  }

  .header p {
    font-size: 1rem;
  }

  .calendar-wrapper {
    padding: 15px;
    border-radius: 14px;
  }

  #calendar {
    min-height: 400px;
    border-radius: 10px;
  }

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

  .fc-button {
    padding: 6px 10px !important;
    font-size: 0.7rem !important;
  }

  .legend-item {
    font-size: 0.8rem;
    padding: 4px 10px;
  }

  .view-btn {
    padding: 8px 14px;
    font-size: 0.9rem;
  }
}

/* You can further tweak for 1366px screens (common 14" resolution) */
@media (max-width: 1400px) {
  .main-container {
    max-width: 900px;
    padding: 5px;
  }

  .header h2 {
    font-size: 1rem;
    margin-bottom: 4px;
  }

  .header p {
    font-size: 0.95rem;
  }

  #calendar {
    min-height: 260px;
  }

  .calendar-wrapper {
    padding: 4px;
  }

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

/* Responsive Design */
@media (max-width: 770px) {
  .main-container {
    padding: 15px;
  }

  .header h2 {
    font-size: 1rem;
  }

  .header p {
    font-size: 0.9rem;
  }

  .calendar-controls {
    padding: 15px;
  }

  .legend-container {
    gap: 1px;
  }

  .legend-item {
    font-size: 0.7rem;
    padding: 6px 6px;
  }

  .calendar-wrapper {
    padding: 20px;
  }

  .fc-toolbar {
    flex-direction: column;
    gap: 10px;
  }

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

  .fc-button {
    padding: 6px 6px !important;
    font-size: 0.75rem !important;
  }

  .fc-event-title {
    color: red;
    font-size: 0.4rem !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .calendar-event-modal {
    padding: 20px;
    width: 95%;
  }

  .modal-title {
    font-size: 1.25rem;
  }
}

@media (max-width: 600px) {

  .legend-container {
    display: none !important;
  }

  .fc .fc-multimonth .fc-event-title,
  .fc .fc-multimonth .fc-event .fc-event-title,
  .fc .fc-multimonth .fc-event .fc-event-title-container,
  .fc .fc-multimonth .fc-event .fc-list-event-title,
  .fc .fc-multimonth .fc-event .fc-list-event-title>a,
  .fc .fc-multimonth .fc-event .fc-event-time,
  .fc .fc-multimonth .fc-event .fc-event-main,
  .fc .fc-multimonth .fc-event strong,
  .fc .fc-multimonth .fc-event span,
  .fc .fc-multimonth .fc-event div {
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
  }

  .fc .fc-multimonth .fc-daygrid-event-harness,
  .fc .fc-multimonth .fc-daygrid-event-harness>a {
    max-height: none !important;
    line-height: 1.3 !important;
  }

  .fc .fc-multimonth .fc-daygrid-event {
    display: block !important;
    width: 100% !important;
    margin: 2px 0 !important;
    border-radius: 8px !important;
    padding: 0 !important;
    min-height: 28px;
    overflow: hidden;
  }

  .fc .fc-multimonth .event-chip {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    padding: 0;
    display: flex;
    align-items: stretch;
  }

  .fc .fc-multimonth .event-chip-label {
    display: none;
  }

  .fc .fc-multimonth .fc-daygrid-more-link {
    display: none !important;
  }

  .year-view-month-legend {
    margin: 8px 0 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.65rem;
    color: #1f2937;
    width: 100%;
  }

  .year-view-month-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(31, 41, 55, 0.1);
  }

  .year-view-month-legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
  }

  .fc-legend-container {
    gap: 1px;
  }

  .fc-legend-item {
    font-size: 0.7rem;
  }

  .fc-button {
    padding: 4px 4px !important;
    font-size: 0.75rem !important;
  }
}

/* Custom fix for consistent event height in multiMonthYear view */
.fc-multimonth-day .fc-daygrid-event-harness,
.fc-multimonth-day .fc-daygrid-event-harness>a {
  max-height: 30px !important;
  line-height: 30px !important;
  overflow: hidden;
}

/* Ensure event content in multiMonthYear is minimal on all sizes */
.fc-multimonth-day .fc-event-main-frame,
.fc-multimonth-day .fc-event-title-container {
  padding: 0;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles */
.legend-item:focus,
.view-btn:focus,
.fc-button:focus,
.close-btn:focus {
  outline: 2px solid #4f46e5 !important;
  outline-offset: 2px !important;
}

/* Enhanced event styling based on type */
.event-school-period {
  background: linear-gradient(135deg, #f6faff, #d7eaff) !important;
  border-color: #adcdffff !important;
}

.event-holiday {
  background: linear-gradient(135deg, #fff3f3, #fad6d6) !important;
  border-color: #f36666 !important;
}

.event-special {
  background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
  border-color: #fbbf24 !important;
}

.event-public-holiday {
  background: linear-gradient(135deg, #f3e8ff, #e9d5ff) !important;
  border-color: #a78bfa !important;
}

.event-other {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7) !important;
  border-color: #34d399 !important;
}

.fc-popover .fc-event,
.fc-popover .event-holiday,
.fc-popover .event-school-period,
.fc-popover .event-special,
.fc-popover .event-public-holiday,
.fc-popover .event-other {
  border-left: none !important;
}

.fc-popover .fc-event::before,
.fc-popover .event-holiday::before,
.fc-popover .event-school-period::before,
.fc-popover .event-special::before,
.fc-popover .event-public-holiday::before,
.fc-popover .event-other::before {
  display: none !important;
  content: none !important;
}

.fc-header-toolbar .fc-button-group > .fc-button {
  margin-right: 8px;
}
.fc-header-toolbar .fc-button-group > .fc-button:last-child {
  margin-right: 0;
}
