
* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #333;
  text-align: center;
  padding: 1rem;
  margin: 0;
  min-height: 100vh;
  transition: all 0.3s ease;
}

body.dark-mode {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  color: #ecf0f1;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  border-radius: 10px;
  margin-bottom: 2rem;
}

.dark-mode .top-bar {
  background: rgba(0, 0, 0, 0.2);
}

.auth-buttons button {
  margin-left: 10px;
  padding: 0.5rem 1rem;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.auth-buttons button:hover {
  background: #c0392b;
  transform: translateY(-2px);
}

.auth-form {
  position: absolute;
  top: 70px;
  right: 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 5px 25px rgba(0,0,0,0.2);
  z-index: 1000;
}

.dark-mode .auth-form {
  background: rgba(44, 62, 80, 0.95);
  color: #ecf0f1;
}

.auth-form input {
  display: block;
  width: 200px;
  margin: 10px 0;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s ease;
}

.auth-form input:focus {
  outline: none;
  border-color: #3498db;
}

.dark-mode .auth-form input {
  background: #34495e;
  border-color: #555;
  color: #ecf0f1;
}

.auth-form button {
  margin-top: 15px;
  padding: 12px;
  width: 100%;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s ease;
}

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

.hidden {
  display: none !important;
}

.container {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(15px);
  padding: 2rem;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  max-width: 700px;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark-mode .container {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.1);
}

.header-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.theme-toggle {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.user-controls {
  display: flex;
  gap: 10px;
}

.logout-btn {
  background: #e74c3c;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.logout-btn:hover {
  background: #c0392b;
  transform: translateY(-2px);
}

h1 {
  font-size: 2.5rem;
  margin: 1rem 0;
  background: linear-gradient(45deg, #3498db, #9b59b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
  opacity: 0.9;
}

.nav-links a {
  color: #3498db;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.nav-links a:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.dark-mode .nav-links a {
  color: #74b9ff;
}

.fact-generator {
  margin: 2rem 0;
}

select {
  font-size: 1rem;
  padding: 12px 16px;
  margin-bottom: 1.5rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 200px;
}

select:focus {
  outline: none;
  border-color: #3498db;
}

.dark-mode select {
  background: rgba(0, 0, 0, 0.2);
}

.dark-mode select option {
  background: #34495e;
  color: #ecf0f1;
}

.dark-mode select optgroup {
  background: #2c3e50;
  color: #ecf0f1;
  font-weight: bold;
}

.button-group {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

button#generateBtn {
  font-size: 1.2rem;
  padding: 15px 30px;
  background: linear-gradient(45deg, #e74c3c, #c0392b);
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  min-width: 200px;
}



.keyboard-hint {
  font-size: 0.85rem;
  opacity: 0.7;
  margin: 10px 0 0 0;
  font-style: italic;
}

button#generateBtn:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

button#generateBtn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.loader {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.fact-container {
  margin: 2rem 0;
  min-height: 100px;
}

#factDisplay {
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1.6;
  background: rgba(255, 255, 255, 0.1);
  padding: 1.5rem;
  border-radius: 15px;
  margin: 1rem 0;
  border-left: 4px solid #3498db;
  text-align: left;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.fact-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.action-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.favorites-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; height: 0; }
  to { opacity: 1; height: auto; }
}

.search-input {
  width: 100%;
  padding: 10px 15px;
  margin: 10px 0 15px 0;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 25px;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.search-input:focus {
  outline: none;
  border-color: #3498db;
  background: rgba(255, 255, 255, 0.15);
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.dark-mode .search-input {
  background: rgba(0, 0, 0, 0.2);
}

.dark-mode .search-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.favorites-list {
  max-height: 300px;
  overflow-y: auto;
  text-align: left;
}

.favorite-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem;
  margin: 0.5rem 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  transition: all 0.3s ease;
}

.favorite-item:hover {
  background: rgba(255, 255, 255, 0.15);
}

.favorite-item p {
  margin: 0;
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.4;
}

.remove-btn {
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  margin-left: 10px;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.remove-btn:hover {
  background: #c0392b;
  transform: scale(1.1);
}

.message {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 15px 20px;
  border-radius: 10px;
  color: white;
  font-weight: 500;
  z-index: 1000;
  animation: slideIn 0.3s ease;
}

.message.success {
  background: #27ae60;
}

.message.error {
  background: #e74c3c;
}

.message.info {
  background: #3498db;
}

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

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 0.5rem;
  }
  
  .container {
    padding: 1.5rem;
    margin: 0.5rem;
  }
  
  h1 {
    font-size: 2rem;
  }
  
  .top-bar {
    padding: 10px;
    flex-direction: column;
    gap: 10px;
  }
  
  .auth-form {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    right: auto;
    width: 90%;
    max-width: 300px;
  }
  
  .nav-links {
    flex-direction: column;
    align-items: center;
  }
  
  .fact-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .action-btn {
    width: 100%;
    max-width: 200px;
  }
  
  select {
    width: 100%;
    max-width: 300px;
  }
  
  .message {
    right: 10px;
    left: 10px;
    right: 10px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 1rem;
  }
  
  h1 {
    font-size: 1.8rem;
  }
  
  #factDisplay {
    font-size: 1rem;
    padding: 1rem;
  }
  
  button#generateBtn {
    padding: 12px 24px;
    font-size: 1rem;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
button:focus,
select:focus,
input:focus,
a:focus {
  outline: 2px solid #3498db;
  outline-offset: 2px;
}
