/* ==========================================================================
   FullCalendar v6 Theme — NM-ERP Design System Integration
   Maps FullCalendar CSS custom properties to design-system.css tokens.
   ========================================================================== */

/* --- FullCalendar variable overrides --- */
:root {
  --fc-border-color: var(--border);
  --fc-button-bg-color: var(--surface);
  --fc-button-border-color: var(--border-strong);
  --fc-button-text-color: var(--text-secondary);
  --fc-button-hover-bg-color: #f1f5f9;
  --fc-button-active-bg-color: var(--primary-light);
  --fc-button-active-border-color: var(--primary);
  --fc-button-active-text-color: var(--primary-dark);
  --fc-today-bg-color: #eff6ff;
  --fc-event-text-color: #ffffff;
  --fc-page-bg-color: var(--surface);
  --fc-neutral-bg-color: var(--content-bg);
}

/* --- FullCalendar prev/next arrow icons --- */
.fc .fc-prev-button,
.fc .fc-next-button {
  font-size: 0;
  min-width: 32px;
  padding: 4px 8px;
}
.fc .fc-prev-button::after {
  content: '\2039';
  font-size: 18px;
  line-height: 1;
}
.fc .fc-next-button::after {
  content: '\203A';
  font-size: 18px;
  line-height: 1;
}
.fc .fc-prev-button .fc-icon,
.fc .fc-next-button .fc-icon {
  display: none;
}

/* --- Calendar layout --- */
.cal-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.cal-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.cal-main {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

/* --- Month view: single-line event strips --- */
.fc-event-month {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 4px;
  border-radius: 3px;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  line-height: 1.4;
}

/* --- Week view: multi-line event blocks --- */
.fc-event-week {
  padding: 4px 6px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.4;
}

.fc-event-week .fc-ev-project {
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fc-event-week .fc-ev-type {
  color: rgba(255, 255, 255, 0.85);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fc-event-week .fc-ev-installers {
  color: rgba(255, 255, 255, 0.7);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Week view: ensure day cells stretch to fill calendar height --- */
.fc-dayGridWeek-view .fc-daygrid-day-frame {
  min-height: 100%;
}

/* --- Day cell overflow for month view only --- */
#calLayout .fc-dayGridMonth-view .fc-daygrid-day-events {
  max-height: 120px;
  overflow-y: auto;
}

/* --- Activity popover --- */
.activity-popover {
  position: fixed;
  z-index: 201;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 12px 16px;
  min-width: 240px;
  max-width: 320px;
}

.activity-popover .popover-heading {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 8px 0;
  padding-right: 20px;
}

.activity-popover .popover-row {
  margin-bottom: 4px;
  font-size: 13px;
  line-height: 1.5;
}

.activity-popover .popover-label {
  color: var(--text-muted);
  font-size: 11px;
  margin-right: 4px;
}

.activity-popover .popover-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.activity-popover .popover-close:hover {
  color: var(--text-primary);
}

.activity-popover .popover-actions {
  margin-top: 10px;
}

/* --- Sidebar filter heading --- */
.cal-filter-heading {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin: 16px 0 8px 0;
}

/* --- Sidebar type filter items --- */
.cal-type-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  padding: 3px 0;
}

.cal-type-item input[type="checkbox"] {
  margin: 0;
}

.cal-type-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
  display: inline-block;
}

/* --- Mini-calendar compact --- */
.mini-cal .flatpickr-calendar {
  position: static !important;
  box-shadow: none;
  border: none;
  width: 100%;
}

/* Flatpickr inline wrapper — keep it in flow */
.mini-cal .flatpickr-wrapper {
  display: block;
  width: 100%;
}

/* --- View toggle --- */
.view-toggle {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.view-toggle .btn-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
}

.view-toggle .btn-icon:hover {
  background: #f1f5f9;
}

.view-toggle .btn-icon[aria-pressed="true"] {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* --- Responsive: hide sidebar below 768px --- */
@media (max-width: 767px) {
  .cal-sidebar {
    display: none;
  }

  .cal-layout {
    display: block;
  }
}
