:root {
  --font-family: Arial, sans-serif;
  --container-width: 90%;  /* Cambiado de 60% a 90% para ser más adaptable */
  --container-padding: 20px;
  --header-color: #333;
  --section-margin: 20px 0;
  --textarea-width: 100%;
  --textarea-padding: 10px;
  --button-margin-top: 10px;
  --button-padding: 8px 16px;
  --button-color: white;
  --button-bg-color: #4CAF50;
  --button-border: none;
  --button-cursor: pointer;
  --button-hover-bg-color: #45a049;
  --result-border: 1px solid #ccc;
  --result-padding: 10px;
  --table-border: 1px solid #ddd;
  --table-header-bg: #f2f2f2;
  --table-even-row: #f5f9ff;
  --table-odd-row: #ffffff;
  --error-color: #e74c3c;
  --loading-color: #3498db;
  --you-bubble-color: #e8f4fd;
  --me-bubble-color: #f0f0f0;
  --conversation-intro-bg: #f9f9f9;
  --conversation-summary-bg: #f5f5f5;
  --grammar-highlight-color: #4CAF50;
  --correction-highlight-color: #e67e22;
  --correction-correct-color: #2ecc71;
  --correction-incorrect-color: #e74c3c;
}

body {
  background: url('lewai0-1.jpg');
  background-size: cover;
  background-attachment: fixed;
  font-family: var(--font-family);
  margin: 0;
  padding: 0;
  font-size: 16px;  /* Base font size */
}

.container {
  width: var(--container-width);
  max-width: 1000px;  /* Máximo ancho para pantallas grandes */
  margin: 20px auto;
  padding: var(--container-padding);
  background-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  border-radius: 5px;
  box-sizing: border-box;  /* Incluir padding en el ancho total */
}

h1 {
  text-align: center;
  color: var(--header-color);
  font-size: 1.8rem;  /* Tamaño relativo */
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

.input-section,
.result-section {
  margin: var(--section-margin);
}

.input-section textarea {
  width: var(--textarea-width);
  padding: var(--textarea-padding);
  box-sizing: border-box;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
  min-height: 100px;
  font-size: 1rem;  /* Tamaño de fuente relativo */
}

/* Contenedor flexible para botones */
.button-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

button {
  padding: var(--button-padding);
  color: var(--button-color);
  background-color: var(--button-bg-color);
  border: var(--button-border);
  cursor: var(--button-cursor);
  border-radius: 4px;
  font-size: 0.9rem;
  flex-grow: 1;
  min-width: 120px;
  text-align: center;
  margin: 5px 0;
}

button:hover {
  background-color: var(--button-hover-bg-color);
}

.result-section {
  border: var(--result-border);
  padding: var(--result-padding);
  background-color: white;
  border-radius: 4px;
  min-height: 100px;
  overflow-x: auto;  /* Permitir scroll horizontal si el contenido es demasiado ancho */
}

/* Estilos para la tabla del diccionario */
.dictionary-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.9rem;
  border: 1px solid #ddd;
}

.dictionary-table th,
.dictionary-table td {
  padding: 8px;
  text-align: left;
  border: 1px solid #ddd;
}

.dictionary-table th {
  background-color: #f2f2f2;
  font-weight: bold;
  color: #333;
}

.dictionary-table .even-row {
  background-color: #f7f9fc;
}

.dictionary-table .odd-row {
  background-color: #ffffff;
}

/* Estilos específicos para cada columna */
.dictionary-table td:first-child {
  font-weight: bold;
  min-width: 80px;
}

.word-type {
  color: #666;
  font-size: 0.9em;
  font-style: italic;
}

.dictionary-table td:nth-child(2) {
  font-style: italic;
  color: #555;
}

.dictionary-table td:last-child {
  color: #0066cc;
}

/* Estilo para los ejemplos */
.dictionary-table .example {
  font-style: italic;
  color: #444;
  padding: 10px;
  background-color: #f9f9f9;
  line-height: 1.4;
}

