/* CSS Custom Properties for consistent theming */
:root {
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --primary-color: #667eea;
  --secondary-color: #764ba2;
  --success-color: #38a169;
  --error-color: #e53e3e;
  --warning-color: #d69e2e;
  --text-primary: #2d3748;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --bg-primary: #ffffff;
  --bg-secondary: #f7fafc;
  --bg-tertiary: #edf2f7;
  --border-color: #e2e8f0;
  --border-radius: 0px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
  --transition: all 0.2s ease;
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background: var(--primary-gradient);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.6;
}

/* Container and layout */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  margin-bottom: 3rem;
  color: white;
}

header h1 {
  font-size: 2.75rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  letter-spacing: -0.025em;
}

header p {
  font-size: 1.125rem;
  opacity: 0.95;
  font-weight: 400;
}

main {
  background: var(--bg-primary);
  border-radius: 0px;
  padding: 3rem;
  box-shadow: var(--shadow-xl);
  position: relative;
  flex: 1;
}

footer {
  text-align: center;
  margin-top: 2rem;
  color: white;
  font-size: 0.875rem;
  opacity: 0.8;
}

footer a {
  color: white;
  text-decoration: underline;
}

/* Step management */
.step {
  transition: var(--transition);
  opacity: 1;
}

.step.hidden {
  display: none;
}

h2 {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 1.75rem;
  font-weight: 600;
  border-bottom: 2px solid var(--bg-tertiary);
  padding-bottom: 0.75rem;
}

/* Form elements */
.input-group {
  margin-bottom: 2rem;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

label {
  display: block;
  margin-bottom: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  transition: var(--transition);
  background: var(--bg-primary);
  font-family: inherit;
}

input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input:invalid {
  border-color: var(--error-color);
}

small {
  display: block;
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

small a {
  color: var(--primary-color);
  text-decoration: none;
}

small a:hover {
  text-decoration: underline;
}

/* Button styles */
.btn-primary, .btn-secondary {
  padding: 1rem 2rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  min-width: 140px;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
  border-color: var(--text-muted);
}

.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 0px;
  animation: spin 1s linear infinite;
}

.btn-spinner.hidden {
  display: none;
}

.btn-text.hidden {
  display: none;
}

.button-row {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 2rem;
}

/* Statistics and counts */
.stats {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
}

.stat {
  text-align: center;
  padding: 1.5rem 2.5rem;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.database-count {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.stat-number {
  display: block;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* Suffix configuration section */
.suffix-config-section {
  margin-bottom: 2rem;
}

.suffix-config-section h3 {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

/* Database list display */
.database-list-section {
  margin-bottom: 2rem;
}

.database-list-section h3 {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

/* Tab container */
.tab-container {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-secondary);
}

.tab-buttons {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.tab-button {
  flex: 1;
  padding: 1rem;
  border: none;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border-radius: 0;
}

.tab-button:hover {
  background: var(--bg-tertiary);
}

.tab-button.active {
  background: var(--primary-color);
  color: white;
}

.tab-content {
  padding: 1rem;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.database-list-container {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-secondary);
}

.database-list {
  padding: 1rem;
}

.database-item {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: 0.5rem;
  background: var(--bg-primary);
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.database-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.database-item:last-child {
  margin-bottom: 0;
}

.database-item .title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
  word-break: break-word;
}

.database-item .url {
  font-size: 0.875rem;
  color: var(--text-muted);
  word-break: break-all;
}

.database-item .metadata {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Condensed list styles */
.database-list-condensed {
  padding: 0;
}

.database-item-condensed {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.database-item-condensed:hover {
  background: var(--bg-tertiary);
}

.database-item-condensed:last-child {
  border-bottom: none;
}

.database-item-condensed .icon {
  font-size: 1.25rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.database-item-condensed .icon-image {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  border-radius: 0;
  object-fit: cover;
}

.database-item-condensed .title {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
}

.database-item-condensed .url {
  font-size: 0.75rem;
  color: var(--text-muted);
  word-break: break-all;
  margin-top: 0.25rem;
}

/* Matches and results display */
.matches-container, .results-container {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 2rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-secondary);
}

.matches-list, .results-list {
  padding: 1rem;
}

.match-item, .result-item {
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: 0.75rem;
  background: var(--bg-primary);
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.match-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.match-item:last-child, .result-item:last-child {
  margin-bottom: 0;
}

.match-item .title-change {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  line-height: 1.4;
  word-break: break-word;
}

.database-item .title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.database-item .title .icon {
  font-size: 1.25rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.database-item .title .icon-image {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  border-radius: 0;
  object-fit: cover;
}

.match-item .old-title {
  color: var(--error-color);
  text-decoration: line-through;
  opacity: 0.8;
}

.match-item .new-title {
  color: var(--success-color);
  font-weight: 700;
}

.match-item .url {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  word-break: break-all;
}

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

.result-item.success {
  background: #f0fff4;
  border-color: #9ae6b4;
  color: #22543d;
}

.result-item.error {
  background: #fed7d7;
  border-color: #feb2b2;
  color: #742a2a;
}

.result-item .result-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.result-item .result-text {
  flex: 1;
  line-height: 1.4;
  word-break: break-word;
}

/* Results summary */
.results-summary {
  text-align: center;
  margin-bottom: 2rem;
  padding: 2rem;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.results-summary h3 {
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.results-summary p {
  font-size: 1.125rem;
  color: var(--text-muted);
}

/* Error handling */
.error-message {
  position: fixed;
  top: 2rem;
  right: 2rem;
  max-width: 400px;
  z-index: 1000;
  animation: slideInRight 0.3s ease;
}

.error-message.hidden {
  display: none;
}

.error-content {
  background: #fed7d7;
  border: 1px solid #feb2b2;
  border-radius: var(--border-radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.error-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.error-text {
  flex: 1;
  color: #742a2a;
  font-weight: 500;
  line-height: 1.4;
}

.error-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #742a2a;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}

.error-close:hover {
  opacity: 0.7;
}

/* Loading overlay */
.loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 0px;
  backdrop-filter: blur(2px);
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--primary-color);
  border-radius: 0px;
  animation: spin 1s linear infinite;
  margin-bottom: 1.5rem;
}

.loading p {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 1.125rem;
}

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

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

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

.step {
  animation: fadeIn 0.3s ease;
}

/* Responsive design */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }
  
  main {
    padding: 2rem;
  }
  
  .input-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  header h1 {
    font-size: 2.25rem;
  }
  
  .button-row {
    flex-direction: column;
  }
  
  .error-message {
    position: fixed;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
  
  .matches-container, .results-container {
    max-height: 300px;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 2rem;
  }
  
  main {
    padding: 1.5rem;
  }
  
  .stat {
    padding: 1rem 1.5rem;
  }
  
  .stat-number {
    font-size: 2rem;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --text-muted: #333333;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for accessibility */
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Print styles */
@media print {
  body {
    background: white;
  }
  
  .container {
    max-width: none;
    padding: 0;
  }
  
  main {
    box-shadow: none;
    border: 1px solid #000;
  }
  
  .btn-primary, .btn-secondary {
    display: none;
  }
} 