/*
 * Estilos para el plugin Moodle Docente Auto
 * Mejoras de UX para backend y frontend
 * Version: 2.4
 */

/* ========================================
   ESTILOS DEL BACKEND (Administración)
   ======================================== */

/* Contenedor principal del panel de admin */
.moodle-docente-admin-wrap {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
    overflow: hidden;
}

/* Header del panel */
.moodle-docente-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
    position: relative;
}

.moodle-docente-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="2" fill="rgba(255,255,255,0.1)"/><circle cx="80" cy="40" r="1.5" fill="rgba(255,255,255,0.1)"/><circle cx="40" cy="70" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="90" cy="80" r="2.5" fill="rgba(255,255,255,0.1)"/></svg>') repeat;
    opacity: 0.3;
}

.moodle-docente-header h1 {
    margin: 0;
    font-size: 2.5em;
    font-weight: 300;
    position: relative;
    z-index: 1;
}

.moodle-docente-header .subtitle {
    margin: 10px 0 0;
    opacity: 0.9;
    font-size: 1.1em;
    position: relative;
    z-index: 1;
}

/* Contenido del formulario */
.moodle-docente-content {
    padding: 40px;
}

/* Tarjetas de configuración */
.moodle-config-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.moodle-config-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.moodle-config-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.moodle-config-card h3 {
    margin: 0 0 20px;
    color: #495057;
    font-size: 1.3em;
    display: flex;
    align-items: center;
}

.moodle-config-card h3::before {
    content: "⚙️";
    margin-right: 10px;
    font-size: 1.2em;
}

/* Campos de formulario mejorados */
.moodle-form-field {
    margin-bottom: 20px;
}

.moodle-form-field label {
    display: block;
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.moodle-form-field input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    background-color: white;
}

.moodle-form-field input[type="text"]:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

/* Botón de guardar mejorado */
.moodle-save-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.moodle-save-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

/* Sección de documentación */
.moodle-docs-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-top: 30px;
    border: 1px solid #e9ecef;
}

.moodle-docs-section h2 {
    color: #495057;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
    margin-bottom: 25px;
}

.moodle-shortcode-example {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    padding: 20px;
    margin: 15px 0;
    border-radius: 0 8px 8px 0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    overflow-x: auto;
}

.moodle-param-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.moodle-param-table th,
.moodle-param-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.moodle-param-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.moodle-param-table tr:hover {
    background: #f8f9fa;
}

/* Status indicators */
.moodle-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.moodle-status.required {
    background: #ff6b6b;
    color: white;
}

.moodle-status.optional {
    background: #51cf66;
    color: white;
}

/* ========================================
   ESTILOS DEL FRONTEND (Botones)
   ======================================== */

/* Botón principal del curso */
.moodle-docente-btn {
    position: relative;
    display: inline-block;
    padding: 14px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    text-decoration: none !important;
    border-radius: 50px;
    font-weight: 600;
    
    letter-spacing: 1px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    overflow: hidden;
    min-width: 160px;
    text-align: center;
}

/* Efecto de hover */
.moodle-docente-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.moodle-docente-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    color: white !important;
}

.moodle-docente-btn:hover::before {
    left: 100%;
}

/* Estado de carga */
.moodle-docente-btn.is-loading {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

.moodle-docente-btn.is-loading::before {
    display: none;
}

/* Spinner de carga */
.moodle-docente-btn.is-loading::after {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    display: inline-block;
    animation: spin 1s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Variantes de botón */
.moodle-docente-btn.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.moodle-docente-btn.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.moodle-docente-btn.btn-warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
}

.moodle-docente-btn.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
}

/* Botón pequeño */
.moodle-docente-btn.btn-sm {
    padding: 10px 20px;
    font-size: 12px;
    min-width: 120px;
}

/* Botón grande */
.moodle-docente-btn.btn-lg {
    padding: 18px 36px;
    font-size: 16px;
    min-width: 200px;
}

/* Mensaje de error/login */
.moodle-login-message {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: #721c24;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
    margin: 20px 0;
    border: 1px solid rgba(114, 28, 36, 0.1);
}

.moodle-login-message::before {
    content: "🔐";
    margin-right: 10px;
    font-size: 1.2em;
}

/* ========================================
   TOOLTIPS PERSONALIZADOS MEJORADOS
   ======================================== */

/* Prevenir tooltip nativo del navegador para botones con tooltip personalizado */
.moodle-docente-btn.has-custom-tooltip:hover {
    /* El JavaScript manejará el tooltip personalizado */
}

/* Estilos para tooltips mejorados */
.moodle-enhanced-tooltip {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.4;
    text-align: center;
}