/* Estilos para la explicación gramatical */
.grammar-container {
  margin-top: 15px;
}

.grammar-original-phrase {
  font-weight: bold;
  font-size: 1.1rem;
  padding: 10px;
  margin-bottom: 15px;
  background-color: #f0f8ff;
  border-left: 4px solid #3498db;
  color: #2c3e50;
  text-align: center;
}

.grammar-table {
  margin-top: 15px;
}

.grammar-component {
  font-weight: bold;
  color: #2980b9;
  min-width: 120px;
  width: 25%;
}

.grammar-explanation {
  line-height: 1.5;
}

.grammar-summary {
  margin-top: 20px;
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 8px;
  border-left: 4px solid var(--grammar-highlight-color);
}

.grammar-summary h4 {
  color: var(--grammar-highlight-color);
  margin-top: 0;
  margin-bottom: 10px;
}

.grammar-summary p {
  line-height: 1.5;
  margin: 8px 0;
}

/* Estilos para la corrección de texto */
.correction-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 10px;
  padding: 15px;
  border-radius: 8px;
  background-color: #fff;
}

.correction-original,
.correction-correct,
.correction-explanation {
  padding: 12px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.correction-original {
  background-color: #fff5ee;
  border-left: 4px solid var(--correction-incorrect-color);
}

.correction-correct {
  background-color: #f0fff4;
  border-left: 4px solid var(--correction-correct-color);
}

.correction-explanation {
  background-color: #fff9f1;
  border-left: 4px solid var(--correction-highlight-color);
}

.correction-label {
  font-weight: bold;
  margin-bottom: 5px;
  color: #555;
  font-size: 0.9rem;
}

.correction-text {
  line-height: 1.6;
  font-size: 1rem;
}

.correction-text.incorrect {
  color: var(--correction-incorrect-color);
  text-decoration: line-through;
  text-decoration-color: rgba(231, 76, 60, 0.4);
  text-decoration-thickness: 2px;
}

.correction-text.correct {
  color: var(--correction-correct-color);
  font-weight: bold;
}

.correction-text.explanation {
  color: #333;
}

.correction-audio {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.correction-audio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #f8f9fa;
  color: #3498db;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.correction-audio-btn:hover {
  background-color: #eef2f7;
  color: #2980b9;
}

.correction-audio-btn i {
  margin-right: 6px;
}

/* Estilos para los mensajes de error y carga */
.error {
  color: var(--error-color);
  padding: 10px;
  border-left: 4px solid var(--error-color);
  background-color: rgba(231, 76, 60, 0.1);
  margin: 10px 0;
}

.loading {
  color: var(--loading-color);
  padding: 10px;
  text-align: center;
  margin: 10px 0;
  font-style: italic;
}

.translation-loading {
  color: var(--loading-color);
  padding: 5px 10px;
  text-align: center;
  margin: 5px 0;
  font-style: italic;
  font-size: 0.85rem;
  background-color: rgba(52, 152, 219, 0.1);
  border-radius: 4px;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.raw-data {
  white-space: pre-wrap;
  margin-top: 15px;
  padding: 10px;
  background-color: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85rem;
  overflow-x: auto;
}

/* Estilos para la conversación */
.conversation-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px 0;
}

.conversation-intro {
  padding: 15px;
  background-color: var(--conversation-intro-bg);
  border-radius: 8px;
  margin-bottom: 15px;
  border-left: 4px solid #3498db;
  line-height: 1.5;
  font-size: 0.95rem;
}

.conversation-you,
.conversation-me {
  max-width: 85%;
  padding: 12px 15px;
  border-radius: 18px;
  line-height: 1.4;
  position: relative;
  margin: 5px 0;
  font-size: 0.95rem;
}

.conversation-you {
  align-self: flex-start;
  background-color: var(--you-bubble-color);
  border-bottom-left-radius: 5px;
}

.conversation-me {
  align-self: flex-end;
  background-color: var(--me-bubble-color);
  border-bottom-right-radius: 5px;
}

/* Nuevo diseño para el encabezado del diálogo */
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 5px;
}

