/**
 * Estilos para el chat en modo Pantalla Completa - Braves Chat iA
 * Version: 1.0.0
 * @package BravesChat
 */

/* ============================================
   ISOLATION LAYER - FULLSCREEN MODE
   ============================================ */
/* Comprehensive reset for fullscreen mode to prevent theme CSS bleeding */
/* ============================================
   ESTILOS GENERALES Y RESETS
   ============================================ */
body #braveslab-chat-container,
body #braveslab-chat-container *,
body #braveslab-chat-container *::before,
body #braveslab-chat-container *::after {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    line-height: normal;
    letter-spacing: normal;
    text-transform: none;
    font-style: normal;
    font-variant: normal;
    box-sizing: border-box;
}

body #braveslab-chat-container h1,
body #braveslab-chat-container h2,
body #braveslab-chat-container h3,
body #braveslab-chat-container h4,
body #braveslab-chat-container h5,
body #braveslab-chat-container h6,
body #braveslab-chat-container p,
body #braveslab-chat-container span,
body #braveslab-chat-container div {
    font-family: inherit;
    margin: 0;
    padding: 0;
    font-weight: normal;
    line-height: inherit;
}

body #braveslab-chat-container button,
body #braveslab-chat-container input[type="button"],
body #braveslab-chat-container input[type="submit"] {
    all: unset;
    box-sizing: border-box;
    font-family: inherit;
    cursor: pointer;
    display: inline-block;
    text-align: center;
    vertical-align: middle;
    user-select: none;
}

body #braveslab-chat-container input,
body #braveslab-chat-container textarea {
    all: unset;
    box-sizing: border-box;
    font-family: inherit;
    display: block;
    width: auto;
}

/* ============================================
   OVERLAY — cubre el fondo blanco del tema
   ============================================ */
#braves-fullscreen-overlay {
    position: fixed;
    inset: 0;
    background: #212121;
    z-index: 999996;
}

/* ============================================
   CONTENEDORES PRINCIPALES (TEMA DARK / BLACK)
   ============================================ */
body #braveslab-chat-container {
    z-index: 999999;
}

/* El botón circular debe estar oculto en fullscreen */
body #braveslab-chat-container #chat-toggle {
    display: none !important;
}

/* Ventana de Chat (Modo Fullscreen) */
body #braveslab-chat-container #chat-window {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    background: #212121 !important;
    /* Dark Mode Fondo principal */
    color: #ececec !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999998;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ============================================
   HEADER MINIMALISTA
   ============================================ */
body #braveslab-chat-container #chat-header {
    background: transparent;
    color: #ececec;
    padding: 15px 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 50px;
    flex-shrink: 0;
}

body #braveslab-chat-container #chat-header .header-inner {
    display: flex;
    align-items: center;
    gap: 15px;
}

body #braveslab-chat-container #chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    color: #ececec;
}

body #braveslab-chat-container #chat-header p {
    display: none;
    /* Subtítulo oculto para aspecto limpio estilo ChatGPT */
}

/* ============================================
   ÁREA DE MENSAJES (LAYOUT CENTRALIZADO)
   ============================================ */
body #braveslab-chat-container #chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 40px 20px 20px 20px;
    background: transparent;
    /* Hereda del #chat-window */
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0 auto;
    scroll-behavior: smooth;
}

body #braveslab-chat-container #chat-messages::-webkit-scrollbar {
    width: 8px;
}

body #braveslab-chat-container #chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

body #braveslab-chat-container #chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

/* Mensajes con estilo de filas (No burbujas) */
body #braveslab-chat-container .message {
    display: flex;
    flex-direction: row;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 20px 0;
    animation: messageIn 0.3s ease;
    gap: 20px;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body #braveslab-chat-container .message.user {
    flex-direction: row-reverse;
}

body #braveslab-chat-container .message.bot {
    flex-direction: row;
}

/* Avatares */
body #braveslab-chat-container .message-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    /* Fondo blanco para el icono SVG para asegurar visibilidad */
}

