/* Variables CSS personalizadas */
:root {
  --primary-color: #3b82f6;
  --primary-dark: #2563eb;
  --secondary-color: #f59e0b;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* Estilos base */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
}

/* Botones de la barra de herramientas */
.toolbar-btn {
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  color: #374151;
  background-color: white;
  border: 1px solid #d1d5db;
  transition: all 0.2s;
  min-width: 40px;
  cursor: pointer;
}

.toolbar-btn:hover {
  background-color: #f9fafb;
  border-color: #9ca3af;
  transform: translateY(-1px);
}

.toolbar-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px #3b82f6, 0 0 0 4px white;
}

/* Estado activo de los botones */
.toolbar-btn.active {
  background-color: #3b82f6;
  color: white;
  border-color: #2563eb;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.toolbar-btn.active:hover {
  background-color: #2563eb;
  border-color: #1d4ed8;
  transform: translateY(-1px);
}

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

/* Botón de análisis */
.analyze-btn {
  padding: 0.5rem 1.5rem;
  background: linear-gradient(to right, #2563eb, #4f46e5);
  color: white;
  font-weight: 600;
  border-radius: 0.5rem;
  border: none;
  transition: all 0.2s;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.analyze-btn:hover {
  background: linear-gradient(to right, #1d4ed8, #4338ca);
}

.analyze-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

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

.analyze-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-sm);
}

/* Editor de contenido */
.editor-content {
  min-height: 400px;
  max-height: 600px;
  overflow-y: auto;
  font-size: 1.125rem;
  line-height: 1.75;
  color: #1f2937;
  outline: none;
  border: 1px solid transparent;
  transition: border-color 0.2s ease;
  position: relative;
}

.editor-content:focus {
  border-color: var(--primary-color);
}

/* Estilos para listas en el editor */
.editor-content ul {
  list-style-type: disc;
  margin-left: 1.5rem;
  margin-bottom: 1rem;
  padding-left: 0;
}

.editor-content ol {
  list-style-type: decimal;
  margin-left: 1.5rem;
  margin-bottom: 1rem;
  padding-left: 0;
}

.editor-content li {
  margin-bottom: 0.5rem;
  display: list-item;
  list-style-position: outside;
}

.editor-content ul ul {
  list-style-type: circle;
  margin-top: 0.5rem;
}

.editor-content ul ul ul {
  list-style-type: square;
}

.editor-content ol ol {
  list-style-type: lower-alpha;
  margin-top: 0.5rem;
}

.editor-content ol ol ol {
  list-style-type: lower-roman;
}

/* Placeholder cuando el editor está vacío */
.editor-content.show-placeholder::before {
  content: attr(data-placeholder-main);
  color: #9ca3af;
  font-style: italic;
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

.editor-content.show-placeholder::after {
  content: attr(data-placeholder-tip);
  color: #9ca3af;
  font-size: 0.875rem;
  font-style: italic;
  pointer-events: none;
  position: absolute;
  top: 2rem;
  left: 0;
  font-weight: 400;
  z-index: 1;
}

/* Scrollbar personalizado */
.editor-content::-webkit-scrollbar {
  width: 8px;
}

.editor-content::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 4px;
}

.editor-content::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.editor-content::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Resaltados de premisas y conclusiones */
.highlight-premise {
  background: linear-gradient(120deg, #dbeafe 0%, #bfdbfe 100%);
  border-bottom: 2px solid var(--primary-color);
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.highlight-conclusion {
  background: linear-gradient(120deg, #fef3c7 0%, #fde68a 100%);
  border-bottom: 2px solid var(--secondary-color);
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.highlight-active {
  outline: 2px solid var(--danger-color);
  outline-offset: 2px;
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
}

/* Panel de recomendaciones */
.recommendation-card {
  padding: 1.5rem;
  background: linear-gradient(to right, #f9fafb, white);
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  transition: all 0.2s;
  cursor: pointer;
  border-left: 4px solid transparent;
  min-height: 160px;
  max-width: 100%;
}

.recommendation-card:hover {
  transform: translateY(-2px);
  border-left-color: var(--primary-color);
}

.recommendation-card.premise {
  border-left-color: var(--primary-color);
}

.recommendation-card.conclusion {
  border-left-color: var(--secondary-color);
}

.recommendation-card .type-badge {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 9999px;
  color: white;
}

.recommendation-card .leer-mas {
  color: #2563eb;
  transition: color 0.2s;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
}

.recommendation-card .leer-mas:hover {
  color: #1d4ed8;
}

.recommendation-card.premise .type-badge {
  background: var(--primary-color);
}

.recommendation-card.conclusion .type-badge {
  background: var(--secondary-color);
}

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal {
  background: var(--bg-primary);
  border-radius: 12px;
  max-width: 90%;
  max-height: 80%;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(to right, #f9fafb, white);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
}

.modal-close {
  font-size: 1.5rem;
  color: #9ca3af;
  transition: color 0.2s;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-close:hover {
  color: #4b5563;
}

.modal-close:hover {
  background: var(--bg-secondary);
}

.modal-content {
  padding: 1.5rem;
  color: #1f2937;
  line-height: 1.75;
  max-height: 400px;
  overflow-y: auto;
}

/* Loading overlay */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-spinner {
  text-align: center;
}

.spinner {
  width: 4rem;
  height: 4rem;
  border: 4px solid white;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

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

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

/* Estados de la API */
.api-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.api-status.connected {
  color: #059669;
}

.api-status.connected .status-dot {
  background-color: #10b981;
}

.api-status.disconnected {
  color: #dc2626;
}

.api-status.disconnected .status-dot {
  background-color: #ef4444;
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Responsive design */
@media (max-width: 768px) {
  .toolbar-btn {
    padding: 0.5rem 0.25rem;
    font-size: 0.875rem;
    min-width: 36px;
  }
  
  .analyze-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
  
  .editor-content {
    font-size: 1rem;
    min-height: 300px;
  }
  
  .modal {
    margin: 1rem;
    max-width: calc(100% - 2rem);
  }
}

/* Mejoras de accesibilidad */
.toolbar-btn:focus-visible,
.analyze-btn:focus-visible,
.modal-close:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Estados de hover mejorados */
.recommendation-card:hover .leer-mas {
  color: #1d4ed8;
  text-decoration: underline;
}

/* Mejor distribución del contenido en tarjetas más anchas */
.recommendation-card p {
  line-height: 1.75;
}

.recommendation-card .text-gray-600 {
  font-size: 1rem;
}

.recommendation-card .text-gray-800 {
  font-size: 1.125rem;
}

/* Contador de palabras */
.word-count {
  font-size: 0.875rem;
  color: #6b7280;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

/* Footer del análisis */
.analysis-footer {
  background: linear-gradient(to right, #eff6ff, #eef2ff);
  border-top: 1px solid #bfdbfe;
}

.premise-indicator,
.conclusion-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.premise-indicator .indicator-dot {
  width: 0.75rem;
  height: 0.75rem;
  background-color: #3b82f6;
  border-radius: 50%;
}

.conclusion-indicator .indicator-dot {
  width: 0.75rem;
  height: 0.75rem;
  background-color: #f59e0b;
  border-radius: 50%;
}

