/* ============================================
   JJ GAMES AND TOOLS - WIDGET ASISTENTE
   Estilos integrados con el diseño principal
   ============================================ */

/* Variables heredadas del :root de style.css */
:root {
    --jj-widget-bg: rgba(20, 20, 30, 0.85);
    --jj-widget-border: 1px solid rgba(255, 255, 255, 0.1);
    --jj-widget-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 212, 255, 0.15);
    --jj-font-display: 'Orbitron', sans-serif;
    --jj-font-primary: 'Inter', sans-serif;
}

/* Botón flotante */
.jj-widget-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-red));
    border: none;
    color: #fff;
    font-size: 1.6rem;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 25px rgba(0, 212, 255, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    backdrop-filter: blur(10px);
}

.jj-widget-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 40px rgba(230, 57, 70, 0.5);
}

.jj-widget-btn i {
    pointer-events: none;
}

/* Contenedor del chat */
.jj-chat-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--jj-widget-bg);
    backdrop-filter: blur(25px);
    border: var(--jj-widget-border);
    border-radius: 20px;
    box-shadow: var(--jj-widget-shadow);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--jj-font-primary);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.jj-chat-container.active {
    display: flex;
}

/* Cabecera */
.jj-chat-header {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(230, 57, 70, 0.15));
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: var(--jj-widget-border);
}

.jj-chat-header .jj-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-red));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
}

.jj-chat-header .jj-title {
    font-family: var(--jj-font-display);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.jj-chat-header .jj-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.jj-chat-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.3s;
}

.jj-chat-close:hover {
    color: var(--primary-red);
}

/* Área de mensajes */
.jj-chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    scroll-behavior: smooth;
}

.jj-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.85rem;
    line-height: 1.5;
    word-wrap: break-word;
    animation: jj-fadeIn 0.3s ease;
}

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

.jj-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary-blue), #0077b6);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.jj-message.assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    border: var(--jj-widget-border);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.jj-message.tool {
    align-self: flex-start;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.2);
    color: var(--primary-yellow);
    font-size: 0.75rem;
    font-family: monospace;
    max-width: 100%;
}

/* Bloque de razonamiento (modo portfolio) */
.jj-reasoning-block {
    background: rgba(0, 0, 0, 0.4);
    border-left: 3px solid var(--primary-yellow);
    padding: 10px;
    margin: 8px 0;
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
}

/* Área de input */
.jj-chat-input-area {
    display: flex;
    padding: 10px;
    border-top: var(--jj-widget-border);
    background: rgba(0, 0, 0, 0.3);
    gap: 8px;
}

.jj-chat-input {
    flex: 1;
    padding: 12px 16px;
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-family: var(--jj-font-primary);
    font-size: 0.85rem;
    outline: none;
    transition: border 0.3s;
}

.jj-chat-input:focus {
    border-color: var(--primary-blue);
}

.jj-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-red));
    border: none;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jj-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
}

.jj-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Responsive */
@media (max-width: 480px) {
    .jj-widget-btn {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
        font-size: 1.4rem;
    }
    .jj-chat-container {
        bottom: 85px;
        right: 10px;
        width: calc(100vw - 20px);
        height: 450px;
    }
}