/*
 * Translator component styles for Traduire.org
 * Optimized for performance and user experience
 */

.translator-container {
  max-width: 1200px;
  margin: 0 auto 2rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* Language Selector */
.language-selector {
  display: flex;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: relative;
  padding: 1rem;
  gap: 1rem;
}

.lang-select-wrapper {
  flex: 1;
  position: relative;
}

.lang-select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 14px;
  font-weight: 500;
  color: #0055A4;
  background: #F8F9FA;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  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='%230055A4' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.lang-select:hover {
  border-color: #0055A4;
  background-color: #fff;
}

.lang-select:focus {
  outline: none;
  border-color: #0055A4;
  box-shadow: 0 0 0 3px rgba(0, 85, 164, 0.1);
}

/* Swap button */
.swap-button {
  position: relative;
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.swap-button:hover {
  background: #F8F9FA;
  border-color: #0055A4;
  transform: rotate(180deg);
}

.swap-button:active {
  transform: rotate(180deg) scale(0.95);
}

.swap-icon {
  width: 20px;
  height: 20px;
  color: #0055A4;
}

/* Translation panels */
.translation-panels {
  display: flex;
  min-height: 300px;
}

.panel {
  flex: 1;
  position: relative;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.panel.source {
  border-right: 1px solid #e0e0e0;
}

.panel-content {
  padding: 1.5rem;
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.text-input,
.text-output {
  width: 100%;
  min-height: 200px;
  border: none;
  outline: none;
  font-size: 18px;
  color: #1F2937;
  resize: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  flex: 1;
}

.text-input::placeholder {
  color: #9CA3AF;
}

.text-output {
  background: transparent;
  color: #0055A4;
  font-weight: 500;
}

/* Panel footer */
.panel-footer {
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #F8F9FA;
  border-top: 1px solid #e0e0e0;
}

.char-counter {
  font-size: 13px;
  color: #6B7280;
  font-weight: 500;
}

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

/* Icon button */
.icon-button {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  border-radius: 6px;
  color: #6B7280;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-button:hover {
  background: #E5E7EB;
  color: #0055A4;
}

.icon-button:active {
  transform: scale(0.95);
}

/* Clear button */
.clear-button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: #E5E7EB;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  color: #6B7280;
  font-size: 20px;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.clear-button.visible {
  display: flex;
}

.clear-button:hover {
  background: #D1D5DB;
  color: #1F2937;
}

/* Translate button */
.translate-button {
  background: linear-gradient(135deg, #0055A4 0%, #0066CC 100%);
  color: white;
  border: none;
  padding: 0.625rem 1.75rem;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0, 85, 164, 0.2);
}

.translate-button:hover {
  background: linear-gradient(135deg, #004080 0%, #0055A4 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 85, 164, 0.3);
}

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

.translate-button:disabled {
  background: #D1D5DB;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Info section */
.info-section {
  max-width: 1200px;
  margin: 3rem auto 0;
  padding: 0 1rem;
}

.info-card {
  background: #fff;
  border-radius: 12px;
  padding: 2.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.info-card h1 {
  color: #0055A4;
  font-size: 2rem;
  margin-bottom: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}

.info-card h2 {
  color: #0055A4;
  font-size: 1.5rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.info-card h3 {
  color: #1F2937;
  font-size: 1.25rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.info-card p {
  color: #4B5563;
  line-height: 1.7;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.info-card strong {
  color: #0055A4;
  font-weight: 600;
}

/* Feature grid */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.feature-item {
  padding: 1.5rem;
  background: linear-gradient(135deg, #F8F9FA 0%, #fff 100%);
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  transition: all 0.2s;
}

.feature-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 85, 164, 0.1);
  border-color: #0055A4;
}

.feature-item h3,
.feature-item h4 {
  color: #1F2937;
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 1.1rem;
}

.feature-item p {
  color: #6B7280;
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 0;
}

/* Responsive design */
@media (max-width: 768px) {
  .translation-panels {
    flex-direction: column;
  }

  .panel.source {
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }

  .language-selector {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .lang-select-wrapper {
    flex: 1 1 calc(50% - 0.375rem);
    min-width: 0;
  }

  .swap-button {
    order: 3;
    flex: 1 1 100%;
    border-radius: 6px;
    width: 100%;
    height: 40px;
  }

  .swap-button:hover {
    transform: rotate(90deg);
  }

  .swap-button:active {
    transform: rotate(90deg) scale(0.95);
  }

  .text-input,
  .text-output {
    font-size: 16px;
    min-height: 150px;
  }

  .info-card {
    padding: 1.5rem;
  }

  .info-card h1 {
    font-size: 1.5rem;
  }

  .info-card h2 {
    font-size: 1.25rem;
  }

  .info-card h3 {
    font-size: 1.1rem;
  }

  .feature-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .translator-container {
    border-radius: 8px;
  }

  .info-card {
    padding: 1.25rem;
  }

  .panel-content {
    padding: 1rem;
  }

  .panel-footer {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .translate-button {
    width: 100%;
  }
}

/* Loading state */
.text-output.loading {
  color: #9CA3AF;
  font-style: italic;
}

/* Animation for translation appearance */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.text-output:not(:empty) {
  animation: slideIn 0.3s ease-out;
}

/* Accessibility improvements */
.lang-select:focus,
.swap-button:focus,
.translate-button:focus,
.icon-button:focus,
.clear-button:focus {
  outline: 2px solid #0055A4;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .translator-container {
    border: 2px solid #000;
  }

  .lang-select,
  .swap-button {
    border-width: 3px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .swap-button,
  .translate-button,
  .icon-button,
  .feature-item,
  .text-output {
    transition: none;
    animation: none;
  }

  .swap-button:hover {
    transform: none;
  }
}
