/* Portal Events Calendar Styles */

/* Override for portal context */
.portal-calendar {
  padding: 30px 0;
  background: #ECF3F0;
}

.portal-calendar .calendar-layout {
  grid-template-columns: 1fr 320px;
}

/* Calendar Navigation */
.calendar-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--gold);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: #f3f4f6;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--dark-green);
  text-decoration: none;
}

.btn-icon:hover {
  background: var(--dark-green);
  color: white;
}

.current-period {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--dark-green);
  font-family: 'Stoke', serif;
}

.view-selector {
  display: flex;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 4px;
}

.view-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  text-decoration: none;
  color: #374151;
  font-size: 0.9rem;
}

.view-btn:hover {
  background: #e5e7eb;
}

.view-btn.active {
  background: var(--dark-green);
  color: white;
}

.btn-secondary {
  padding: 8px 16px;
  border: 1px solid var(--dark-green);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
  color: var(--dark-green);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--dark-green);
  color: white;
}

/* Month View Large */
.month-view-large {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.month-header-large {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--dark-green);
}

.month-header-large .day-header {
  padding: 12px;
  text-align: center;
  font-weight: 600;
  color: white;
  font-size: 0.9rem;
}

.month-grid-large {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.day-cell {
  min-height: 100px;
  border-right: 1px solid #eee;
  border-bottom: 1px solid #eee;
  padding: 8px;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  flex-direction: column;
}

.day-cell:nth-child(7n) {
  border-right: none;
}

.day-cell:hover {
  background-color: #f8fafc;
}

.day-cell.empty {
  background-color: #fafafa;
  cursor: default;
}

.day-cell.today {
  background-color: #f0f7f1;
}

.day-cell.today .day-number {
  background: var(--dark-green);
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-cell.has-event {
  background-color: #fffbeb;
}

.day-number {
  font-weight: 600;
  font-size: 0.9rem;
  color: #374151;
  margin-bottom: 6px;
}

.day-events {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}

.event-pill {
  font-size: 0.7rem;
  padding: 3px 6px;
  border-radius: 4px;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--dark-green);
  cursor: pointer;
  transition: opacity 0.2s;
}

.event-pill:hover {
  opacity: 0.85;
}

/* Event Modal */
.event-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

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

.event-modal {
  background: white;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  transform: scale(0.9);
  transition: transform 0.2s;
}

.event-modal-overlay.active .event-modal {
  transform: scale(1);
}

.event-modal-header {
  padding: 20px 20px 15px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
}

.event-modal-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--dark-green);
  margin: 0;
}

.event-modal-category {
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: 12px;
  color: white;
  white-space: nowrap;
}

.event-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #999;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.event-modal-close:hover {
  color: #333;
}

.event-modal-body {
  padding: 20px;
}

.event-modal-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.event-modal-row:last-child {
  margin-bottom: 0;
}

.event-modal-row i {
  color: var(--dark-green);
  width: 18px;
  text-align: center;
  margin-top: 2px;
}

.event-modal-row span {
  color: #374151;
  font-size: 0.95rem;
}

.event-modal-description {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #eee;
  color: #555;
  font-size: 0.95rem;
  line-height: 1.5;
}

