/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #333;
  background: #f8f9fa;
  line-height: 1.6;
}

/* Main layout */
.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header - Compact */
.page__header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem 1.5rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.page__header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.page__tagline {
  font-size: 0.9rem;
  opacity: 0.95;
}

/* Main content area with sidebar */
.main-content {
  display: flex;
  flex: 1;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
  gap: 1.5rem;
  padding: 1.5rem;
}

/* Sidebar for filters */
.filters-sidebar {
  width: 320px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 1rem;
  height: fit-content;
  position: sticky;
  top: 1.5rem;
  transition: all 0.3s ease;
}

.filters-sidebar--collapsed {
  width: 48px;
  padding: 0.5rem;
  overflow: hidden;
}

/* Toggle button for sidebar */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  cursor: pointer;
  user-select: none;
  min-height: 24px;
}

.filters-sidebar--collapsed .sidebar-toggle {
  margin-bottom: 0;
  justify-content: center;
  position: relative;
}

/* Tooltip for collapsed state */
.filters-sidebar--collapsed .sidebar-toggle:hover::after {
  content: "Expand filters";
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 10px;
  background: #333;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
}

.sidebar-toggle__icon {
  font-size: 1.2rem;
  transition: transform 0.3s;
}

.filters-sidebar--collapsed .sidebar-toggle__icon {
  transform: rotate(180deg);
  font-size: 1rem;
}

.sidebar-toggle__text {
  font-weight: 600;
  font-size: 0.95rem;
}

.filters-sidebar--collapsed .sidebar-toggle__text {
  display: none;
}

/* Search and results container */
.content-area {
  flex: 1;
  min-width: 0;
}

/* Search form - Sticky at top */
.search-form {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 1.5rem;
  position: sticky;
  top: 1.5rem;
  z-index: 10;
}

.search-form__controls {
  display: flex;
  gap: 0.75rem;
}

.search-form__input {
  flex: 1;
  padding: 0.625rem 1rem;
  border: 2px solid #e1e4e8;
  border-radius: 6px;
  font-size: 1rem;
  transition: all 0.2s;
}

.search-form__input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

.search-form__summary {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: #6a737d;
}

/* Buttons */
.button {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.button--primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.button--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}

.button--text {
  background: transparent;
  color: #667eea;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.button--text:hover {
  background: rgba(102,126,234,0.1);
}

/* Filters */
.filters {
  transition: all 0.3s ease;
}

.filters-sidebar--collapsed .filters {
  display: none;
}

/* Collapsible filter groups */
.filters__group {
  margin-bottom: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.filters__group--collapsed {
  margin-bottom: 0.5rem;
}

.filters__group-header {
  padding: 0.75rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.filters__group--collapsed .filters__group-header {
  border-bottom: none;
}

.filters__group-header--collapsible {
  user-select: none;
}

.filters__group-header-row {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.filters__group-toggle {
  margin-right: 0.5rem;
  font-size: 0.75rem;
  transition: transform 0.2s;
  display: inline-block;
}

.filters__group-badge {
  background: #6366f1;
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  margin-left: 0.5rem;
}

.filters__group-selected {
  color: #6366f1;
  font-size: 0.75rem;
  margin-left: 0.5rem;
  font-weight: 500;
}

.filters__group--collapsed .filters__list {
  display: none;
}

.filters__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e1e4e8;
}

.filters__header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #24292e;
}

.filters__actions {
  display: flex;
  gap: 0.5rem;
}

/* Filter groups */
.filters__groups {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.filters__groups::-webkit-scrollbar {
  width: 6px;
}

.filters__groups::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.filters__groups::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.filters__group {
  margin-bottom: 1.25rem;
}

.filters__group-header {
  margin-bottom: 0.5rem;
}

.filters__group-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #24292e;
  margin-bottom: 0.25rem;
}

.filters__group-header p {
  font-size: 0.75rem;
  color: #6a737d;
  line-height: 1.4;
}

.filters__group-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.filters__list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Source options */
.source-option {
  font-size: 0.85rem;
}

.source-option__label {
  display: flex;
  align-items: flex-start;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.source-option__label:hover {
  background: #f6f8fa;
}

.source-option__label input[type="checkbox"] {
  margin-right: 0.5rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
}

.source-option__label strong {
  display: block;
  font-weight: 500;
  color: #24292e;
  margin-bottom: 0.1rem;
}

.source-option__meta {
  font-size: 0.75rem;
  color: #6a737d;
  line-height: 1.3;
}

/* Results section */
.results {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  min-height: 400px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.results__empty {
  text-align: center;
  color: #6a737d;
  padding: 3rem;
  font-size: 1rem;
}

.results__error {
  text-align: center;
  color: #d73a49;
  padding: 2rem;
  background: #ffeef0;
  border-radius: 6px;
}

/* Footer - Compact */
.page__footer {
  background: white;
  border-top: 1px solid #e1e4e8;
  padding: 1rem 1.5rem;
  text-align: center;
  margin-top: auto;
}

.page__footer p {
  font-size: 0.875rem;
  color: #6a737d;
  margin-bottom: 0.75rem;
}

.button--secondary {
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

.button--secondary:hover {
  background: #667eea;
  color: white;
}

/* Mobile responsive */
@media (max-width: 1024px) {
  .main-content {
    flex-direction: column;
  }

  .filters-sidebar {
    width: 100%;
    position: static;
    margin-bottom: 1rem;
  }

  .search-form {
    position: static;
  }

  .filters__groups {
    max-height: 300px;
  }
}

@media (max-width: 768px) {
  .page__header {
    padding: 1rem;
  }

  .page__header h1 {
    font-size: 1.25rem;
  }

  .main-content {
    padding: 1rem;
  }

  .filters-sidebar {
    padding: 0.75rem;
  }

  .search-form__controls {
    flex-direction: column;
  }

  .button--primary {
    width: 100%;
  }
}

/* Compact view option */
.compact-filters {
  display: none;
  background: white;
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.compact-filters__toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.compact-filters__content {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e1e4e8;
  display: none;
}

.compact-filters--expanded .compact-filters__content {
  display: block;
}

/* Improved Google CSE styling */
.gsc-control-cse {
  padding: 0 !important;
  border: none !important;
}

.gsc-results-wrapper-visible {
  margin-top: 0 !important;
}

.gsc-result {
  margin-bottom: 1rem !important;
  padding: 0.75rem !important;
  border: 1px solid #e1e4e8 !important;
  border-radius: 6px !important;
  transition: all 0.2s !important;
}

.gsc-result:hover {
  border-color: #d1d5da !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
}