body #braveslab-chat-container .message.user .message-avatar {
    background-color: #444;
    /* Fondo gris para avatar del usuario (cuando lo implementemos vía JS) */
    color: #fff;
    font-weight: 500;
    font-size: 14px;
}

body #braveslab-chat-container .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Contenido del Mensaje */
body #braveslab-chat-container .message-content {
    flex: 1;
    max-width: calc(100% - 70px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

body #braveslab-chat-container .message.bot .message-content {
    align-items: flex-start;
}

body #braveslab-chat-container .message.user .message-content {
    align-items: flex-end;
}

body #braveslab-chat-container .message-bubble {
    font-size: 15px;
    line-height: 1.7;
    word-wrap: break-word;
    color: #ececec;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

body #braveslab-chat-container .message.user .message-bubble {
    background: #2f2f2f !important;
    padding: 12px 18px !important;
    border-radius: 18px !important;
    color: #ececec !important;
}

body #braveslab-chat-container .message-time {
    display: none;
    /* Ocultamos el tiempo para un look más limpio como ChatGPT */
}

/* Formato texto Markdown */
body #braveslab-chat-container .message-bubble p {
    margin-bottom: 1em;
}

body #braveslab-chat-container .message-bubble p:last-child {
    margin-bottom: 0;
}

body #braveslab-chat-container .message-bubble a {
    color: var(--braves-primary, #01B7AF);
    text-decoration: underline;
}

/* ============================================
   ÁREA DE ENTRADA DE TEXTO
   ============================================ */
body #braveslab-chat-container #chat-input-wrapper {
    width: 100%;
    padding: 20px;
    background: linear-gradient(to top, rgba(33, 33, 33, 1) 50%, rgba(33, 33, 33, 0)) !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 10;
}

body #braveslab-chat-container #chat-input-container {
    background: #2f2f2f !important;
    border: 1px solid #444 !important;
    border-radius: 25px !important;
    padding: 8px 15px !important;
    display: flex;
    align-items: flex-end;
    gap: 15px;
    width: 100%;
    max-width: 800px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
    margin: 0 auto;
}

body #braveslab-chat-container #chat-input-container:focus-within {
    border-color: rgba(255, 255, 255, 0.3);
}

body #braveslab-chat-container #chat-input {
    flex: 1;
    font-size: 16px;
    outline: none;
    color: #ececec;
    background: transparent;
    font-family: 'Montserrat', 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    resize: none;
    overflow-y: auto;
    min-height: 72px;
    max-height: 200px;
    padding: 6px 12px;
}

body #braveslab-chat-container #chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Botón de Enviar (Flecha) */
body #braveslab-chat-container #send-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background-color: #fff;
    color: #000;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease, transform 0.2s ease;
    margin-bottom: 2px;
    /* Alineación fina con input text */
}

body #braveslab-chat-container #send-button svg {
    transform: translate(1px, 1px);
    width: 20px;
    height: 20px;
}

body #braveslab-chat-container #send-button:hover:not(:disabled) {
    transform: scale(1.05);
    opacity: 0.9;
}

body #braveslab-chat-container #send-button:disabled {
    opacity: 0.3;
    background-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
}

/* Footer disclaimer */
body #braveslab-chat-container .chat-footer-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    margin-top: 15px;
    font-family: 'Montserrat', sans-serif;
}

/* ============================================
   INDICADOR DE ESCRITURA (PUNTO PALPITANTE)
   ============================================ */
body #braveslab-chat-container .typing-indicator {
    display: none;
    align-items: center;
    padding: 10px 0;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    /* Alinear con el contenido de los mensajes del bot */
    padding-left: calc(36px + 20px);
}

body #braveslab-chat-container .typing-pulse-dot {
    display: none;
}

/* Animación latido: tun-tun (pausa) tun-tun */
@keyframes heartbeat-screen {
    0%   { opacity: 0.3; transform: scale(1);   }
    10%  { opacity: 1;   transform: scale(1.4); }
    20%  { opacity: 0.3; transform: scale(1);   }
    30%  { opacity: 1;   transform: scale(1.4); }
    40%  { opacity: 0.3; transform: scale(1);   }
    100% { opacity: 0.3; transform: scale(1);   }
}

