/* css/markdown_viewer.css - Estilos para el visor de markdown integrado */

/* Modal base */
.modal-overlay.markdown-viewer {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10000;
}

.markdown-modal-container {
  width: 90vw;
  height: 90vh;
  max-width: 1400px;
  background: white;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  position: relative;
}

/* Header */
.markdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 16px 16px 0 0;
}

.markdown-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.doc-selector {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  color: #333;
  min-width: 300px;
  cursor: pointer;
  font-size: 14px;
}

.doc-selector:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.markdown-controls {
  display: flex;
  gap: 8px;
}

.control-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.control-btn.active {
  background: rgba(255, 255, 255, 0.4);
}

.control-btn.close {
  background: #e74c3c;
  font-size: 20px;
  font-weight: bold;
}

.control-btn.close:hover {
  background: #c0392b;
}

/* Body */
.markdown-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.markdown-sidebar {
  width: 300px;
  background: #f8f9fa;
  border-right: 1px solid #e9ecef;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.markdown-sidebar.hidden {
  transform: translateX(-100%);
  margin-right: -300px;
}

.toc-header {
  padding: 20px 20px 10px 20px;
  border-bottom: 1px solid #e9ecef;
}

.toc-header h3 {
  margin: 0;
  color: #495057;
  font-size: 16px;
}

.toc-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list li {
  margin: 0;
}

.toc-link {
  display: block;
  padding: 8px 20px;
  color: #495057;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
  transition: all 0.2s ease;
}

.toc-link:hover {
  background: #e9ecef;
  color: #007bff;
  padding-left: 24px;
}

.toc-level-1 .toc-link {
  font-weight: 600;
  font-size: 15px;
}

.toc-level-2 .toc-link {
  padding-left: 32px;
}

.toc-level-3 .toc-link {
  padding-left: 44px;
  font-size: 13px;
}

.toc-level-4 .toc-link {
  padding-left: 56px;
  font-size: 12px;
}

.document-list {
  border-top: 1px solid #e9ecef;
  padding: 20px;
}

.document-list h4 {
  margin: 0 0 15px 0;
  color: #495057;
  font-size: 14px;
  font-weight: 600;
}

.related-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 8px;
}

.related-doc:hover {
  background: #e9ecef;
}

.doc-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.doc-info {
  flex: 1;
}

.doc-name {
  font-weight: 500;
  font-size: 13px;
  color: #495057;
  margin-bottom: 2px;
}

.doc-desc {
  font-size: 11px;
  color: #6c757d;
  line-height: 1.3;
}

/* Content */
.markdown-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.loading-spinner {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #6c757d;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

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

.markdown-rendered {
  flex: 1;
  overflow-y: auto;
  padding: 40px 60px;
  background: white;
  line-height: 1.7;
  color: #333;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Markdown content styles */
.markdown-rendered h1 {
  font-size: 2.2em;
  color: #2c3e50;
  margin: 0 0 24px 0;
  padding-bottom: 12px;
  border-bottom: 3px solid #3498db;
  font-weight: 700;
}

.markdown-rendered h2 {
  font-size: 1.8em;
  color: #34495e;
  margin: 32px 0 20px 0;
  font-weight: 600;
  position: relative;
}

.markdown-rendered h2::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  background: #3498db;
  border-radius: 2px;
}

.markdown-rendered h3 {
  font-size: 1.4em;
  color: #2c3e50;
  margin: 24px 0 16px 0;
  font-weight: 600;
}

.markdown-rendered h4 {
  font-size: 1.2em;
  color: #34495e;
  margin: 20px 0 12px 0;
  font-weight: 600;
}

.markdown-rendered p {
  margin: 16px 0;
  text-align: justify;
}

.markdown-rendered ul, 
.markdown-rendered ol {
  margin: 16px 0;
  padding-left: 24px;
}

.markdown-rendered li {
  margin: 8px 0;
  line-height: 1.6;
}

.markdown-rendered li strong {
  color: #2c3e50;
}

.markdown-rendered blockquote {
  margin: 24px 0;
  padding: 16px 24px;
  background: #f8f9fa;
  border-left: 4px solid #3498db;
  border-radius: 0 8px 8px 0;
  font-style: italic;
}

.markdown-rendered code {
  background: #f1f3f4;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Fira Code', Monaco, 'Cascadia Code', monospace;
  font-size: 0.9em;
  color: #e74c3c;
}

.markdown-rendered pre {
  background: #2c3e50;
  color: #ecf0f1;
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 20px 0;
  font-family: 'Fira Code', Monaco, 'Cascadia Code', monospace;
  line-height: 1.5;
}

.markdown-rendered pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 14px;
}

.markdown-rendered table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

.markdown-rendered th {
  background: #3498db;
  color: white;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
}

.markdown-rendered td {
  padding: 12px 16px;
  border-bottom: 1px solid #e9ecef;
}

.markdown-rendered tr:nth-child(even) {
  background: #f8f9fa;
}

