/**
 * IA Workers Chat - CSS
 * Estilos modernos para el chat con IA
 */

/* Variables CSS */
:root {
    --ia-chat-primary: #6366f1;
    --ia-chat-primary-hover: #4f46e5;
    --ia-chat-bg-dark: #0f172a;
    --ia-chat-bg-light: #ffffff;
    --ia-chat-surface-dark: #1e293b;
    --ia-chat-surface-light: #f8fafc;
    --ia-chat-text-dark: #f1f5f9;
    --ia-chat-text-light: #1e293b;
    --ia-chat-border-dark: #334155;
    --ia-chat-border-light: #e2e8f0;
    --ia-chat-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* Contenedor principal - solo margen inferior */
.ia-chat-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    margin-bottom: 500px; /* Margen inferior extra grande para evitar problemas con el footer */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    /* Sin bordes, backgrounds ni otros elementos que den apariencia de caja */
}

/* Sin media queries - diseño unificado */

/* Clase que se agregará por JavaScript para pantallas grandes */
.ia-chat-container.zoomed {
    /* Usando solo zoom para evitar efectos de contenedor */
    zoom: 1.08;
}

/* Tema Dark (por defecto) - sin estilos de caja */
.ia-chat-container[data-theme="dark"] {
    background: none;
    color: var(--ia-chat-text-dark);
}

/* Tema Light - sin estilos de caja */
.ia-chat-container[data-theme="light"] {
    background: none;
    color: var(--ia-chat-text-light);
}

/* Área de mensajes - totalmente integrada */
.ia-chat-messages {
    flex: 1;
    padding: 10px 0 0; /* Mínimo padding necesario */
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: none;
}

/* Pantalla de bienvenida */
.ia-chat-welcome-screen {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
    padding: 10px 0 0; /* Mínimo padding necesario */
    min-height: auto;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s ease;
}

.ia-chat-welcome-screen.show {
    opacity: 1;
    transform: translateY(0);
}

.ia-chat-welcome-screen.hide {
    opacity: 0;
    transform: translateY(-20px);
}

/* Título de bienvenida */
.ia-chat-welcome-title {
    text-align: center;
    max-width: 600px;
}

.ia-chat-welcome-title h2 {
    margin: 0 0 10px 0; /* Reducido de 12px */
    font-size: 42px; /* Reducido de 48px */
    font-weight: 600;
    letter-spacing: -0.02em;
    position: relative;
    display: inline-block;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shine 3s linear infinite;
    overflow: hidden;
}

.ia-chat-container[data-theme="dark"] .ia-chat-welcome-title h2 {
    background-image: linear-gradient(90deg, #6366f1, #4f46e5, #fff, #6366f1);
    background-size: 200% auto;
    color: var(--ia-chat-text-dark);
}

.ia-chat-container[data-theme="light"] .ia-chat-welcome-title h2 {
    background-image: linear-gradient(90deg, #6366f1, #4f46e5, #4338ca, #6366f1);
    background-size: 200% auto;
    color: var(--ia-chat-text-light);
}

@keyframes shine {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

/* Este selector ya está definido arriba con el efecto brillante */

.ia-chat-welcome-title p {
    margin: 0;
    font-size: 16px; /* Reducido de 18px */
    opacity: 0.7;
    font-weight: 400;
    max-width: 500px; /* Limitar el ancho del subtítulo */
    margin: 0 auto; /* Centrar el texto */
}

/* Preguntas sugeridas */
.ia-chat-suggested-questions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Reducido de 300px */
    gap: 12px; /* Reducido de 16px */
    width: 100%;
    max-width: 700px; /* Reducido de 800px */
}

.ia-chat-question-card {
    background: rgba(30, 41, 59, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px; /* Reducido de 16px */
    padding: 14px 16px; /* Reducido de 20px */
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.ia-chat-container[data-theme="dark"] .ia-chat-question-card {
    background: rgba(30, 41, 59, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--ia-chat-text-dark);
}

.ia-chat-container[data-theme="light"] .ia-chat-question-card {
    border-color: rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.5);
    color: var(--ia-chat-text-light);
}

.ia-chat-question-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--ia-chat-primary) 0%, var(--ia-chat-primary-hover) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.ia-chat-question-card:hover::before {
    opacity: 0.1;
}

.ia-chat-question-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(30, 41, 59, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.15);
}

.ia-chat-container[data-theme="light"] .ia-chat-question-card:hover {
    background: rgba(255, 255, 255, 0.7);
}

.ia-chat-question-card:active {
    transform: translateY(0);
}

.ia-chat-question-title {
    position: relative;
    z-index: 1;
    font-size: 14px; /* Reducido de 15px */
    font-weight: 600;
    margin-bottom: 3px; /* Reducido de 4px */
}

.ia-chat-question-subtitle {
    position: relative;
    z-index: 1;
    font-size: 12px; /* Reducido de 13px */
    opacity: 0.7;
}

/* Scrollbar personalizado */
.ia-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ia-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ia-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.3);
    border-radius: 3px;
}

.ia-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.5);
}

/* Mensajes individuales */
.ia-chat-message {
    display: flex;
    flex-direction: row;
    gap: 12px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.ia-chat-message.show {
    opacity: 1;
    transform: translateY(0);
}

.ia-chat-message-user {
    flex-direction: row-reverse;
}

.ia-chat-message-assistant,
.ia-chat-message-error {
    flex-direction: row;
}

/* Avatares */
.ia-chat-avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    border: none;
}