.conversation-me .dialog-header {
  justify-content: flex-end;
}

.speaker {
  font-weight: bold;
  margin-right: 8px;
  font-size: 1.05em;
  color: #2c3e50;
}

.conversation-you .speaker {
  color: #2980b9;
}

.conversation-me .speaker {
  color: #27ae60;
}

/* Botón de audio */
.audio-btn {
  background-color: transparent;
  border: none;
  color: #3498db;
  cursor: pointer;
  padding: 2px 5px;
  font-size: 0.9rem;
  margin: 0 5px;
  border-radius: 50%;
  width: 25px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s;
}

.audio-btn:hover {
  background-color: rgba(52, 152, 219, 0.1);
}

/* Contenido del diálogo */
.dialog-content {
  display: flex;
  flex-direction: column;
}

.dialog-text {
  text-align: left;
}

.conversation-me .dialog-text {
  text-align: right;
}

/* Estilo para la traducción */
.dialog-translation {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dotted #ccc;
  color: #666;
  font-style: italic;
  font-size: 0.9em;
  display: none; /* Inicialmente oculto hasta que se cargue la traducción */
}

.conversation-summary {
  margin-top: 20px;
  padding: 15px;
  background-color: var(--conversation-summary-bg);
  border-radius: 8px;
  border-top: 2px solid #3498db;
  font-size: 0.95rem;
}

.conversation-summary h4 {
  color: #2c3e50;
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1rem;
}

.conversation-summary p {
  line-height: 1.5;
  margin: 0;
}

select, button, textarea {
  font-family: var(--font-family);
}

select {
  padding: 8px;
  margin: 5px 0;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: white;
  width: 100%;
  max-width: 400px;
  font-size: 1rem;
}

/* Diseño responsive */
@media (max-width: 768px) {
  :root {
    --container-width: 95%;
    --container-padding: 15px;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  .container {
    margin: 10px auto;
  }
  
  button {
    min-width: unset;
    width: calc(50% - 10px);
    flex-grow: 0;
    font-size: 0.85rem;
    padding: 10px 5px;
  }
  
  .conversation-you,
  .conversation-me {
    max-width: 90%;
  }
  
  /* Ajustes para la tabla en móviles */
  .dictionary-table {
    font-size: 0.8rem;
  }
  
  .dictionary-table th,
  .dictionary-table td {
    padding: 5px;
  }
}

/* Para pantallas muy pequeñas (móviles en vertical) */
@media (max-width: 480px) {
  h1 {
    font-size: 1.3rem;
  }
  
  p {
    font-size: 0.9rem;
  }
  
  .button-container {
    flex-direction: column;
  }
  
  button {
    width: 100%;
    margin: 3px 0;
  }
  
  /* Hacer la tabla más compacta */
  .dictionary-table {
    font-size: 0.75rem;
  }
  
  .dictionary-table th,
  .dictionary-table td {
    padding: 4px;
  }
  
  /* Mostrar scroll horizontal para la tabla */
  .result-section {
    overflow-x: auto;
  }
  
  .conversation-you,
  .conversation-me {
    max-width: 95%;
    padding: 8px 10px;
  }
  
  /* Ajustes para la traducción en pantallas pequeñas */
  .dialog-translation {
    font-size: 0.8em;
    padding-top: 6px;
    margin-top: 6px;
  }
  
  /* Ajuste para el botón de audio en pantallas pequeñas */
  .audio-btn {
    width: 22px;
    height: 22px;
    font-size: 0.8rem;
  }
}

/* Optimizaciones adicionales */
.options-label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

.text-input-label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

/* Para dispositivos con poca altura */
@media (max-height: 600px) {
  .container {
    margin: 5px auto;
  }
  
  h1 {
    margin: 0.3em 0;
  }
  
  .input-section textarea {
    min-height: 60px;
  }
}
