* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background: #f5f5f5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: #2c3e50;
  color: white;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-content {
  text-align: left;
}

header h1 {
  margin: 0;
  font-size: 1.8rem;
}

header h1 a {
  color: white;
  text-decoration: none;
}

header .subtitle {
  opacity: 0.8;
  margin-top: 0.25rem;
}

.language-switcher {
  display: flex;
  align-items: center;
}

.language-switcher select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='white' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

.language-switcher select:hover {
  background-color: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

.language-switcher select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.language-switcher select option {
  background-color: #2c3e50;
  color: white;
}

main {
  flex: 1;
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

footer {
  background: #2c3e50;
  color: white;
  text-align: center;
  padding: 1rem;
  opacity: 0.9;
}

/* Search Section */
.search-section {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 2rem;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-row {
  display: flex;
  gap: 0.5rem;
}

.search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 4px;
  outline: none;
}

.search-input:focus {
  border-color: #3498db;
}

.search-button {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.search-button:hover {
  background: #2980b9;
}

.filters {
  display: flex;
  gap: 1rem;
}

.filter-select {
  padding: 0.5rem;
  font-size: 0.9rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
}

/* Results Section */
.results-section {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.results-section h2 {
  margin-bottom: 1rem;
  color: #2c3e50;
}

.results-count {
  color: #666;
  margin-bottom: 1rem;
}

.no-results {
  color: #666;
  font-style: italic;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.result-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.result-image {
  flex-shrink: 0;
}

.result-image img {
  border-radius: 15px;
  border: 1px solid #000;
  max-width: 150px;
}

.result-content {
  flex: 1;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* Mobile: stack vertically */
@media (max-width: 600px) {
  .result-item {
    flex-direction: column;
  }

  .result-image img {
    max-width: 100%;
  }

  .search-row {
    flex-direction: column;
  }

  .filters {
    flex-direction: column;
  }

  .filter-select {
    width: 100%;
  }
}

.result-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.result-title {
  display: block;
  font-weight: 600;
  color: #3498db;
  text-decoration: none;
}

.result-title:hover {
  text-decoration: underline;
}

.result-meta {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: #666;
}

.result-meta span {
  margin-right: 0.5rem;
}

.result-meta .year {
  background: #3498db;
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.result-meta .type {
  background: #95a5a6;
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.result-meta .page {
  background: #27ae60;
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.result-snippet {
  color: #555;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.result-snippet mark {
  background: #fff3cd;
  padding: 0.1rem 0.2rem;
  border-radius: 2px;
}

.result-actions {
  display: flex;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  text-decoration: none;
  border-radius: 4px;
  background: #3498db;
  color: white;
  border: none;
  cursor: pointer;
}

.btn:hover {
  background: #2980b9;
}

.btn-secondary {
  background: #95a5a6;
}

.btn-secondary:hover {
  background: #7f8c8d;
}

.btn-small {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

/* Browse Section */
.browse-section {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.browse-section h2 {
  margin-bottom: 0.5rem;
  color: #2c3e50;
}

.category-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.category-link {
  padding: 0.5rem 1rem;
  background: #ecf0f1;
  color: #2c3e50;
  text-decoration: none;
  border-radius: 4px;
}

.category-link:hover {
  background: #3498db;
  color: white;
}

/* Document Section */
.document-section {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.document-header {
  margin-bottom: 1rem;
}

.back-link {
  color: #3498db;
  text-decoration: none;
  font-size: 0.9rem;
}

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

.document-header h2 {
  margin: 0.5rem 0;
  color: #2c3e50;
}

.document-meta {
  font-size: 0.85rem;
}

.document-meta span {
  margin-right: 0.5rem;
  background: #ecf0f1;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
}

.document-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 4px;
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-nav select {
  padding: 0.3rem;
  font-size: 0.9rem;
}

.page-info {
  color: #666;
  font-size: 0.9rem;
}

.document-actions {
  display: flex;
  gap: 0.5rem;
}

.pdf-viewer {
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}

.pdf-viewer iframe {
  border: none;
  display: block;
}

/* Responsive */
@media (max-width: 600px) {
  main {
    padding: 1rem;
  }

  .search-row {
    flex-direction: column;
  }

  .filters {
    flex-direction: column;
  }

  .document-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .document-actions {
    flex-direction: column;
  }
}
