/**
 * Estilos del módulo NV Multi-AI Assistant.
 *
 * Estilos específicos para el modal del asistente IA,
 * el selector de proveedores, las plantillas y el panel
 * de configuración del módulo.
 *
 * @package NotoriusVision\OptimizadorPro
 * @since 1.0.0
 */

/* ============================================================
   BOTÓN DEL ASISTENTE IA
   ============================================================ */

.opnv-ai-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.4;
}

.opnv-ai-button:hover {
    background: #135e96;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.3);
    color: #fff;
}

.opnv-ai-button:active {
    transform: translateY(0);
}

.opnv-ai-button .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* ============================================================
   MODAL DEL ASISTENTE IA
   ============================================================ */

.opnv-ai-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: opnvFadeIn 0.2s ease;
    padding: 20px;
    box-sizing: border-box;
}

.opnv-ai-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Cabecera */
.opnv-ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.opnv-ai-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    padding: 0;
}

.opnv-ai-header .opnv-ai-provider-icon {
    font-size: 24px;
}

.opnv-ai-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.opnv-ai-close:hover {
    background: #e0e0e0;
    color: #333;
}

/* Cuerpo */
.opnv-ai-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Loader */
.opnv-ai-loader {
    text-align: center;
    padding: 40px 20px;
    color: #646970;
}

.opnv-ai-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: opnvSpin 0.8s linear infinite;
    margin: 0 auto 15px;
}

/* Secciones del modal */
.opnv-ai-section {
    margin-bottom: 24px;
}

.opnv-ai-section:last-child {
    margin-bottom: 0;
}

.opnv-ai-section label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1d2327;
    font-size: 14px;
}

.opnv-ai-section label .dashicons {
    color: #2271b1;
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Textareas */
.opnv-ai-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #c3c4c7;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.opnv-ai-textarea:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.1);
}

.opnv-ai-textarea[readonly] {
    background: #f6f7f7;
    color: #50575e;
    cursor: default;
}

/* Botones de acción dentro del modal */
.opnv-ai-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.opnv-ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    border: 1px solid #c3c4c7;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
    color: #1d2327;
    white-space: nowrap;
}

.opnv-ai-btn:hover {
    background: #f0f0f1;
}

.opnv-ai-btn .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.opnv-ai-btn-primary {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}

.opnv-ai-btn-primary:hover {
    background: #135e96;
    border-color: #135e96;
    color: #fff;
}

.opnv-ai-btn-copy {
    background: #f0f6fc;
    border-color: #2271b1;
    color: #2271b1;
}

.opnv-ai-btn-copy:hover {
    background: #e0edf8;
}

.opnv-ai-btn-open {
    background: #ecf7ed;
    border-color: #46b450;
    color: #1e7b26;
}

.opnv-ai-btn-open:hover {
    background: #d8f0da;
}

.opnv-ai-btn-seo {
    background: #fef7e0;
    border-color: #ffb900;
    color: #b06000;
}

.opnv-ai-btn-seo:hover {
    background: #fef0c0;
}

/* Botón copiado (feedback) */
.opnv-ai-btn.opnv-copied {
    background: #46b450 !important;
    border-color: #46b450 !important;
    color: #fff !important;
}

/* Previsualización */
.opnv-ai-preview {
    margin-top: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.opnv-ai-preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: #f0f6fc;
    border-bottom: 1px solid #e0e0e0;
}

.opnv-ai-preview-header h3 {
    margin: 0;
    font-size: 14px;
}

.opnv-ai-preview-header .dashicons {
    color: #2271b1;
}

.opnv-ai-preview-content {
    padding: 15px;
    max-height: 300px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.6;
}

/* Pie del modal */
.opnv-ai-footer {
    display: flex;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ============================================================
   SELECTOR DE PROVEEDORES EN EL MODAL
   ============================================================ */

.opnv-provider-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.opnv-provider-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
    background: #fff;
}

.opnv-provider-option:hover {
    border-color: #2271b1;
    background: #f0f6fc;
}

.opnv-provider-option.selected {
    border-color: #2271b1;
    background: #2271b1;
    color: #fff;
}

.opnv-provider-option .opnv-provider-icon {
    font-size: 18px;
}