/* ============================================
   HEARTBEAT DOT — Latido persistente del agente
   ============================================ */

/* Contenedor — mismo ancho y centrado que los mensajes */
body #braveslab-chat-container .braves-heartbeat-dot {
    display: flex;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 6px 0 10px calc(36px + 20px);
}

/* El dot en sí */
body #braveslab-chat-container .braves-heartbeat-dot__inner {
    display: inline-block;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background-color: var(--braves-primary, #01B7AF);
    animation: heartbeat-screen 2s ease-in-out infinite;
    flex-shrink: 0;
}

/* ============================================
   STREAMING Y ESCRITURA
   ============================================ */
body #braveslab-chat-container .typing-cursor {
    display: block;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background-color: var(--braves-primary, #01B7AF);
    animation: heartbeat-screen 2s ease-in-out infinite;
    margin-top: 10px;
    margin-left: 0;
    margin-bottom: 2px;
}

body #braveslab-chat-container #chat-input:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    body #braveslab-chat-container .message {
        padding: 15px;
        gap: 12px;
    }

    body #braveslab-chat-container #chat-messages {
        padding: 20px 0;
    }

    body #braveslab-chat-container #chat-input-wrapper {
        padding: 15px;
        padding-bottom: 20px;
    }

    body #braveslab-chat-container .message-avatar {
        width: 30px;
        height: 30px;
        min-width: 30px;
    }

    body #braveslab-chat-container .message-bubble {
        font-size: 15px;
    }
}

/* ============================================
   WELCOME MODE (Pantalla de inicio tipo Claude)
   ============================================ */

/* En welcome mode: centrar todo verticalmente */
body #braveslab-chat-container #chat-window.braves-welcome-mode {
    justify-content: center;
    align-items: center;
}

/* Ocultar header, mensajes e indicador en welcome mode */
body #braveslab-chat-container #chat-window.braves-welcome-mode #chat-header {
    display: none;
}

body #braveslab-chat-container #chat-window.braves-welcome-mode #chat-messages {
    display: none !important;
    flex: 0;
}

body #braveslab-chat-container #chat-window.braves-welcome-mode .typing-indicator {
    display: none !important;
}

body #braveslab-chat-container #chat-window.braves-welcome-mode .braves-heartbeat-dot {
    display: none !important;
}

/* Input centrado en welcome mode */
body #braveslab-chat-container #chat-window.braves-welcome-mode #chat-input-wrapper {
    background: transparent !important;
    max-width: 800px;
    width: 100%;
    padding-top: 0;
}

/* Pantalla de bienvenida (splash) */
body #braveslab-chat-container #chat-welcome-splash {
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    max-width: 600px;
    width: 100%;
    padding: 0 20px 32px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

body #braveslab-chat-container #chat-window.braves-welcome-mode #chat-welcome-splash {
    display: flex;
}

body #braveslab-chat-container .welcome-splash-icon {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    overflow: hidden;
    background: transparent;
}

body #braveslab-chat-container .welcome-splash-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

body #braveslab-chat-container .welcome-splash-title {
    font-size: 26px;
    font-weight: 600;
    color: #ececec;
    margin: 0;
    line-height: 1.3;
}

body #braveslab-chat-container .welcome-splash-subtitle {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.45);
    margin: 0;
    line-height: 1.6;
}

/* Animación de salida del splash */
body #braveslab-chat-container #chat-welcome-splash.braves-splash-exit {
    opacity: 0;
    transform: translateY(-16px);
    pointer-events: none;
}

/* Animación de entrada de los mensajes */
@keyframes messages-slide-in {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body #braveslab-chat-container #chat-messages.braves-messages-appear {
    animation: messages-slide-in 0.4s ease forwards;
}

@media (max-width: 768px) {
    body #braveslab-chat-container .welcome-splash-title {
        font-size: 22px;
    }

    body #braveslab-chat-container .welcome-splash-icon {
        width: 48px;
        height: 48px;
    }
}