/* enhancements.css - v1.1
   Estilos para las nuevas funciones cognitivas y de UX
   Cargar DESPUÉS de app.css */

/* ============================================================
   1. SUGERENCIAS DE PROMPT (chips iniciales)
   ============================================================ */
.prompt-suggestions {
    padding: 24px 16px;
    text-align: center;
}

.prompt-suggestions h3 {
    color: var(--text, #eee);
    margin-bottom: 16px;
    font-size: 1.1em;
    opacity: 0.85;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    max-width: 700px;
    margin: 0 auto;
}

.suggestion-chip {
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border, #2d2d3f);
    color: var(--text, #eee);
    padding: 12px 14px;
    border-radius: 14px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.suggestion-chip:hover {
    background: rgba(76,201,240,0.1);
    border-color: rgba(76,201,240,0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76,201,240,0.15);
}

.suggestion-chip .chip-icon {
    font-size: 1.3em;
    flex-shrink: 0;
}

.suggestion-chip .chip-text {
    flex: 1;
    overflow: hidden;
}

/* ============================================================
   2. BOTÓN DE VOZ
   ============================================================ */
.btn-voice {
    background: transparent;
    border: none;
    color: var(--text, #eee);
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 1em;
}

.btn-voice:hover {
    background: rgba(255,255,255,0.05);
}

.btn-voice.listening {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    animation: voicePulse 1.2s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,0.6); }
    50% { box-shadow: 0 0 0 8px rgba(231,76,60,0); }
}

/* ============================================================
   3. MENÚ DE COMANDOS SLASH
   ============================================================ */
.slash-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border, #2d2d3f);
    border-radius: 10px;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
    margin-bottom: 6px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 100;
}

.slash-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.slash-item:last-child {
    border-bottom: none;
}

.slash-item:hover {
    background: rgba(76,201,240,0.1);
}

.slash-icon {
    font-size: 1.2em;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.slash-command {
    font-weight: 600;
    color: var(--text, #eee);
    font-size: 0.95em;
}

.slash-desc {
    font-size: 0.8em;
    opacity: 0.6;
    margin-top: 2px;
}

/* ============================================================
   4. MOSTRAR RAZONAMIENTO
   ============================================================ */
.reasoning-display {
    background: rgba(76,201,240,0.05);
    border-left: 3px solid #4cc9f0;
    border-radius: 0 10px 10px 0;
    margin: 12px 0;
    overflow: hidden;
    font-size: 0.9em;
    transition: max-height 0.3s ease;
}

.reasoning-display.collapsed .reasoning-content {
    display: none;
}

.reasoning-display.collapsed .reasoning-header i {
    transform: rotate(-90deg);
}

.reasoning-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(76,201,240,0.1);
    cursor: pointer;
    color: #4cc9f0;
    font-weight: 600;
    user-select: none;
}

.reasoning-header i {
    transition: transform 0.2s;
}

.reasoning-content {
    padding: 10px 14px;
}

.reasoning-step {
    display: flex;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px dotted rgba(255,255,255,0.06);
}

.reasoning-step:last-child {
    border-bottom: none;
}

.reasoning-step-name {
    background: rgba(76,201,240,0.15);
    color: #4cc9f0;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 600;
    height: fit-content;
    white-space: nowrap;
    flex-shrink: 0;
}

.reasoning-step-content {
    color: var(--text, #eee);
    opacity: 0.85;
    font-size: 0.9em;
    line-height: 1.5;
}

/* ============================================================
   5. MARCADOR DE MENSAJES (hover)
   ============================================================ */
.bookmark-msg-btn {
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.bookmark-msg-btn:hover {
    background: rgba(76,201,240,0.2) !important;
    transform: scale(1.1);
}

/* ============================================================
   6. BOTONES ACTIVOS EN SIDEBAR
   ============================================================ */
.btn-thinking.active {
    background: rgba(76,201,240,0.2);
    border-color: rgba(76,201,240,0.5);
    color: #4cc9f0;
}

/* ============================================================
   7. ONBOARDING (pantalla de bienvenida)
   ============================================================ */
#onboarding-overlay {
    animation: fadeIn 0.4s ease;
}

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

/* ============================================================
   8. AGENTE DE PÁGINAS ESTÁTICAS - Panel de resultado
   ============================================================ */
.static-page-result {
    background: linear-gradient(135deg, rgba(76,201,240,0.08), rgba(114,239,221,0.05));
    border: 1px solid rgba(76,201,240,0.25);
    border-radius: 14px;
    padding: 18px;
    margin-top: 8px;
}

.spr-header h3 {
    margin: 0 0 6px;
    color: #4cc9f0;
    font-size: 1.1em;
}

.spr-desc {
    margin: 0 0 12px;
    opacity: 0.75;
    font-size: 0.9em;
    font-style: italic;
}

.spr-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85em;
    opacity: 0.85;
    margin-bottom: 14px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
}

.spr-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.spr-btn {
    border: none;
    padding: 9px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.88em;
    font-family: inherit;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.spr-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.spr-btn-primary {
    background: linear-gradient(135deg, #4cc9f0, #3aa8d8);
    color: #0a0a1a;
    font-weight: 600;
}

.spr-btn-secondary {
    background: rgba(114,239,221,0.15);
    color: #72efdd;
    border: 1px solid rgba(114,239,221,0.3);
}

.spr-btn-tertiary {
    background: rgba(255,255,255,0.08);
    color: var(--text, #eee);
    border: 1px solid var(--border, #2d2d3f);
}

.spr-btn-ghost {
    background: transparent;
    color: var(--text, #eee);
    border: 1px solid var(--border, #2d2d3f);
    opacity: 0.75;
}

.spr-btn-ghost:hover {
    opacity: 1;
}

.spr-btn-warn {
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
    border: 1px solid rgba(243, 156, 18, 0.3);
}

.spr-btn-warn:hover {
    background: rgba(243, 156, 18, 0.25);
}

.spr-iteration-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.78em;
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
    border: 1px solid rgba(243, 156, 18, 0.3);
    margin-left: 4px;
}

.spr-iteration-badge.spr-iteration-new {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    border-color: rgba(46, 204, 113, 0.3);
}

.spr-features {
    color: #72efdd;
    font-weight: 500;
}

/* === v10: Calidad profesional === */
.spr-quality {
    margin: 10px 0;
    padding: 10px 12px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-md, 8px);
    display: flex;
    align-items: center;
    gap: 10px;
}

.spr-quality-bar {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
}

.spr-quality-fill {
    height: 100%;
    background: linear-gradient(90deg, #e74c3c 0%, #f39c12 50%, #2ecc71 100%);
    transition: width 0.5s ease;
}

.spr-quality-label {
    font-size: 0.82em;
    font-weight: 600;
    white-space: nowrap;
    color: var(--accent, #4cc9f0);
}

.spr-issues {
    margin: 10px 0;
    padding: 10px 14px;
    background: rgba(243, 156, 18, 0.08);
    border-left: 3px solid #f39c12;
    border-radius: var(--radius-md, 8px);
    font-size: 0.82em;
    line-height: 1.6;
}

.spr-issues strong {
    color: #f39c12;
    display: block;
    margin-bottom: 4px;
}

.spr-issues ul {
    margin: 0;
    padding-left: 18px;
}

.spr-issues li {
    margin-bottom: 2px;
    opacity: 0.85;
}

/* === Preview en vivo con device toggles === */
.spr-preview-wrapper {
    margin-top: 12px;
    border: 1px solid var(--border, #2d2d3f);
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
    background: #1a1a2e;
}

.spr-preview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid var(--border, #2d2d3f);
}

.spr-device-toggle {
    display: flex;
    gap: 4px;
    background: rgba(0,0,0,0.3);
    padding: 3px;
    border-radius: 8px;
}

.spr-device-btn {
    background: transparent;
    border: none;
    color: var(--text-muted, #888);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9em;
    transition: all 0.2s;
}

.spr-device-btn:hover {
    color: var(--text, #eee);
}

.spr-device-btn.active {
    background: var(--accent, #4cc9f0);
    color: #0a0a1a;
}

.spr-preview-container {
    background: #2a2a3a;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    min-height: 400px;
    max-height: 600px;
}

.spr-preview-frame {
    width: 100%;
    height: 600px;
    border: none;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    transition: width 0.3s ease, height 0.3s ease;
}

/* ============================================================
   v12: AGENTE DE IMÁGENES
   ============================================================ */
.images-mode-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;          /* v13: scroll vertical */
    overflow-x: hidden;
    padding: 20px;
    gap: 16px;
    -webkit-overflow-scrolling: touch;
}

.images-mode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    position: sticky;          /* v13: header sticky */
    top: 0;
    background: var(--bg-primary, #0f0f1a);
    z-index: 5;
    padding: 8px 0;
    margin: -8px 0;
}

.images-mode-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--accent, #4cc9f0);
}

.images-mode-description {
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border, #2d2d3f);
    border-radius: var(--radius-md, 10px);
    padding: 16px;
    flex-shrink: 0;
}

.images-mode-description p {
    margin: 0;
    line-height: 1.6;
    font-size: 0.9rem;
    color: var(--text-muted, #888);
}

.images-mode-input-area {
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border, #2d2d3f);
    border-radius: var(--radius-md, 10px);
    padding: 16px;
    flex-shrink: 0;
}

.images-mode-input-area label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-muted, #888);
    font-weight: 500;
}

.images-mode-input-area textarea {
    width: 100%;
    background: var(--bg-tertiary, #252539);
    border: 1px solid var(--border, #2d2d3f);
    color: var(--text, #eee);
    padding: 10px 12px;
    border-radius: var(--radius-sm, 6px);
    font-family: inherit;
    font-size: 0.92rem;
    resize: vertical;
    min-height: 70px;
    outline: none;
    transition: border-color 0.2s;
}

.images-mode-input-area textarea:focus {
    border-color: var(--accent, #4cc9f0);
}

.images-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 14px 0;
}

.images-control-group label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    margin-bottom: 4px;
}

.images-control-group select {
    width: 100%;
    background: var(--bg-tertiary, #252539);
    border: 1px solid var(--border, #2d2d3f);
    color: var(--text, #eee);
    padding: 8px 10px;
    border-radius: var(--radius-sm, 6px);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.images-control-group select:focus {
    border-color: var(--accent, #4cc9f0);
}

.images-templates {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.images-templates-label {
    width: 100%;
    font-size: 0.82rem;
    color: var(--text-muted, #888);
    font-weight: 500;
    margin-bottom: 4px;
}

.images-template-chip {
    background: var(--bg-tertiary, #252539);
    border: 1px solid var(--border, #2d2d3f);
    color: var(--text, #eee);
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.2s;
    user-select: none;
}

.images-template-chip:hover {
    background: rgba(76,201,240,0.12);
    border-color: var(--accent, #4cc9f0);
    color: var(--accent, #4cc9f0);
    transform: translateY(-1px);
}

.images-mode-output-area {
    /* v13: ya no hace scroll propio, lo hace el contenedor padre */
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border, #2d2d3f);
    border-radius: var(--radius-md, 10px);
    padding: 16px;
    flex-shrink: 0;
}

.images-output-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Card de resultado de imagen */
.image-result-card {
    background: linear-gradient(135deg, rgba(76,201,240,0.05), rgba(114,239,221,0.03));
    border: 1px solid var(--border, #2d2d3f);
    border-radius: var(--radius-md, 10px);
    padding: 16px;
}

.img-header h3 {
    margin: 0 0 6px;
    color: var(--accent, #4cc9f0);
    font-size: 1em;
    line-height: 1.3;
}

.img-desc {
    margin: 0 0 10px;
    opacity: 0.7;
    font-size: 0.85em;
}

.img-iteration-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.78em;
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
    border: 1px solid rgba(243, 156, 18, 0.3);
    margin-left: 4px;
}

.img-iteration-badge.img-iteration-new {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    border-color: rgba(46, 204, 113, 0.3);
}

.img-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.82em;
    opacity: 0.85;
    margin-bottom: 12px;
    padding: 6px 10px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-sm, 6px);
}

.img-loading {
    text-align: center;
    padding: 60px 20px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-sm, 6px);
    color: var(--text-muted, #888);
}

.img-loading p {
    margin: 12px 0 0;
    font-size: 0.88em;
}

.img-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(76,201,240,0.2);
    border-top-color: var(--accent, #4cc9f0);
    border-radius: 50%;
    margin: 0 auto;
    animation: imgSpin 0.8s linear infinite;
}

@keyframes imgSpin {
    to { transform: rotate(360deg); }
}

.img-preview-wrapper {
    background: #000;
    border-radius: var(--radius-sm, 6px);
    overflow: hidden;
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
}

.img-preview {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-sm, 6px);
}

.img-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.img-btn {
    border: none;
    padding: 9px 14px;
    border-radius: var(--radius-sm, 8px);
    cursor: pointer;
    font-size: 0.85em;
    font-family: inherit;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.img-btn:hover {
    transform: translateY(-1px);
}

.img-btn-primary {
    background: linear-gradient(135deg, #4cc9f0, #3aa8d8);
    color: #0a0a1a;
    font-weight: 600;
}

.img-btn-secondary {
    background: rgba(114,239,221,0.15);
    color: #72efdd;
    border: 1px solid rgba(114,239,221,0.3);
}

.img-btn-tertiary {
    background: rgba(255,255,255,0.08);
    color: var(--text, #eee);
    border: 1px solid var(--border, #2d2d3f);
}

.img-btn-ghost {
    background: transparent;
    color: var(--text, #eee);
    border: 1px solid var(--border, #2d2d3f);
    opacity: 0.85;
}

.img-btn-warn {
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
    border: 1px solid rgba(243, 156, 18, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .images-controls {
        grid-template-columns: 1fr;
    }
    
    .images-mode-container {
        padding: 12px;
    }
    
    .img-actions {
        flex-direction: column;
    }
    
    .img-btn {
        width: 100%;
        justify-content: center;
    }
}

.spr-code-wrapper {
    margin-top: 12px;
    background: #0d1117;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}

.spr-code {
    margin: 0;
    padding: 14px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.78em;
    line-height: 1.5;
    color: #c9d1d9;
    max-height: 400px;
    overflow-y: auto;
}

.spr-code code {
    font-family: inherit;
    white-space: pre;
}

/* ============================================================
   9. RESPONSIVE GENERAL MEJORADO
   ============================================================ */

/* Tablets */
@media (max-width: 1024px) {
    .suggestions-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* Móvil */
@media (max-width: 768px) {
    .suggestions-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .prompt-suggestions {
        padding: 16px 12px;
    }
    
    .suggestion-chip {
        padding: 10px 12px;
        font-size: 0.85em;
    }
    
    .suggestion-chip .chip-text {
        font-size: 0.95em;
    }
    
    .reasoning-step {
        flex-direction: column;
        gap: 4px;
    }
    
    .reasoning-step-name {
        white-space: normal;
    }
    
    /* Sidebar más compacto en móvil */
    .personality-controls .btn-thinking {
        font-size: 0.85em;
        padding: 6px 10px;
    }
    
    /* Acciones del agente de páginas: botones a ancho completo en móvil */
    .spr-actions {
        flex-direction: column;
    }
    
    .spr-btn {
        width: 100%;
        justify-content: center;
    }
    
    .spr-stats {
        font-size: 0.78em;
        gap: 8px;
    }
    
    /* Onboarding responsivo */
    #onboarding-overlay > div {
        padding: 20px !important;
    }
    
    /* Modales más anchos en móvil */
    .diagnostic-modal,
    #bookmarks-modal > div,
    #onboarding-overlay > div {
        width: 95% !important;
        max-width: 95% !important;
    }
    
    /* Code wrapper más compacto */
    .spr-code {
        font-size: 0.72em;
        padding: 10px;
        max-height: 250px;
    }
}

/* Móvil pequeño */
@media (max-width: 480px) {
    .suggestions-grid {
        grid-template-columns: 1fr;
    }
    
    .prompt-suggestions h3 {
        font-size: 1em;
    }
    
    .spr-header h3 {
        font-size: 1em;
    }
    
    /* Sidebar botones aún más compactos */
    .btn-thinking,
    .btn-new-chat,
    .btn-history-action {
        font-size: 0.8em;
    }
}

/* ============================================================
   10. SCROLLBAR GLOBAL MÁS ESTÉTICA
   ============================================================ */
.diagnostic-modal::-webkit-scrollbar,
#bookmarks-modal div::-webkit-scrollbar,
.spr-code::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.diagnostic-modal::-webkit-scrollbar-thumb,
#bookmarks-modal div::-webkit-scrollbar-thumb,
.spr-code::-webkit-scrollbar-thumb {
    background: rgba(76,201,240,0.5);
    border-radius: 3px;
}

/* ============================================================
   11. AJUSTES FINOS PARA INPUT AREA
   ============================================================ */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.input-wrapper > textarea {
    flex: 1;
}

/* ============================================================
   12. ANIMACIÓN DE APARICIÓN DE MENSAJES
   ============================================================ */
.message-wrapper {
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   13. MODO ACCESIBILIDAD
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   14. INDICADOR DE ESCRIBIENDO MEJORADO
   ============================================================ */
.typing-emotion {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-emotion::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    margin-right: 4px;
    animation: pulse 1.4s ease-in-out infinite;
}

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

/* ============================================================
   15. SCROLLBAR EN CHAT MÁS SUTIL
   ============================================================ */
.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.25);
}
