/**
 * Estilos para Sistema de Ayuda
 * Archivo: assets/css/ayuda/ayuda.css
 * Versión: 1.1 - Modal de guías corregido
 */

/* ========================================
   VARIABLES Y CONFIGURACIÓN BASE
   ======================================== */

:root {
    --ayuda-primary: #667eea;
    --ayuda-primary-hover: #5a67d8;
    --ayuda-secondary: #6c757d;
    --ayuda-success: #28a745;
    --ayuda-info: #17a2b8;
    --ayuda-warning: #ffc107;
    --ayuda-danger: #dc3545;
    --ayuda-light: #f8f9fa;
    --ayuda-dark: #343a40;
    --ayuda-border: #e9ecef;
}

/* ========================================
   RESET Y BASE
   ======================================== */

/* Ocultar elementos del tema */
#main-header, .site-header, .ast-breadcrumbs-wrapper {
    display: none !important;
}

body.logged-in .site {
    padding-top: 0 !important;
}

.site-content, #primary, .entry-content {
    padding: 0 !important;
    margin: 0 !important;
}

/* ========================================
   LAYOUT PRINCIPAL
   ======================================== */

.ayuda-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto;
}

/* ========================================
   BARRA LATERAL
   ======================================== */

.ayuda-sidebar {
    width: 15px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: #f0f0f0;
    z-index: 1000;
    transition: all 0.3s ease;
    overflow: hidden;
}

.ayuda-sidebar:hover {
    width: 280px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    background: #ffffff;
}

.sidebar-toggle {
    width: 15px;
    height: 100vh;
    position: absolute;
    cursor: pointer;
    z-index: 1001;
    background: linear-gradient(to right, #ddd 0%, transparent 100%);
}

.sidebar-toggle::after {
    content: '›';
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: 18px;
    font-weight: bold;
}

.ayuda-sidebar:hover .sidebar-toggle::after {
    content: '‹';
}

.sidebar-content {
    width: 280px;
    padding: 20px 10px;
    margin-left: 15px;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.sidebar-content h3 {
    font-size: 14px;
    color: var(--ayuda-primary);
    margin-bottom: 10px;
    margin-top: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--ayuda-primary);
}

.sidebar-content h3:first-child {
    margin-top: 0;
}

.sidebar-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-content li {
    margin-bottom: 4px;
}

.sidebar-content a {
    color: #333;
    text-decoration: none;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.sidebar-content a:hover {
    background: #f0f4f8;
    color: var(--ayuda-primary);
    transform: translateX(5px);
}

.sidebar-content a.activo {
    background: var(--ayuda-primary);
    color: white !important;
    font-weight: bold;
}

#stats-sidebar {
    background: var(--ayuda-light);
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    margin: 10px 0;
}

#stats-sidebar p {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
}

#stats-sidebar strong {
    color: var(--ayuda-primary);
    font-weight: bold;
}

/* ========================================
   CONTENIDO PRINCIPAL
   ======================================== */

.ayuda-main {
    flex: 1;
    margin-left: 15px;
    transition: margin-left 0.3s ease;
    max-width: calc(100vw - 15px);
}

.ayuda-sidebar:hover ~ .ayuda-main {
    margin-left: 10px;
}

.ayuda-header {
    background: linear-gradient(135deg, var(--ayuda-primary) 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 12px;
    margin: 20px;
    text-align: center;
}

.ayuda-header h1 {
    margin: 0 0 10px 0;
    font-size: 28px;
}

.ayuda-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 16px;
}

/* ========================================
   SECCIONES
   ======================================== */

.ayuda-seccion {
    display: none;
}

.ayuda-seccion.activa {
    display: block;
}

/* ========================================
   MENSAJES
   ======================================== */

.ayuda-mensaje {
    padding: 12px 20px;
    border-radius: 6px;
    margin: 20px;
    animation: fadeIn 0.3s ease;
}

