body {
  font-family: sans-serif;
  margin: 0;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1200px;
  padding: 20px;
}

.logo {
  font-size: 2rem;
  font-weight: 700;
  color: #1976d2;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  letter-spacing: -0.02em;
  text-decoration: none;
  background: linear-gradient(135deg, #1976d2, #2196f3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  user-select: none;
}

nav {
  display: flex;
  gap: 20px;
}

nav a {
  text-decoration: none;
  color: #333;
  padding: 8px 16px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

nav a:hover {
  background-color: #f0f0f0;
}

nav a.active {
  background-color: #2196F3;
  color: white;
}

#userInfo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-photo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.large-user-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid #ddd;
}

#logoutBtn {
  padding: 6px 12px;
  background: #f44336;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#logoutBtn:hover {
  background: #d32f2f;
}

.search-container {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  justify-content: center;
}

.searchbar {
  flex: 1;
  max-width: 60vw;
  padding: 14px 20px;
  font-size: 1.1rem;
  border-radius: 50px;
  border: 1px solid #ddd;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.searchbar:focus {
  outline: none;
  border-color: #2196F3;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.search-button {
  padding: 14px 28px;
  background: #2196F3;
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  white-space: nowrap;
}

.search-button:hover {
  background: #1976d2;
  transform: translateY(-1px);
}

.search-button:active {
  transform: translateY(0);
}