.ia-chat-message-content {
    display: flex;
    flex-direction: column;
    max-width: calc(100% - 48px);
}

.ia-chat-bubble {
    padding: 10px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
    max-width: 600px;
}

/* Burbujas de usuario - cuadradas con color negro sólido */
.ia-chat-message-user .ia-chat-bubble {
    background: #0a0a0a;
    color: white;
    border-radius: 8px;
    border-bottom-right-radius: 2px;
}

/* Burbujas de asistente - cuadradas con color azul-gris oscuro semi-transparente */
.ia-chat-container[data-theme="dark"] .ia-chat-message-assistant .ia-chat-bubble {
    background: rgba(30, 41, 59, 0.8);
    color: var(--ia-chat-text-dark);
    border-radius: 8px;
    border-bottom-left-radius: 2px;
}

.ia-chat-container[data-theme="light"] .ia-chat-message-assistant .ia-chat-bubble {
    background: rgba(30, 41, 59, 0.7);
    color: var(--ia-chat-text-light);
    border-radius: 8px;
    border-bottom-left-radius: 2px;
}

/* Burbujas de error - sin bordes */
.ia-chat-message-error .ia-chat-bubble {
    background: rgba(255, 200, 200, 0.2);
    color: #c33;
}

/* Formato de código en mensajes */
.ia-chat-bubble code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.ia-chat-message-user .ia-chat-bubble code {
    background: rgba(255, 255, 255, 0.2);
}

/* Timestamps */
.ia-chat-timestamp {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
    padding: 0 4px;
}

/* Área de input - sin apariencia de caja */
.ia-chat-input-wrapper {
    padding: 10px 0 10px;
    background: none;
    border: none;
    flex-shrink: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ia-chat-container[data-theme="dark"] .ia-chat-input-wrapper {
    background: none;
}

.ia-chat-container[data-theme="light"] .ia-chat-input-wrapper {
    background: none;
}

.ia-chat-input-container {
    display: flex;
    gap: 0;
    align-items: center;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    overflow: hidden;
    background: rgba(30, 41, 59, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ia-chat-input {
    flex: 1;
    height: 48px; /* Mismo alto que el botón */
    min-height: 48px;
    max-height: 48px;
    padding: 12px 16px;
    border: none;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    transition: all 0.2s ease;
    outline: none;
    background: transparent;
    color: white;
    overflow-y: hidden;
    overflow-x: hidden;
}

.ia-chat-container[data-theme="dark"] .ia-chat-input {
    background: transparent;
    color: white;
    border: none;
}

.ia-chat-container[data-theme="light"] .ia-chat-input {
    background: transparent;
    color: white;
    border: none;
}

.ia-chat-input:focus {
    border-color: rgba(99, 102, 241, 0.6);
    background: transparent;
    box-shadow: none;
}

.ia-chat-container[data-theme="light"] .ia-chat-input:focus {
    background: transparent;
}

.ia-chat-input::placeholder {
    opacity: 0.5;
}

/* Botón de enviar */
.ia-chat-send-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 0;
    background: #ffffff;
    color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ia-chat-send-btn svg {
    color: #000000;
}

.ia-chat-send-btn:hover:not(:disabled) {
    background: #f0f0f0;
    transform: scale(1.05);
}

.ia-chat-send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Indicador de escritura en el área de mensajes */
.ia-chat-typing-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 8px;
}

.ia-chat-typing-bubble {
    background: rgba(30, 41, 59, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 16px 20px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.ia-chat-container[data-theme="light"] .ia-chat-typing-bubble {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(0, 0, 0, 0.08);
}

.ia-chat-typing-bubble span {
    width: 8px;
    height: 8px;
    background: var(--ia-chat-primary);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.ia-chat-typing-bubble span:nth-child(2) {
    animation-delay: 0.2s;
}

.ia-chat-typing-bubble span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    30% {
        transform: scale(1.3);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .ia-chat-container {
        max-width: 100%;
        height: 500px;
        border-radius: 0;
    }
    
    .ia-chat-bubble {
        max-width: 85%;
    }
    
    .ia-chat-header {
        padding: 12px 16px;
    }
    
    .ia-chat-messages {
        padding: 16px;
    }
    
    .ia-chat-input-wrapper {
        padding: 12px 16px;
    }
}

/* Media query específica para pantallas 1366x768 y similares */
@media screen and (max-width: 1400px) {
    .ia-chat-welcome-title h2 {
        font-size: 48px;
    }

    .ia-chat-welcome-title p {
        font-size: 18px;
        max-width: 650px;
    }

    .ia-chat-suggested-questions {
        max-width: 850px;
        gap: 16px;
    }

    .ia-chat-question-card {
        padding: 18px;
        border-radius: 16px;
    }

    .ia-chat-question-title {
        font-size: 16px;
    }

    .ia-chat-question-subtitle {
        font-size: 14px;
    }

    .ia-chat-input {
        padding: 16px 20px;
        font-size: 16px;
    }

    .ia-chat-send-btn {
        width: 54px;
        height: 54px;
    }
}

/* Posición floating (opcional) */
.ia-chat-container[data-position="floating"] {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: 600px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    z-index: 999;
}

@media (max-width: 768px) {
    .ia-chat-container[data-position="floating"] {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100vh;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }
}