/* ============================================================
   SELECTOR DE MODO DE SALIDA
   ============================================================ */

.opnv-mode-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.opnv-mode-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    flex: 1;
    min-width: 140px;
    max-width: 200px;
}

.opnv-mode-card:hover {
    border-color: #2271b1;
}

.opnv-mode-card.selected {
    border-color: #2271b1;
    background: #f0f6fc;
}

.opnv-mode-card input[type="radio"] {
    display: none;
}

.opnv-mode-card .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
    color: #2271b1;
}

.opnv-mode-card strong {
    font-size: 13px;
}

.opnv-mode-card .mode-desc {
    font-size: 10px;
    color: #646970;
    line-height: 1.3;
}

/* ============================================================
   EDITOR DE PLANTILLAS
   ============================================================ */

.opnv-template-editor {
    margin-bottom: 15px;
}

.opnv-template-editor textarea {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    tab-size: 4;
}

.opnv-quick-vars {
    margin-top: 10px;
    padding: 12px;
    background: #f6f7f7;
    border-radius: 6px;
}

.opnv-quick-vars label {
    display: block;
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 8px;
    color: #50575e;
}

.opnv-var-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.opnv-var-btn {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    padding: 3px 8px;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.opnv-var-btn:hover {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

/* ============================================================
   VISTA PREVIA DE PROMPT EN EDITOR
   ============================================================ */

.opnv-prompt-preview {
    margin-top: 15px;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.opnv-prompt-preview h3 {
    margin: 0 0 10px;
    font-size: 14px;
}

.opnv-prompt-preview pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #1d2327;
}

.opnv-prompt-preview mark {
    background: #fff3cd;
    padding: 1px 4px;
    border-radius: 2px;
}

.opnv-prompt-preview .unresolved {
    background: #fce8e6;
    color: #c5221f;
}

/* ============================================================
   TABLA DE PROVEEDORES EN PANEL
   ============================================================ */

.opnv-provider-icon-cell {
    text-align: center;
    vertical-align: middle;
}

.opnv-provider-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f0f6fc;
    font-size: 20px;
}

.opnv-provider-template-preview {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    color: #646970;
    font-family: monospace;
    background: #f6f7f7;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
    margin-top: 3px;
}

/* ============================================================
   ICONOS DE PROVEEDORES
   ============================================================ */

.opnv-icon-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.opnv-icon-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 70px;
}

.opnv-icon-option:hover {
    border-color: #2271b1;
}

.opnv-icon-option.selected {
    border-color: #2271b1;
    background: #f0f6fc;
}

.opnv-icon-option input {
    display: none;
}

.opnv-icon-emoji {
    font-size: 24px;
}

.opnv-icon-label {
    font-size: 10px;
    color: #666;
    text-align: center;
}

/* ============================================================
   PÁGINA DE LOGS DEL ASISTENTE
   ============================================================ */

.opnv-log-row.opnv-log-error {
    background: #fcf0f1 !important;
}

.opnv-log-row.opnv-log-critical {
    background: #fce8e6 !important;
}

.opnv-log-row.opnv-log-warning {
    background: #fef7e0 !important;
}

.opnv-log-timestamp {
    font-family: monospace;
    font-size: 12px;
    color: #50575e;
}

.opnv-log-provider {
    display: inline-block;
    background: #f0f6fc;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    color: #2271b1;
}

.opnv-log-details {
    font-size: 12px;
    color: #646970;
}

/* ============================================================
   FILTROS EN PÁGINA DE LOGS
   ============================================================ */

.opnv-filters-form {
    margin-bottom: 0;
}

.opnv-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.opnv-filter-item label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 12px;
    color: #50575e;
}

.opnv-filter-item select,
.opnv-filter-item input {
    width: 100%;
}

.opnv-filters-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

/* ============================================================
   GENERADOR DE SHORTCODES
   ============================================================ */

.opnv-shortcode-output {
    background: #f6f7f7;
    border: 1px solid #c3c4c7;
    border-radius: 6px;
    padding: 20px;
    text-align: center;
    margin-bottom: 10px;
}

.opnv-shortcode-output code {
    font-size: 16px;
    font-weight: 600;
    word-break: break-all;
}

