/* Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
    --latam-blue: #1B0088;
    --latam-red: #E3004F;
    --bg-color: #F4F6F8;
    --card-bg: #FFFFFF;
    --text-primary: #1A1A1A;
    --text-secondary: #666666;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --radius-lg: 16px;
    --radius-md: 12px;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    /* Allow scrolling if content is too tall */
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background-color: var(--card-bg);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.brand-name {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--latam-blue);
}

/* Main Layout */
#main-container {
    flex: 1;
    display: flex;
    gap: 24px;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    align-items: stretch;
    justify-content: center;
}

/* Video Container */
#video-container {
    flex: 1;
    max-width: 450px;
    /* Limit width to better frame the portrait video */
    /* Limit width to better frame the portrait video */
    /* Center it if we want, or just let flex handle it */
    background-color: black;
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-md);
    /* Fix height to prevent resizing when video loads */
    height: 550px;
    max-height: 75vh;
}

#video-container video,
#video-container iframe,
#placeholder-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}

#placeholder-img {
    z-index: 1;
    transition: opacity 0.5s ease;
    object-fit: contain !important;
    object-position: center;
    background-color: #0d0044;
    /* Dark blue background to match LATAM vibe */
}

#video-container video,
#video-container iframe {
    z-index: 2;
}

/* Avatar Selection */
#avatar-selection {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(13, 0, 68, 0.9);
    /* Dark overlay */
    gap: 20px;
    transition: opacity 0.5s ease;
}

.avatar-selection-title {
    color: white;
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 10px;
}

.avatar-gallery {
    display: flex;
    gap: 20px;
}

.avatar-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.avatar-card:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.avatar-card.selected {
    opacity: 1;
    transform: scale(1.05);
}

.avatar-card img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid transparent;
    object-fit: cover;
    transition: border-color 0.3s ease;
}

.avatar-card.selected img {
    border-color: var(--latam-red);
    box-shadow: 0 0 15px rgba(227, 0, 79, 0.5);
}

.avatar-name {
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Chat Container */
#chat-container {
    flex: 1;
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 320px;
    max-width: 450px;
    /* Match video container height */
    height: 550px;
    max-height: 75vh;
}

#chat-history {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    /* Enable vertical scrollbar */
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Ensure it takes available space but allows scrolling */
    min-height: 0;
}

/* Messages */
.message {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    line-height: 1.5;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

.message.user {
    background-color: var(--latam-blue);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    background-color: #F0F2F5;
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.system {
    background-color: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    align-self: center;
    padding: 4px 12px;
    border: 1px solid #E0E0E0;
    border-radius: 20px;
}

/* Input Area */
#chat-input-area {
    padding: 20px;
    border-top: 1px solid #EEEEEE;
    display: flex;
    gap: 12px;
    background-color: var(--card-bg);
}

#chat-input {
    flex-grow: 1;
    padding: 12px 16px;
    border: 1px solid #E0E0E0;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    outline: none;
}

#chat-input:focus {
    border-color: var(--latam-blue);
}

#chat-input:disabled {
    background-color: #F9F9F9;
    cursor: not-allowed;
}

/* Buttons */
button {
    padding: 10px 20px;
    font-family: inherit;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

#send-btn {
    background-color: var(--latam-red);
    color: white;
}

#send-btn:hover:not(:disabled) {
    background-color: #C40044;
    transform: translateY(-1px);
}

#send-btn:disabled {
    background-color: #FFCCD9;
    cursor: not-allowed;
}

/* Header Controls */
.header-controls {
    display: flex;
    gap: 10px;
}

.header-controls button {
    padding: 8px 16px;
    font-size: 0.9rem;
}

#connect-btn {
    background-color: var(--latam-blue);
    color: white;
    min-width: 120px;
}

#connect-btn:hover {
    background-color: #140066;
    transform: translateY(-1px);
}

#end-btn {
    background-color: var(--text-secondary);
    color: white;
}

#end-btn:hover {
    background-color: #444;
}

/* Disclaimer */
.disclaimer {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0 0 10px 0;
    padding: 0 20px;
}

/* Responsive */
/* Responsive */
@media (max-width: 768px) {
    #main-container {
        flex-direction: column;
        padding: 16px;
        gap: 16px;
    }

    #video-container {
        width: 100%;
        height: 35vh;
        /* Use viewport height for better scaling */
        min-height: 250px;
        flex: none;
    }

    #chat-container {
        width: 100%;
        max-width: 100%;
        height: 45vh;
        /* Fill remaining space roughly */
        min-height: 300px;
        flex: none;
    }

    header {
        padding: 0.75rem 1rem;
    }

    .brand-name {
        font-size: 1rem;
    }

    .header-controls button {
        padding: 6px 10px;
        font-size: 0.8rem;
        min-width: auto;
        /* Override any min-width */
    }
}