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

:root {
  /* Dark theme (default) */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-input: #334155;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --border-color: #475569;
  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
}

/* Light theme */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-input: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --border-color: #cbd5e1;
  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
}

/* Theme toggle styles */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
}

#theme-switch {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  padding: 0;
}

#theme-switch:hover {
  transform: scale(1.1);
  border-color: var(--accent-primary);
}

/* Offline indicator */
.offline-indicator {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #ef4444;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 99;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateX(-50%) translateY(100px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

.theme-icon {
  font-size: 1.2rem;
  transition: all 0.3s ease;
}

[data-theme="light"] .theme-icon.light {
  display: none;
}

[data-theme="light"] .theme-icon.dark {
  display: block;
}

[data-theme="dark"] .theme-icon.light {
  display: block;
}

[data-theme="dark"] .theme-icon.dark {
  display: none;
}

body {
  background-color: var(--bg-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  font-family: "Poppins", sans-serif;
}

.container {
  width: 100%;
  max-width: 400px;
  background-color: var(--bg-secondary);
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

h1 {
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 20px;
}

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

label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-secondary);
}

input,
select {
  width: 100%;
  padding: 10px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  font-size: 1rem;
  color: var(--text-primary);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

input.error {
  border-color: #ef4444;
  background-color: rgba(239, 68, 68, 0.05);
}

input.error:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

button {
  width: 100%;
  padding: 12px;
  background-color: var(--accent-primary);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

button:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
}

#result {
  margin-top: 20px;
  text-align: center;
  font-size: 1.2rem;
  color: var(--text-primary);
}

.conversion-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 15px;
  background-color: var(--bg-input);
  border-radius: 8px;
  margin-top: 20px;
}

.amount-display {
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--text-primary);
  padding: 8px 15px;
  border-radius: 6px;
  background-color: var(--bg-secondary);
}

.amount-display.highlight {
  color: var(--accent-primary);
  font-size: 1.6rem;
  font-weight: 600;
}

.equals {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin: 5px 0;
}

.details-toggle {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.9rem;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease, color 0.12s ease;
  display: inline-block;
  font-weight: 600;
}

.rate-details {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: left;
}

.details-toggle.hint {
  animation: pulse 1.2s ease-in-out 0s 2;
  box-shadow: 0 8px 24px rgba(59,130,246,0.16);
  transform: translateY(-2px);
}

/* Hover / focus states for accessibility */
.details-toggle:hover,
.details-toggle:focus {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

/* Theme-specific tweaks for visibility */
[data-theme="light"] .details-toggle {
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

[data-theme="light"] .details-toggle:hover,
[data-theme="light"] .details-toggle:focus {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

[data-theme="dark"] .details-toggle {
  background: rgba(255,255,255,0.03);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.06);
}

[data-theme="dark"] .details-toggle:hover,
[data-theme="dark"] .details-toggle:focus {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

/* Spinner animations */
@keyframes spin {
  0% { 
    transform: rotate(0deg);
    border-width: 8px;
  }
  50% { 
    border-width: 6px;
  }
  100% { 
    transform: rotate(360deg);
    border-width: 8px;
  }
}

@keyframes pulse {
  0% { box-shadow: 0 0 15px rgba(59, 130, 246, 0.5); }
  50% { box-shadow: 0 0 25px rgba(59, 130, 246, 0.8); }
  100% { box-shadow: 0 0 15px rgba(59, 130, 246, 0.5); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Loading spinner */
.loading-spinner {
  width: 80px;
  height: 80px;
  margin: 30px auto;
  border: 8px solid var(--accent-primary);
  border-top: 8px solid #ffffff;
  border-radius: 50%;
  animation: 
    spin 0.8s cubic-bezier(0.5, 0, 0.5, 1) infinite,
    pulse 2s ease-in-out infinite;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  opacity: 1;
  transition: opacity 0.3s ease;
  background-color: var(--bg-input);
  transform-origin: center center;
}

.loading-spinner::before {
  content: '';
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border: 6px solid var(--bg-input);
  border-radius: 50%;
  z-index: -1;
}

.loading-spinner::after {
  content: "Loading...";
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--accent-primary);
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  animation: fadeIn 0.3s ease;
}

/* Error message */
.error-message {
  margin: 20px auto;
  text-align: center;
  color: #ef4444;
  font-size: 0.95rem;
  padding: 12px 15px;
  border-radius: 8px;
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  max-width: 90%;
  animation: 
    fadeIn 0.3s ease,
    shake 0.5s ease-in-out;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Hidden state */
.cache-status {
  margin-top: 15px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: 6px;
  background-color: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.cache-status.offline {
  background-color: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.cache-status.cached {
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--accent-primary);
}

.cache-icon {
  font-size: 1rem;
}

/* History section */
.history-section {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  animation: fadeIn 0.3s ease;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.history-header h3 {
  color: var(--text-primary);
  font-size: 1rem;
  margin: 0;
}

.clear-btn {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.clear-btn:hover {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  padding: 10px 12px;
  background-color: var(--bg-input);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-item:hover {
  background-color: var(--bg-secondary);
  border-color: var(--accent-primary);
}

.history-item-text {
  font-size: 0.9rem;
  color: var(--text-primary);
  flex: 1;
}

.history-item-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: 10px;
}

.hidden {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}