.markdown-rendered tr:hover {
  background: #e3f2fd;
}

.markdown-rendered a {
  color: #3498db;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.markdown-rendered a:hover {
  color: #2980b9;
  text-decoration: underline;
}

.anchor-link {
  opacity: 0;
  font-size: 0.8em;
  margin-left: 8px;
  transition: opacity 0.2s ease;
}

.markdown-rendered h1:hover .anchor-link,
.markdown-rendered h2:hover .anchor-link,
.markdown-rendered h3:hover .anchor-link,
.markdown-rendered h4:hover .anchor-link,
.markdown-rendered h5:hover .anchor-link,
.markdown-rendered h6:hover .anchor-link {
  opacity: 0.7;
}

.anchor-link:hover {
  opacity: 1 !important;
}

/* Footer */
.markdown-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
  border-radius: 0 0 16px 16px;
}

.document-info {
  display: flex;
  gap: 20px;
  color: #6c757d;
  font-size: 14px;
}

.view-controls {
  display: flex;
  gap: 8px;
}

.view-btn {
  background: #6c757d;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.view-btn:hover {
  background: #495057;
  transform: translateY(-1px);
}

/* Responsive */
@media (max-width: 1024px) {
  .markdown-modal-container {
    width: 95vw;
    height: 95vh;
  }
  
  .markdown-sidebar {
    width: 250px;
  }
  
  .markdown-rendered {
    padding: 20px 30px;
  }
}

@media (max-width: 768px) {
  .markdown-header {
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }
  
  .markdown-nav {
    width: 100%;
    justify-content: center;
  }
  
  .doc-selector {
    min-width: 250px;
  }
  
  .markdown-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .markdown-sidebar:not(.hidden) {
    transform: translateX(0);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  }
  
  .markdown-rendered {
    padding: 20px;
  }
}

/* Tema oscuro */
.markdown-viewer.dark-theme .markdown-modal-container {
  background: #2c3e50;
  color: #ecf0f1;
}

.markdown-viewer.dark-theme .markdown-sidebar {
  background: #34495e;
  border-right-color: #4a6741;
}

.markdown-viewer.dark-theme .toc-header,
.markdown-viewer.dark-theme .document-list {
  border-color: #4a6741;
}

.markdown-viewer.dark-theme .toc-header h3,
.markdown-viewer.dark-theme .document-list h4 {
  color: #bdc3c7;
}

.markdown-viewer.dark-theme .toc-link {
  color: #bdc3c7;
}

.markdown-viewer.dark-theme .toc-link:hover {
  background: #4a6741;
  color: #3498db;
}

.markdown-viewer.dark-theme .related-doc:hover {
  background: #4a6741;
}

.markdown-viewer.dark-theme .doc-name {
  color: #bdc3c7;
}

.markdown-viewer.dark-theme .doc-desc {
  color: #95a5a6;
}

.markdown-viewer.dark-theme .markdown-rendered {
  background: #2c3e50;
  color: #ecf0f1;
}

.markdown-viewer.dark-theme .markdown-rendered h1,
.markdown-viewer.dark-theme .markdown-rendered h2,
.markdown-viewer.dark-theme .markdown-rendered h3,
.markdown-viewer.dark-theme .markdown-rendered h4 {
  color: #ecf0f1;
}

.markdown-viewer.dark-theme .markdown-rendered blockquote {
  background: #34495e;
  border-left-color: #3498db;
}

.markdown-viewer.dark-theme .markdown-rendered code {
  background: #34495e;
  color: #e74c3c;
}

.markdown-viewer.dark-theme .markdown-rendered table th {
  background: #34495e;
}

.markdown-viewer.dark-theme .markdown-rendered table td {
  border-bottom-color: #4a6741;
}

.markdown-viewer.dark-theme .markdown-rendered tr:nth-child(even) {
  background: #34495e;
}

.markdown-viewer.dark-theme .markdown-rendered tr:hover {
  background: #4a6741;
}

.markdown-viewer.dark-theme .markdown-footer {
  background: #34495e;
  border-top-color: #4a6741;
}

/* Pantalla completa */
.markdown-viewer.fullscreen .markdown-modal-container {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

.markdown-viewer.fullscreen .markdown-header {
  border-radius: 0;
}

.markdown-viewer.fullscreen .markdown-footer {
  border-radius: 0;
}

/* Animaciones */
.modal-overlay.markdown-viewer.show {
  animation: fadeInModal 0.3s ease;
}

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

.modal-overlay.markdown-viewer.show .markdown-modal-container {
  animation: slideInModal 0.3s ease;
}

@keyframes slideInModal {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Error message */
.error-message {
  text-align: center;
  padding: 60px 40px;
  color: #e74c3c;
}

.error-message h2 {
  margin-bottom: 16px;
}

.error-message button {
  background: #e74c3c;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 20px;
  transition: background 0.2s ease;
}

.error-message button:hover {
  background: #c0392b;
}