/* --- Chat Section --- */
.chat-container {
    padding: 20px 0;
    position: relative;
    overflow: hidden;
}

.chat-widget {
    position: relative;
    right: -60px;
    max-width: 800px;
    width: 100%;
    margin: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.02);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    overflow: hidden;
    flex-shrink: 0;
}

/* Fullscreen mode for chat widget */
.chat-widget.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh; /* Динамічна висота для мобільних з клавіатурою */
    max-width: none;
    right: 0;
    border-radius: 0;
    z-index: 1001;
    transition: all 0.3s ease;
}

.chat-widget.fullscreen .chat-box {
    height: calc(100dvh - 90px); /* Висота мінус .chat-input-container */
}

/* Медіа-запит для мобільних */
@media (max-width: 768px) {
    .chat-widget.fullscreen {
        border-radius: 0;
    }
    .chat-widget.fullscreen .chat-box {
        height: calc(100vh - 80px); /* Менший відступ для мобільних */
    }
    .chat-input-container {
        gap: 10px; /* Зменшуємо відстань між елементами */
    }
    .fullscreen-toggle {
        width: 40px; /* Менший розмір для мобільних */
        height: 40px;
        font-size: 1.2rem;
    }
}

.chat-box {
    height: 350px;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-message {
    padding: 12px 20px;
    border-radius: 20px;
    max-width: 75%;
    line-height: 1.5;
    font-size: 0.7rem; /* Зменшено з 0.78rem */
}

.chat-message p {
    margin: 0;
    padding: 0;
}

.chat-message ul {
    margin: 8px 0;
    padding-left: 20px;
    list-style-type: disc;
}

.chat-message li {
    margin-bottom: 4px;
}

.user-message {
    background: linear-gradient(45deg, var(--accent-color), #007BFF);
    color: #FFFFFF;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.bot-message {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--text-color);
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    text-shadow: 0px 1px 3px rgba(0, 0, 0, 0.4);
}

.chat-input-container {
    display: flex;
    gap: 15px;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background-color: transparent;
}

.chat-input {
    flex-grow: 1;
    padding: 15px;
    border-radius: 25px;
    border: 1px solid transparent;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    font-size: 1rem;
    transition: border-color 0.3s ease, background-color 0.3s ease, opacity 0.3s ease;
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.chat-input:disabled {
    background-color: rgba(255, 255, 255, 0.05);
    opacity: 0.5;
    cursor: not-allowed;
}

.send-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: linear-gradient(45deg, var(--accent-color), #007BFF);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    transition: background 0.3s ease, opacity 0.3s ease, border-color 0.3s ease;
}

.send-button:disabled {
    background: rgba(255, 255, 255, 0.1);
    opacity: 0.5;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.1);
}

/* Fullscreen toggle button */
.fullscreen-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: linear-gradient(45deg, var(--accent-color), #007BFF);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    transition: background 0.3s ease, opacity 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
}

.fullscreen-toggle:hover {
    background: linear-gradient(45deg, #8A2BE2, #007BFF);
    border-color: #8A2BE2;
}

.fullscreen-toggle:disabled {
    background: rgba(255, 255, 255, 0.1);
    opacity: 0.5;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.1);
}

/* Typing indicator */
.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-color);
    animation: typing 1s infinite;
    margin: 0 2px;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.chat-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(26, 26, 46, 0.15) 0%, rgba(26, 26, 46, 0.05) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: 16px;
}

.start-chat-btn {
    font-family: 'Ermilov', sans-serif;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-color);
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 20px 30px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: none;
    white-space: normal;
    line-height: 1.4;
    max-width: 320px;
}

.start-chat-btn:hover {
    text-shadow: 0 0 10px #8A2BE2, 0 0 20px #8A2BE2;
    border-color: #8A2BE2;
    background-color: rgba(138, 43, 226, 0.1);
}

.overlay-logo {
    position: absolute;
    top: 54%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: auto;
    opacity: 0.1;
    z-index: -1;
}

/* New styles for side-by-side layout */
.chat-container .container {
    max-width: 1300px;
}

.chat-layout-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
}

.hero-headline {
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 30px;
}

.chat-companion-image {
    position: relative;
    z-index: 3;
    max-width: 415px;
    height: auto;
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
}

.image-3d-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#broken-wall-canvas {
    position: absolute;
    top: -50px;
    left: -50px;
    right: -50px;
    bottom: -50px;
    z-index: 1;
    mask-image: radial-gradient(ellipse at center, black 60%, transparent 85%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 60%, transparent 85%);
}

.loading-message {
    align-self: flex-start;
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--text-color);
    padding: 12px 20px;
    border-radius: 20px;
    max-width: 75%;
    line-height: 1.5;
    font-size: 0.7rem; /* Зменшено для узгодженості */
}
@media (max-width: 1024px) {
    .chat-widget.fullscreen .chat-box {
        height: calc(100dvh - 80px); /* Менша для планшетів */
    }
}

@media (max-width: 768px) {
    .chat-widget.fullscreen {
        height: 100dvh;
    }
    .chat-widget.fullscreen .chat-box {
        height: calc(100dvh - 70px); /* Ще менша для мобільних, враховуючи клавіатуру */
    }
    .chat-input-container {
        padding: 15px; /* Менші відступи */
    }
}