/* Fix mobile scrolling issues */
html, body {
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Main widget container */
#circle-events-widget {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  max-width: 800px;
  margin: 0 auto;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #f0f0f0;
  position: relative;
}

/* Widget header */
#circle-events-widget h2 {
  margin: 0;
  padding: 32px 32px;
  background: #2c3e50;
  color: white;
  font-size: 1.4rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: -0.3px;
  position: relative;
}

/* Events container */
.events-container {
  padding: 0;
  max-height: 700px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

/* Month header */
.month-header {
  background: #f8f9fa;
  border-bottom: 2px solid #2c3e50;
  padding: 20px 32px;
  margin-bottom: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.month-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: -0.5px;
}

.month-events-count {
  background: #2c3e50;
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Month navigation */
.month-navigation {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.nav-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 12px;
  text-align: center;
}

.nav-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.nav-button {
  background: #2c3e50;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(44, 62, 80, 0.15);
}

.nav-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(44, 62, 80, 0.25);
  background: #34495e;
}

.nav-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
}

/* Month container */
.month-container {
  background: #ffffff;
  margin-bottom: 24px;
}

/* Individual event item */
.event-item {
  border-bottom: 1px solid #f0f2f5;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 20px 32px;
}

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

.event-item:hover {
  background: #f9fafb;
  transform: none;
}

/* Event date block - calendar style */
.event-date-block {
  flex-shrink: 0;
  width: 70px;
  height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-right: 20px;
  padding: 8px;
  background: #2c3e50;
  border-radius: 12px;
  color: white;
  box-shadow: 0 3px 10px rgba(44, 62, 80, 0.2);
}

.calendar-day {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 2px;
}

.calendar-weekday {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

/* Event cover image - positioned after content */
.event-cover-image {
  flex-shrink: 0;
  width: 180px;
  height: calc(180px * 366 / 1024); /* Correct aspect ratio: ~64px height */
  overflow: hidden;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  margin-left: 20px;
  align-self: center;
}

.event-cover-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  border-radius: 8px;
}

.event-item:hover .event-cover-image img {
  transform: scale(1.02);
}

/* Event content section */
.event-content {
  flex: 1;
  min-width: 0;
  padding: 0;
}

/* Event main info container */
.event-main-info {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Event details section */
.event-details {
  flex: 1;
  min-width: 0;
}

.event-title {
  font-weight: 700;
  margin-bottom: 8px;
  color: #2c3e50;
  font-size: 1.1rem;
  line-height: 1.3;
}

/* Event meta information */
.event-meta {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 6px;
}

.event-datetime {
  display: flex;
  align-items: center;
}

.event-time {
  font-size: 0.875rem;
  color: #2c3e50;
  font-weight: 600;
  background: #ecf0f1;
  padding: 4px 8px;
  border-radius: 6px;
}

.event-host {
  font-size: 0.875rem;
  color: #374151;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.event-host::before {
  content: "👤";
  font-size: 0.75rem;
}

.event-description {
  font-size: 0.85rem;
  color: #5a6c7d;
  margin-top: 8px;
  line-height: 1.5;
  background: #f8f9fa;
  padding: 12px 14px;
  border-radius: 8px;
  border-left: 3px solid #2c3e50;
}

.event-location {
  font-size: 0.85rem;
  color: #27ae60;
  font-weight: 600;
  display: inline-block;
  background: #e8f5e8;
  padding: 4px 8px;
  border-radius: 12px;
}

/* Loading state */
.loading {
  text-align: center;
  padding: 40px 20px;
  color: #2c3e50;
  font-weight: 500;
  font-size: 1rem;
}

/* No events state */
.no-events {
  text-align: center;
  padding: 40px 20px;
  color: #7f8c8d;
  font-style: italic;
  font-size: 0.95rem;
}

/* Error state */
.error {
  color: #e74c3c;
  padding: 20px;
  text-align: center;
  background: #fdf2f2;
  border: 1px solid #fecaca;
  margin: 16px;
  border-radius: 8px;
  font-weight: 500;
}

/* Add subtle animation for loading */
.loading::after {
  content: '...';
  animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* Medium screen adjustments */
@media (max-width: 900px) and (min-width: 481px) {
  .event-cover-image {
    width: 120px !important;
    height: calc(120px * 366 / 1024) !important;
    margin-left: 15px !important;
  }
}

/* Responsive design */
@media (max-width: 480px) {
  /* Additional mobile scroll fixes */
  html, body {
    position: relative;
    height: 100%;
    touch-action: pan-y;
  }
  
  #circle-events-widget {
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    min-height: 100vh;
    position: relative;
    touch-action: pan-y;
  }
  
  .events-container {
    max-height: none;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
  }
  
  .month-header {
    padding: 12px 20px;
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
  
  .month-title {
    font-size: 1.2rem;
  }
  
  .month-navigation {
    margin: 0 -20px 24px -20px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  
  .nav-title {
    font-size: 0.8rem;
  }
  
  .nav-button {
    font-size: 0.8rem;
    padding: 6px 12px;
  }
  
  .event-item {
    padding: 16px 20px;
    flex-direction: column;
    align-items: stretch;
  }
  
  .event-cover-image {
    width: 100%;
    max-width: 300px;
    height: calc(300px * 366 / 1024);
    margin: 0 auto 16px auto;
    border-radius: 12px;
    order: 1;
  }
  
  .event-content {
    width: 100%;
    order: 2;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 16px;
  }
  
  .event-main-info {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start;
    gap: 16px;
    text-align: left;
    justify-content: flex-start;
    width: 100%;
  }
  
  .event-date-block {
    width: 70px;
    height: 70px;
    margin: 0;
    flex-shrink: 0;
    order: 1;
  }
  
  .calendar-day {
    font-size: 1.6rem;
  }
  
  .calendar-weekday {
    font-size: 0.7rem;
  }
  
  .event-details {
    flex: 1;
    min-width: 0;
    display: flex !important;
    flex-direction: column;
    order: 2;
  }
  
  .event-title {
    font-size: 1.1rem;
    margin-bottom: 8px;
  }
  
  .event-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  
  .event-datetime,
  .event-host,
  .event-location {
    margin: 0;
  }
}

/* Custom scrollbar */
.events-container::-webkit-scrollbar {
  width: 6px;
}

.events-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.events-container::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 10px;
}

.events-container::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}