.filters {
  margin: 20px 0;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.filters input[type="number"] {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
  width: 120px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filters input[type="number"]:focus {
  outline: none;
  border-color: #2196F3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.journal-filter-row {
  display: flex;
  justify-content: center;
  margin: 15px 0;
}

.checkbox-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
  height: 40px;
  box-sizing: border-box;
}

.checkbox-filter:hover {
  background: #f8f9fa;
  border-color: #2196F3;
}

.checkbox-filter input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

.checkbox-filter span {
  font-size: 0.9rem;
  color: #333;
  user-select: none;
}

/* Journal Selector Styles */
.journal-selector {
  position: relative;
  min-width: 300px;
  max-width: 500px;
  width: 100%;
}

.journal-input-container {
  border: 1px solid #ddd;
  border-radius: 8px;
  background: white;
  min-height: 40px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.journal-input-container:focus-within {
  border-color: #2196F3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.journal-search {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  box-sizing: border-box;
  height: 40px;
  background: transparent;
}

.journal-input-container:has(.selected-journals:not(:empty)) .journal-search {
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid #f0f0f0;
}

.journal-search:focus {
  outline: none;
}

.journal-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  margin-top: 4px;
}

.journal-list {
  max-height: 200px;
  overflow-y: auto;
}

.journal-option {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.9rem;
}

.journal-option:last-child {
  border-bottom: none;
}

.journal-option:hover {
  background-color: #f5f5f5;
}

.journal-option.selected {
  background-color: #e3f2fd;
  color: #1976d2;
}

.selected-journals {
  padding: 0 12px 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 80px;
  overflow-y: auto;
  border-radius: 0 0 8px 8px;
}

.selected-journals:empty {
  display: none;
}

.selected-journal {
  background: #2196F3;
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selected-journal .remove {
  cursor: pointer;
  font-weight: bold;
  padding: 0 2px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
}

.selected-journal .remove:hover {
  background: rgba(255,255,255,0.5);
}

/* Simple Results Styling */
#results {
  width: 100%;
  max-width: 1000px;
  margin: 20px 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.results-header {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 20px;
  color: #333;
  border-bottom: 2px solid #e0e0e0;
  padding-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.results-title {
  flex: 1;
  min-width: 300px;
}

.results-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: normal;
}

.results-controls label {
  color: #666;
}

.results-controls select {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  font-size: 0.9rem;
  cursor: pointer;
}

.results-controls select:focus {
  outline: none;
  border-color: #2196F3;
}

.result {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e8e8e8;
}

.result:last-child {
  border-bottom: none;
}

.result-title {
  font-size: 1.1rem;
  font-weight: bold;
  color: #333;
  margin-bottom: 8px;
  line-height: 1.4;
}

.result-title-link {
  color: #1976d2;
  text-decoration: none;
}

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

.result-journal {
  color: #666;
  font-style: italic;
  margin-bottom: 3px;
  font-size: 0.95rem;
}

.result-year {
  color: #666;
  margin-bottom: 3px;
  font-size: 0.95rem;
}

.result-citation-count {
  color: #888;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.result-authors {
  color: #666;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.result-abstract {
  color: #555;
  line-height: 1.5;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.result-citation {
  font-style: italic;
  color: #777;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.result-links {
  font-size: 0.9rem;
}

.result-links a {
  color: #2196F3;
  text-decoration: none;
  margin-right: 10px;
}

.result-links a:hover {
  text-decoration: underline;
}

.show-more {
  color: #1976d2;
  cursor: pointer;
  font-size: 0.9em;
  margin-left: 5px;
}

.show-more:hover {
  text-decoration: underline;
}

/* Status Messages */
.loading {
  text-align: center;
  padding: 40px;
  font-size: 1.2rem;
  color: #666;
}

.error {
  text-align: center;
  padding: 40px;
  font-size: 1.2rem;
  color: #f44336;
  background: #ffebee;
  border-radius: 8px;
  border: 1px solid #ffcdd2;
}

.no-results {
  text-align: center;
  padding: 40px;
  font-size: 1.2rem;
  color: #666;
  background: #f5f5f5;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.login-container {
  background: white;
  padding: 30px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Settings Page Styles */
.settings-main {
  width: 100%;
  max-width: 800px;
  padding: 20px;
}

.settings-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.settings-container h1 {
  margin: 0;
  padding: 30px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  color: #333;
}

.settings-section {
  padding: 30px;
  border-bottom: 1px solid #dee2e6;
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h2 {
  margin-top: 0;
  color: #495057;
}

.section-description {
  color: #6c757d;
  margin-bottom: 20px;
}

.profile-info {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.profile-details p {
  margin: 8px 0;
  color: #495057;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-weight: 500;
}

.status-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.status-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.settings-form {
  max-width: 500px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #495057;
}

.api-key-input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 14px;
  font-family: monospace;
}

.form-group {
  position: relative;
}

.toggle-btn {
  position: absolute;
  right: 8px;
  top: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
}

.toggle-btn:hover {
  background: #f8f9fa;
}

.save-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: background-color 0.2s;
}

.save-btn:hover {
  background: #218838;
}

.save-btn:disabled {
  background: #6c757d;
  cursor: not-allowed;
}

.api-key-help {
  margin-top: 20px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 6px;
}

.api-key-help details summary {
  cursor: pointer;
  font-weight: 500;
  color: #495057;
  margin-bottom: 10px;
}

.api-key-help ol {
  margin: 10px 0;
  padding-left: 20px;
}

.api-key-help a {
  color: #007bff;
  text-decoration: none;
}

.api-key-help a:hover {
  text-decoration: underline;
}

/* Notification Styles */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 20px;
  border-radius: 6px;
  color: white;
  font-weight: 500;
  z-index: 1100;
  cursor: pointer;
  max-width: 300px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  animation: slideIn 0.3s ease-out;
}

.notification-success {
  background: #28a745;
}

.notification-error {
  background: #dc3545;
}

.notification-info {
  background: #17a2b8;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Responsive Design */
@media (min-width: 768px) {
  body {
    padding: 0 40px;
  }
}

@media (min-width: 1200px) {
  body {
    padding: 0 60px;
  }
}

@media (max-width: 768px) {
  body {
    padding: 0 15px;
  }
  
  .search-container {
    flex-direction: column;
    gap: 12px;
  }
  
  .searchbar {
    max-width: 90vw;
  }
  
  .search-button {
    align-self: stretch;
    max-width: 200px;
  }
  
  .filters {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  
  .filters input[type="number"] {
    width: 160px;
  }
  
  .journal-filter-row {
    margin: 10px 0;
    padding: 0 10px;
  }
  
  .journal-selector {
    min-width: 250px;
    max-width: 400px;
  }
  
  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .results-title {
    min-width: auto;
  }
  
  .results-controls {
    align-self: stretch;
    justify-content: center;
  }
  
  .metadata-row {
    flex-direction: column;
    gap: 8px;
  }
  
  .search-result {
    padding: 16px;
  }
}

.hidden {
  display: none !important;
}
