/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #1e3a5f;
  --primary-hover: #2c5282;
  --online-color: #2563eb;
  --in-person-color: #16a34a;
  --text-dark: #1f2937;
  --text-light: #6b7280;
  --border-color: #e5e7eb;
  --bg-light: #f9fafb;
  --bg-white: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --gradient-hero: linear-gradient(135deg, hsl(250 84% 54%) 0%, hsl(280 84% 60%) 50%, hsl(320 70% 55%) 100%);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-dark);
  background-color: var(--bg-light);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.header {
  background-image: linear-gradient(to bottom right, #fafafa, #f5f5f5, #fafafa);
  color: var(--text-dark);
  padding: 48px 0;
  text-align: center;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  color: var(--text-dark);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.badge-icon {
  font-size: 16px;
}

.badge-text {
  font-weight: 500;
}

.main-title {
  font-size: 3.75rem;
  font-weight: 700;
  margin-bottom: 24px;
  line-height: 1.1;
  color: #000;
}

.main-title .highlight {
  background: var(--gradient-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1.25rem;
  line-height: 2rem;
  color: var(--text-light);
  max-width: 600px;
  margin: 0 auto;
}

/* Search Section */
.search-section {
  background: white;
  padding: 32px 16px 40px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.search-row {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}

.search-box {
  position: relative;
  flex: 1;
}

.search-box input {
  width: 100%;
  padding: 14px 16px 14px 48px;
  font-size: 16px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  transition: all 0.2s;
  background-color: white;
  height: 48px;
  box-sizing: border-box;
}

.search-box input:focus {
  outline: none;
  border-color: hsl(250 84% 54%);
  box-shadow: 0 0 0 3px hsla(250, 84%, 54%, 0.1);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 20px;
}

/* Quick Filters */
.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid var(--border-color);
  background: white;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-dark);
  white-space: nowrap;
}

.quick-filter-btn .btn-icon {
  font-size: 16px;
}

.quick-filter-btn:hover {
  border-color: hsl(250 84% 54%);
  color: hsl(250 84% 54%);
  background: #f5f3ff;
  transform: translateY(-1px);
}

.quick-filter-btn.active {
  background: var(--gradient-hero);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px hsla(250, 84%, 54%, 0.3);
}

.quick-filter-btn[data-filter="today"] {
  background: var(--gradient-hero);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px hsla(250, 84%, 54%, 0.3);
}

.quick-filter-btn[data-filter="today"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px hsla(250, 84%, 54%, 0.4);
}

/* Advanced Filters */
.filter-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-dark);
  transition: all 0.2s;
  white-space: nowrap;
  height: 48px;
}

.filter-toggle .filter-icon {
  font-size: 18px;
}

.filter-toggle:hover {
  border-color: hsl(250 84% 54%);
  background: #f5f3ff;
  color: hsl(250 84% 54%);
}

.advanced-filters {
  display: none;
  margin-top: 16px;
  padding: 24px;
  background: white;
  border-radius: 16px;
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

.advanced-filters.show {
  display: block;
}

.filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.filters-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-dark);
}

.filters-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.filters-close:hover {
  color: var(--text-dark);
}

.filter-section {
  margin-bottom: 24px;
}

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

.filter-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 12px;
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-buttons.scrollable {
  max-height: 200px;
  overflow-y: auto;
}

.filter-option-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-option-btn .btn-icon {
  font-size: 16px;
}

.filter-option-btn:hover {
  border-color: hsl(250 84% 54%);
  background: #f5f3ff;
  color: hsl(250 84% 54%);
}

.filter-option-btn.active {
  background: var(--gradient-hero);
  color: white;
  border-color: transparent;
}

/* Results Info */
.results-info {
  padding: 16px;
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  background: white;
}

.results-count {
  font-weight: 600;
  color: var(--primary-color);
}

/* Table Container */
.table-container {
  padding: 16px;
  background: white;
  margin: 0 auto;
  max-width: 100%;
}

.table-wrapper {
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

/* Events Table */
.events-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 14px;
}

.events-table thead {
  background: var(--bg-light);
  position: sticky;
  top: 0;
  z-index: 10;
}

.events-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-dark);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.events-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s;
}

.events-table tbody tr:hover {
  background: var(--bg-light);
}

.events-table td {
  padding: 12px 16px;
  vertical-align: top;
}

/* Event Name Column */
.event-name {
  font-weight: 500;
  color: var(--text-dark);
  min-width: 200px;
}

.event-name a {
  color: var(--primary-color);
  text-decoration: none;
}

.event-name a:hover {
  text-decoration: underline;
}

/* Type Badge */
.type-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-lg);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.type-badge.online {
  background-color: var(--online-color);
  color: white;
}

.type-badge.in-person {
  background-color: var(--in-person-color);
  color: white;
}

/* Library Column */
.library-name {
  color: var(--text-dark);
  min-width: 150px;
}

/* Date Column */
.event-date {
  color: var(--text-dark);
  white-space: nowrap;
  min-width: 180px;
}

/* Week Day Slots */
.week-slots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.week-slot {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background-color: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  transition: all 0.2s;
}

.week-slot.active {
  background-color: #16a34a;
  color: white;
}

.week-slot.compact {
  width: auto;
  padding: 4px 6px;
  font-size: 10px;
}

/* Responsive: adjust slot size on smaller screens */
@media (max-width: 1200px) {
  .week-slot {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }
}

@media (max-width: 768px) {
  .week-slot {
    width: 20px;
    height: 20px;
    font-size: 9px;
  }

  .week-slots {
    gap: 2px;
  }
}

/* Details Column */
.details-link {
  color: var(--primary-color);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 500;
}

.details-link:hover {
  text-decoration: underline;
}

/* Loading State */
.loading {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-light);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-light);
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 20px;
  color: var(--text-dark);
  margin-bottom: 8px;
}

/* Footer */
.footer {
  background: white;
  border-top: 1px solid var(--border-color);
  padding: 24px 16px;
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  margin-top: 32px;
}

/* Detail Page Styles */
.detail-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--primary-color);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 20px;
  padding: 8px 0;
}

.back-button:hover {
  text-decoration: underline;
}

.detail-card {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  padding: 24px;
}

.detail-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 16px;
  line-height: 1.3;
}

.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.detail-meta-item {
  display: flex;
  align-items: start;
  gap: 12px;
  font-size: 15px;
}

.detail-meta-icon {
  color: var(--primary-color);
  font-size: 20px;
  margin-top: 2px;
}

.detail-description {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-dark);
  margin-bottom: 24px;
}

.detail-action {
  display: inline-block;
  background: var(--primary-color);
  color: white;
  padding: 14px 28px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s;
  text-align: center;
  width: 100%;
}

.detail-action:hover {
  background: var(--primary-hover);
}

/* Tablet Styles */
@media (min-width: 640px) {
  .search-section {
    padding: 24px 16px;
  }

  .events-table {
    font-size: 15px;
  }

  .detail-card {
    padding: 32px;
  }
}

/* Desktop Styles */
@media (min-width: 1024px) {
  .header {
    padding: 64px 0;
  }

  .main-title {
    font-size: 4.5rem;
    line-height: 1.1;
    margin-bottom: 32px;
  }

  .subtitle {
    font-size: 1.5rem;
    line-height: 2.25rem;
  }

  .search-section {
    padding: 48px 24px 56px;
  }

  .table-container {
    padding: 24px;
  }

  .search-row {
    max-width: 900px;
    margin: 0 auto 32px;
  }

  .quick-filters {
    justify-content: center;
  }

  .advanced-filters {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
  }
}