/* ============================================================
   PROBADOR DE PLANTILLAS
   ============================================================ */

.opnv-template-tester-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
    align-items: start;
}

.opnv-variables-quick-list {
    max-height: 500px;
    overflow-y: auto;
}

/* ============================================================
   ASISTENTE IA AVANZADO (HEADER & SETTINGS)
   ============================================================ */

.opnv-asst-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(0,0,0,.08);
    background: rgba(0,0,0,.02);
}

.opnv-asst-title {
    font-weight: 700;
    font-size: 13px;
    color: #1d2327;
}

.opnv-asst-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.opnv-iconbtn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,.10);
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.opnv-iconbtn:hover {
    border-color: rgba(0,0,0,.18);
    background: #f6f7f7;
}

/* Drawer de settings dentro del panel */
.opnv-asst-settings {
    display: none;
    padding: 12px;
    border-bottom: 1px solid rgba(0,0,0,.08);
    background: #fff;
}

.opnv-asst-settings.open {
    display: block;
}

.opnv-asst-field {
    margin-bottom: 10px;
}

.opnv-asst-label {
    font-size: 12px;
    opacity: .8;
    margin-bottom: 6px;
    display: block;
    font-weight: 600;
}

.opnv-asst-select {
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 10px;
    background: #fff;
    font-size: 13px;
}

/* ============================================================
   DOCKING TIPO VSCODE & COMPATIBILIDAD
   ============================================================ */

#opnv-assistant-btn,
#opnv-assistant-panel {
    z-index: 999999999 !important;
}

/* Ajustes del body cuando está dockeado */
body.opnv-docked-left {
    padding-left: var(--opnv-dock-w, 380px) !important;
}

body.opnv-docked-right {
    padding-right: var(--opnv-dock-w, 380px) !important;
}

#opnv-assistant-panel.opnv-dock-left {
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: auto !important;
    height: 100vh !important;
    width: var(--opnv-dock-w, 380px) !important;
    border-radius: 0 !important;
}

#opnv-assistant-panel.opnv-dock-right {
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    bottom: auto !important;
    height: 100vh !important;
    width: var(--opnv-dock-w, 380px) !important;
    border-radius: 0 !important;
}

/* Resizer vertical (dock) */
.opnv-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 999999999;
    background: transparent;
}

#opnv-assistant-panel.opnv-dock-left .opnv-resize-handle {
    right: -3px;
}

#opnv-assistant-panel.opnv-dock-right .opnv-resize-handle {
    left: -3px;
}

/* Compatibilidad con Constructores Visuales */
.elementor-editor-active #opnv-assistant-panel,
.et-fb-active #opnv-assistant-panel {
    pointer-events: auto !important;
}

/* ============================================================
   ANIMACIONES
   ============================================================ */

@keyframes opnvFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes opnvSpin {
    to { transform: rotate(360deg); }
}

@keyframes opnvSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.opnv-ai-modal {
    animation: opnvSlideUp 0.3s ease;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 960px) {
    .opnv-template-tester-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .opnv-ai-overlay {
        padding: 10px;
    }

    .opnv-ai-modal {
        max-height: 95vh;
        border-radius: 8px;
    }

    .opnv-ai-header {
        padding: 15px 18px;
    }

    .opnv-ai-header h2 {
        font-size: 16px;
    }

    .opnv-ai-body {
        padding: 18px;
    }

    .opnv-ai-footer {
        padding: 12px 18px;
        flex-direction: column;
    }

    .opnv-ai-footer .opnv-ai-btn {
        width: 100%;
        justify-content: center;
    }

    .opnv-ai-textarea {
        font-size: 12px;
    }

    .opnv-mode-card {
        min-width: 100px;
        max-width: none;
        flex: 1 1 30%;
    }

    .opnv-filters-grid {
        grid-template-columns: 1fr;
    }

    .opnv-filters-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .opnv-ai-actions {
        flex-direction: column;
    }

    .opnv-ai-actions .opnv-ai-btn {
        width: 100%;
        justify-content: center;
    }

    .opnv-mode-selector {
        flex-direction: column;
    }

    .opnv-mode-card {
        max-width: none;
    }

    .opnv-provider-selector {
        flex-direction: column;
    }
}