.ayuda-mensaje.exito {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.ayuda-mensaje.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.ayuda-mensaje.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ========================================
   CONTROLES Y TABS
   ======================================== */

.ayuda-controles {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin: 0 20px 20px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.ayuda-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.ayuda-tab {
    padding: 12px 20px;
    background: var(--ayuda-light);
    border: none;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    font-size: 14px;
}

.ayuda-tab:hover {
    background: #e0f4ff;
    color: var(--ayuda-primary);
}

.ayuda-tab.activo {
    background: var(--ayuda-primary);
    color: white;
}

/* ========================================
   FORMULARIOS
   ======================================== */

.ayuda-formulario {
    background: white;
    border-radius: 8px;
    padding: 25px;
    margin: 0 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.ayuda-grupo {
    margin-bottom: 20px;
}

.ayuda-label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
    font-size: 14px;
}

.ayuda-input,
.ayuda-textarea,
.ayuda-select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--ayuda-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.ayuda-input:focus,
.ayuda-textarea:focus,
.ayuda-select:focus {
    outline: none;
    border-color: var(--ayuda-primary);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.ayuda-textarea {
    min-height: 120px;
    resize: vertical;
}

.ayuda-codigo {
    font-family: 'Monaco', 'Consolas', monospace;
    background: var(--ayuda-light);
    min-height: 150px;
}

.ayuda-grid-form {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* ========================================
   LISTADO DE ENTRADAS
   ======================================== */

.ayuda-listado {
    margin: 0 20px;
}

.ayuda-filtros {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.ayuda-filtros-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.ayuda-buscar {
    grid-column: 1 / -1;
    position: relative;
}

.ayuda-buscar input {
    padding-left: 40px;
}

.ayuda-buscar::before {
    content: '🔍';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    pointer-events: none;
}

.ayuda-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.ayuda-entrada {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid transparent;
}

.ayuda-entrada:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.ayuda-entrada.prioridad-critica {
    border-left-color: var(--ayuda-danger);
}

.ayuda-entrada.prioridad-alta {
    border-left-color: #ff6b6b;
}

.ayuda-entrada.prioridad-media {
    border-left-color: var(--ayuda-warning);
}

.ayuda-entrada.prioridad-baja {
    border-left-color: var(--ayuda-success);
}

.ayuda-entrada-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.ayuda-entrada-titulo {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
    flex: 1;
    cursor: pointer;
    transition: color 0.2s;
}

.ayuda-entrada-titulo:hover {
    color: var(--ayuda-primary);
}

.ayuda-entrada-categoria {
    background: #e3f2fd;
    color: #1976d2;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.ayuda-entrada-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 12px;
    color: #666;
}

.ayuda-prioridad {
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.ayuda-prioridad.alta { background: #ffebee; color: #c62828; }
.ayuda-prioridad.media { background: #fff3e0; color: #ef6c00; }
.ayuda-prioridad.baja { background: #e8f5e8; color: #2e7d32; }
.ayuda-prioridad.critica { background: #fce4ec; color: #ad1457; }

.ayuda-entrada-contenido {
    margin-bottom: 15px;
}

.ayuda-problema {
    background: #fff8e1;
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid var(--ayuda-warning);
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
}

.ayuda-solucion {
    background: #f3e5f5;
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid #9c27b0;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
}

.ayuda-codigo-preview {
    background: var(--ayuda-light);
    border: 1px solid var(--ayuda-border);
    border-radius: 6px;
    padding: 10px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #666;
}

.ayuda-etiquetas {
    margin-top: 15px;
}

.ayuda-etiqueta {
    background: #e1f5fe;
    color: #01579b;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    margin-right: 5px;
    display: inline-block;
    margin-bottom: 3px;
}

.ayuda-acciones {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

/* ========================================
   BOTONES
   ======================================== */

.ayuda-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    text-align: center;
}

.ayuda-btn-primario {
    background: var(--ayuda-primary);
    color: white;
}

.ayuda-btn-primario:hover {
    background: var(--ayuda-primary-hover);
    color: white;
    transform: translateY(-1px);
}

.ayuda-btn-secundario {
    background: var(--ayuda-secondary);
    color: white;
}

.ayuda-btn-secundario:hover {
    background: #5a6268;
    color: white;
}

.ayuda-btn-pequeño {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
}

.ayuda-btn-ver {
    background: var(--ayuda-info);
    color: white;
}

.ayuda-btn-ver:hover {
    background: #138496;
    color: white;
}

.ayuda-btn-eliminar {
    background: var(--ayuda-danger);
    color: white;
}

.ayuda-btn-eliminar:hover {
    background: #c82333;
    color: white;
}

/* ========================================
   MODAL - CORREGIDO PARA GUÍAS
   ======================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 95vw;
    max-height: 95vh;
    width: 1200px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    transform: scale(0.9);
    animation: scaleIn 0.3s ease forwards;
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--ayuda-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--ayuda-light);
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.btn-cerrar {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.btn-cerrar:hover {
    background: #f0f0f0;
    color: var(--ayuda-danger);
}

#modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* Contenido con índice específico para guías */
.modal-body-con-indice {
    display: flex;
    gap: 20px;
    height: 100%;
    min-height: 500px;
}

.indice-container {
    flex: 0 0 250px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
    max-height: 70vh;
    position: sticky;
    top: 0;
}

.indice-container h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--ayuda-primary);
    font-size: 16px;
}

.contenido-container {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding-right: 10px;
}

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

.indice-lista li {
    margin-bottom: 8px;
}

.indice-link {
    color: #333;
    text-decoration: none;
    font-size: 14px;
    display: block;
    padding: 6px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1.3;
}

.indice-link:hover {
    background: #e3f2fd;
    color: var(--ayuda-primary);
}

/* Estilos para el contenido procesado de las guías */
.contenido-container h1,
.contenido-container h2,
.contenido-container h3,
.contenido-container h4 {
    color: #333;
    margin-top: 25px;
    margin-bottom: 15px;
    line-height: 1.3;
}

.contenido-container h1 {
    font-size: 24px;
    border-bottom: 2px solid var(--ayuda-primary);
    padding-bottom: 10px;
}

.contenido-container h2 {
    font-size: 20px;
    color: var(--ayuda-primary);
}

.contenido-container h3 {
    font-size: 18px;
    color: #555;
}

.contenido-container h4 {
    font-size: 16px;
    color: #666;
}

.contenido-container pre {
    background: #f4f4f4;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    border-left: 4px solid var(--ayuda-primary);
    font-size: 13px;
    line-height: 1.4;
}

.contenido-container code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: Monaco, Consolas, monospace;
    font-size: 85%;
}

.contenido-container p {
    line-height: 1.6;
    margin-bottom: 15px;
}

.contenido-container ul,
.contenido-container ol {
    margin-bottom: 15px;
    padding-left: 25px;
}

.contenido-container li {
    margin-bottom: 5px;
}

/* Modal para problemas (más simple) */
.modal-seccion {
    margin-bottom: 25px;
}

.modal-seccion h3 {
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--ayuda-border);
}

.modal-codigo {
    background: var(--ayuda-light);
    padding: 20px;
    border-radius: 6px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    overflow-x: auto;
    white-space: pre-wrap;
    border: 1px solid var(--ayuda-border);
}

/* ========================================
   LOADING Y ESTADOS VACÍOS
   ======================================== */

.ayuda-loading {
    text-align: center;
    padding: 60px;
    color: #666;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--ayuda-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.ayuda-vacio {
    text-align: center;
    padding: 60px;
    color: #666;
}

.ayuda-vacio-icono {
    font-size: 48px;
    display: block;
    margin-bottom: 20px;
    opacity: 0.3;
}

/* ========================================
   PAGINACIÓN
   ======================================== */

.ayuda-paginacion {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 30px 0;
}

.ayuda-paginacion button {
    padding: 8px 12px;
    border: 1px solid var(--ayuda-border);
    background: white;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.ayuda-paginacion button:hover {
    background: var(--ayuda-light);
}

.ayuda-paginacion button.activo {
    background: var(--ayuda-primary);
    color: white;
    border-color: var(--ayuda-primary);
}

.ayuda-paginacion button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   ANIMACIONES
   ======================================== */

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

@keyframes scaleIn {
    from { transform: scale(0.9); }
    to { transform: scale(1); }
}

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

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .ayuda-sidebar { width: 0; }
    .ayuda-sidebar:hover { width: 250px; }
    .ayuda-main { margin-left: 0; }
    
    .ayuda-header {
        margin: 10px;
        padding: 20px;
    }
    
    .ayuda-controles,
    .ayuda-formulario,
    .ayuda-listado {
        margin: 10px;
    }
    
    .ayuda-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .ayuda-grid-form {
        grid-template-columns: 1fr;
    }
    
    .ayuda-filtros-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 10px;
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
    }
    
    .modal-body-con-indice {
        flex-direction: column;
    }
    
    .indice-container {
        flex: none;
        max-height: 200px;
        margin-bottom: 15px;
    }
    
    #modal-body {
        padding: 15px;
    }
    
    .ayuda-entrada-header {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .ayuda-header h1 {
        font-size: 24px;
    }
    
    .ayuda-tabs {
        flex-direction: column;
    }
    
    .ayuda-tab {
        border-radius: 6px;
    }
    
    .ayuda-acciones {
        flex-direction: column;
    }
    
    .modal-content {
        width: 100%;
        height: 100%;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
}