/* Animación de entrada para tooltips */
.moodle-enhanced-tooltip {
    animation: tooltipFadeIn 0.3s ease-out;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Indicador visual para botones con tooltip personalizado */
.moodle-docente-btn.has-custom-tooltip::after {
    content: "";
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    border: 2px solid white;
    opacity: 0.8;
    animation: tooltipIndicator 2s ease-in-out infinite;
}

@keyframes tooltipIndicator {
    0%, 100% { 
        transform: scale(1); 
        opacity: 0.8; 
    }
    50% { 
        transform: scale(1.2); 
        opacity: 1; 
    }
}

/* Ocultar indicador en hover para no distraer */
.moodle-docente-btn.has-custom-tooltip:hover::after {
    opacity: 0;
}

/* Responsive design */
@media (max-width: 768px) {
    .moodle-docente-content {
        padding: 20px;
    }
    
    .moodle-config-card {
        padding: 20px;
    }
    
    .moodle-docente-header {
        padding: 20px;
    }
    
    .moodle-docente-header h1 {
        font-size: 2em;
    }
    
    .moodle-form-field input[type="text"] {
        font-size: 16px; /* Previene zoom en iOS */
    }
    
    .moodle-docente-btn {
        width: 100%;
        margin: 10px 0;
    }
    
    .moodle-param-table {
        font-size: 14px;
    }
    
    .moodle-param-table th,
    .moodle-param-table td {
        padding: 8px 10px;
    }
    
    /* Responsive tooltips */
    .moodle-enhanced-tooltip {
        max-width: 200px !important;
        font-size: 12px !important;
        padding: 10px 12px !important;
    }
}

/* Animaciones suaves */
@media (prefers-reduced-motion: no-preference) {
    .moodle-config-card,
    .moodle-docente-btn,
    .moodle-form-field input {
        transition: all 0.3s ease;
    }
}

/* Modo oscuro (respeta preferencias del usuario) */
@media (prefers-color-scheme: dark) {
    .moodle-config-card {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .moodle-config-card h3 {
        color: #e2e8f0;
    }
    
    .moodle-form-field input[type="text"] {
        background: #4a5568;
        border-color: #6b7280;
        color: #e2e8f0;
    }
    
    .moodle-docs-section {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .moodle-shortcode-example {
        background: #374151;
        border-color: #667eea;
        color: #e2e8f0;
    }
    
    /* Modo oscuro para tooltips */
    .moodle-enhanced-tooltip {
        background: rgba(45, 55, 72, 0.95) !important;
        border-color: #4a5568 !important;
    }
}d #e9ecef;
}

.moodle-param-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.moodle-param-table tr:hover {
    background: #f8f9fa;
}

/* Status indicators */
.moodle-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.moodle-status.required {
    background: #ff6b6b;
    color: white;
}

.moodle-status.optional {
    background: #51cf66;
    color: white;
}

/* ========================================
   ESTILOS DEL FRONTEND (Botones)
   ======================================== */

/* Botón principal del curso */
.moodle-docente-btn {
    position: relative;
    display: inline-block;
    padding: 14px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    text-decoration: none !important;
    border-radius: 50px;
    font-weight: 600;
    letter-spacing: 1px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    overflow: hidden;
    min-width: 160px;
    text-align: center;
}

/* Efecto de hover */
.moodle-docente-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.moodle-docente-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    color: white !important;
}

.moodle-docente-btn:hover::before {
    left: 100%;
}

/* Estado de carga */
.moodle-docente-btn.is-loading {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

.moodle-docente-btn.is-loading::before {
    display: none;
}

/* Spinner de carga */
.moodle-docente-btn.is-loading::after {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    display: inline-block;
    animation: spin 1s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Variantes de botón */
.moodle-docente-btn.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.moodle-docente-btn.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.moodle-docente-btn.btn-warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
}

.moodle-docente-btn.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
}

/* Botón pequeño */
.moodle-docente-btn.btn-sm {
    padding: 10px 20px;
    font-size: 12px;
    min-width: 120px;
}

/* Botón grande */
.moodle-docente-btn.btn-lg {
    padding: 18px 36px;
    font-size: 16px;
    min-width: 200px;
}

/* Mensaje de error/login */
.moodle-login-message {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: #721c24;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
    margin: 20px 0;
    border: 1px solid rgba(114, 28, 36, 0.1);
}

.moodle-login-message::before {
    content: "🔐";
    margin-right: 10px;
    font-size: 1.2em;
}

/* Responsive design */
@media (max-width: 768px) {
    .moodle-docente-content {
        padding: 20px;
    }
    
    .moodle-config-card {
        padding: 20px;
    }
    
    .moodle-docente-header {
        padding: 20px;
    }
    
    .moodle-docente-header h1 {
        font-size: 2em;
    }
    
    .moodle-form-field input[type="text"] {
        font-size: 16px; /* Previene zoom en iOS */
    }
    
    .moodle-docente-btn {
        width: 100%;
        margin: 10px 0;
    }
    
    .moodle-param-table {
        font-size: 14px;
    }
    
    .moodle-param-table th,
    .moodle-param-table td {
        padding: 8px 10px;
    }
}

/* Animaciones suaves */
@media (prefers-reduced-motion: no-preference) {
    .moodle-config-card,
    .moodle-docente-btn,
    .moodle-form-field input {
        transition: all 0.3s ease;
    }
}

/* Modo oscuro (respeta preferencias del usuario) */
@media (prefers-color-scheme: dark) {
    .moodle-config-card {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .moodle-config-card h3 {
        color: #e2e8f0;
    }
    
    .moodle-form-field input[type="text"] {
        background: #4a5568;
        border-color: #6b7280;
        color: #e2e8f0;
    }
    
    .moodle-docs-section {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .moodle-shortcode-example {
        background: #374151;
        border-color: #667eea;
        color: #e2e8f0;
    }
}

/* FIX URGENTE: Mostrar tabla del formulario en la página de configuración */
.wrap form table.form-table {
    display: table !important;
}

/* Y asegurar que el botón sea visible */
#test-connection-btn {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: #0073aa !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 4px !important;
    cursor: pointer !important;
}

.btn-curso-reg-ingreso-v2 {
    padding: 7px 10px 5px !important; 
}	