.event-pill.school { background: var(--dark-green); }
.event-pill.holiday { background: var(--gold); color: var(--dark-green); }
.event-pill.sports { background: #3b82f6; }
.event-pill.other { background: #6b7280; }
.event-pill.general { background: var(--dark-green); }

.more-events {
  font-size: 0.7rem;
  color: #6b7280;
  padding: 2px 0;
}

/* Year View */
.year-view {
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}

.year-view .calendar-month {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.year-view .month-header {
  padding: 8px;
  font-size: 0.85rem;
  display: block;
}

.year-view .month-grid {
  grid-template-columns: repeat(5, 1fr);
  padding: 6px;
  gap: 1px;
}

.year-view .day-header {
  font-size: 0.65rem;
  padding: 2px 0;
}

.year-view .day {
  font-size: 0.75rem;
  padding: 4px 2px;
  cursor: pointer;
}

.year-view .day.has-event {
  background: var(--gold);
  color: var(--dark-green);
  font-weight: 600;
  border-radius: 3px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.year-view .day.has-event:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 10;
  position: relative;
}

.year-view .day.today {
  background: var(--dark-green);
  color: white;
  border-radius: 3px;
}

/* Sidebar Overrides for Portal */
.portal-calendar .dates-sidebar {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.portal-calendar .sidebar-header h2 {
  font-size: 1.3rem;
}

/* Event item styling */
.date-item.school .date-marker { background: var(--dark-green); }
.date-item.holiday .date-marker { background: var(--gold); }
.date-item.sports .date-marker { background: #3b82f6; }
.date-item.other .date-marker { background: #6b7280; }
.date-item.general .date-marker { background: var(--dark-green); }

.date-time {
  font-size: 0.85rem;
  color: #888;
}

.date-location {
  font-size: 0.85rem;
  color: #888;
  margin-top: 4px;
}

.date-location i {
  margin-right: 4px;
  color: var(--dark-green);
}

/* Clickable sidebar events */
.clickable-event {
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
  border-radius: 8px;
  margin: 0 -10px;
  padding: 15px 10px !important;
}

.clickable-event:hover {
  background-color: #f0f7f1;
  transform: translateX(3px);
}

/* Legend colors */
.legend-dot.school { background: var(--dark-green); }
.legend-dot.holiday { background: var(--gold); }
.legend-dot.sports { background: #3b82f6; }
.legend-dot.other { background: #6b7280; }

/* Toggleable Legend Filter */
#legend-filter {
  background: white;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.legend-hint {
  font-size: 0.65rem;
  color: #999;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: 100%;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  margin: 0;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  background: transparent;
}

.legend-item:hover {
  background: rgba(33, 59, 45, 0.08);
}

.legend-item.active {
  background: rgba(33, 59, 45, 0.1);
}

.legend-item .legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.legend-item span:not(.legend-dot) {
  flex: 1;
  font-size: 0.75rem;
  color: #374151;
}

.legend-item:not(.active) {
  opacity: 0.5;
}

.legend-item:not(.active) .legend-dot {
  opacity: 0.4;
}

.legend-reset {
  padding: 6px 10px;
  background: #f3f4f6;
  border: none;
  border-radius: 6px;
  font-size: 0.7rem;
  color: var(--dark-green);
  cursor: pointer;
  transition: all 0.2s;
  margin-left: auto;
}

.legend-reset:hover {
  background: var(--dark-green);
  color: white;
}

.no-events {
  padding: 30px 20px;
  text-align: center;
  color: #888;
}

/* Responsive */
@media (max-width: 1200px) {
  .year-view {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1024px) {
  .portal-calendar .calendar-layout {
    grid-template-columns: 1fr;
  }

  .portal-calendar .dates-sidebar {
    order: -1;
    max-height: none;
  }

  .year-view {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .calendar-nav {
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
  }

  .nav-left, .nav-right {
    justify-content: center;
  }

  .day-cell {
    min-height: 60px;
    padding: 4px;
  }

  .day-events {
    display: none;
  }

  .day-cell.has-event::after {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--gold);
    border-radius: 50%;
    margin-top: auto;
    align-self: center;
  }

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

@media (max-width: 480px) {
  .view-selector {
    width: 100%;
    justify-content: center;
  }

  .view-btn {
    flex: 1;
    text-align: center;
  }

  .year-view {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  /* Override calendar.css column layout for legend filter */
  #legend-filter {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

/* List View */
.list-view-container {
  background: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.list-view-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--gold);
}

.export-buttons {
  display: flex;
  gap: 10px;
}

.export-buttons .btn-secondary i {
  margin-right: 6px;
}

.month-section {
  margin-bottom: 30px;
}

.month-section:last-child {
  margin-bottom: 0;
}

.month-label {
  font-family: 'Stoke', serif;
  color: var(--dark-green);
  font-size: 1.1rem;
  padding: 10px 15px;
  background: #f8fafc;
  border-left: 4px solid var(--gold);
  margin: 0 0 15px 0;
  font-weight: 600;
}

.events-list {
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
}

.event-row {
  display: grid;
  grid-template-columns: 20% 1fr auto;
  gap: 15px;
  padding: 12px 15px;
  border-bottom: 1px solid #eee;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s;
}

.event-row:last-child {
  border-bottom: none;
}

.event-row:hover {
  background: #f8fafc;
}

.event-date-col {
  font-weight: 600;
  color: var(--dark-green);
  font-size: 0.9rem;
  padding: 0 10px 0 20px;
}

.event-info {
  min-width: 0;
}

.event-info .event-title {
  font-weight: 500;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-meta {
  font-size: 0.85rem;
  color: #888;
  margin-top: 2px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.event-time-text {
  white-space: nowrap;
}

.event-location-text {
  white-space: nowrap;
}

.event-location-text i {
  margin-right: 4px;
  color: var(--dark-green);
}

.event-category-badge {
  padding: 2px 10px;
  border-radius: 25px;
  font-size: 0.75rem;
  color: white;
  white-space: nowrap;
  margin: 0 20px 0 0;
}

/* List View Responsive */
@media (max-width: 768px) {
  .list-view-header {
    justify-content: center;
  }

  .event-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .event-date-col {
    font-size: 0.85rem;
  }

  .event-category-badge {
    justify-self: start;
  }
}

@media (max-width: 480px) {
  .export-buttons {
    flex-direction: column;
    width: 100%;
  }

  .export-buttons .btn-secondary {
    width: 100%;
    text-align: center;
  }
}
