/* ===== ПЕРЕМЕННЫЕ ===== */
:root {
    --background-image: url('/static/background2.jpg'); /* Начальное изображение */
    --background-size: 1050px 1400px; /* Размер изображения 700px на 700px */
}

/* ===== ОСНОВНЫЕ СТИЛИ ТЕЛА СТРАНИЦЫ ===== */
body {
    background-color: rgb(180, 37, 185); /* Шоколадный цвет фона */
    background-image: var(--background-image); /* Использование переменной для изображения */
    background-size: var(--background-size); /* Использование переменной для размера */
    background-position: calc(100% - 20px) 120px; /* Позиция изображения с отступом 20px от правого края и 50px от верхней части */
    background-repeat: no-repeat; /* Не повторять изображение */
    color: white; /* Цвет текста */
    font-family: Arial, sans-serif; /* Шрифт */
    text-align: left; /* Выравнивание текста слева */
    padding: 20px; /* Отступы */
    padding-right: 60px; /* Дополнительный отступ справа для предотвращения наложения текста на изображение */
}

/* ===== КЛАСС ДЛЯ ИЗМЕНЕНИЯ РАЗМЕРА ===== */
.change-size {
    --background-size: 80%; /* Новый размер изображения */
}

/* ===== МЕДИА-ЗАПРОСЫ ДЛЯ АДАПТИВНОСТИ ===== */
@media (max-width: 768px) {
    body {
        background-size: 70%; /* Уменьшение размера изображения до 70% */
        background-position: calc(100% - 80px) top; /* Позиция изображения с отступом 80px от правого края */
    }
}

@media (max-width: 480px) {
    body {
        background-size: 50%; /* Уменьшение размера изображения до 50% */
        background-position: calc(100% - 60px) top; /* Позиция изображения с отступом 60px от правого края */
    }
}

/* ===== СТИЛИ ДЛЯ АНИМАЦИИ ПЕЧАТАЮЩЕГОСЯ ТЕКСТА ===== */
#typing-text {
    color: lime; /* Цвет шрифта Салатовый */
    font-size: 20px; /* Размер шрифта */
}

/* ===== СТИЛИ ДЛЯ БЛОКОВ С КОДОМ/PRE ===== */
pre {
    background-color: rgba(37, 46, 3, 0.7); /* Полупрозрачный фон */
    padding: 20px; /* Отступы внутри блока */
    border-radius: 10px; /* Закругленные углы */
    width: 40%; /* Ширина на пол экрана */
    margin: 0; /* Убираем автоматические отступы для выравнивания по левому краю */
}

/* ===== СТИЛИ ЗАГОЛОВКОВ ===== */
title {
    color: rgb(61, 255, 35); /* Цвет заголовка */
    text-align: left; /* Расположение текста слева */
}

h1 {
    color: rgb(61, 255, 35); /* Цвет заголовка */
    text-align: left; /* Расположение текста слева */
}
    
h2 {
    color: rgb(61, 255, 35); /* Цвет подзаголовков */
}

/* ===== СТИЛИ ПАРАГРАФОВ ===== */
p {
    font-size: 20px; /* Размер шрифта для параграфов */
    text-align: left; /* Расположение текста слева */
    max-width: calc(700px - 20px); /* Максимальная ширина параграфа с учетом отступа */
    width: 100%; /* Ширина параграфа для адаптивности */
    margin-left: 20px; /* Отступ слева */
    overflow-wrap: break-word; /* Позволяет длинным словам переноситься на следующую строку */
    word-break: break-word; /* Разрешает перенос слов, если они слишком длинные */
    white-space: normal; /* Позволяет тексту переноситься на новую строку */
    text-indent: 40px; /* Отступ первой строки абзаца */
}

/* ===== СТИЛИ ССЫЛОК ===== */
.about-link, .back-link {
    display: inline-block; /* Отображение как блочный элемент */
    margin-top: 20px; /* Отступ сверху */
    color: rgb(61, 255, 35); /* Цвет гиперссылки */
    text-decoration: none; /* Убираем подчеркивание */
    font-size: 18px; /* Размер шрифта гиперссылки */
    text-align: left; /* Расположение текста слева */
}

.about-link:hover, .back-link:hover {
    text-decoration: underline; /* Подчеркивание при наведении */
}

.about-link img {
    height: 40px;
    width: auto;
}


.tech-links a {
    display: inline-block;
    margin-top: 20px;
    color: rgb(61, 255, 35);
    text-decoration: none;
    font-size: 18px;
    text-align: left;
}

.tech-links a:hover {
    text-decoration: underline;
}

/* ===== СТИЛИ ИЗОБРАЖЕНИЙ ===== */
.bars-image {
    width: 140px;
    height: 140px;
    border-radius: 10px;
    margin: 20px;
}

/* ===== СТИЛИ ДЛЯ ТОВАРОВ/ПРОДУКТОВ ===== */
.product-description {
    font-weight: bold;
    color: yellow;
    font-size: 22px;
    text-shadow: 1px 1px 0px black;
    text-align: left; /* Расположение текста слева */
}

.product-head {
    font-weight: bold;
    color: rgb(61, 255, 35);
    font-size: 30px;
    text-shadow: 1px 1px 0px black;
    margin-top: 20px;
    text-align: left;
}

/* ===== СТИЛИ ВЫВОДА ===== */
#output {
    color: rgb(16, 233, 16);
    text-shadow: 1px 1px 0px black;
    font-size: 54px;
    margin-top: 30px;
    margin-left: 140px;
}

/* ===== АНИМАЦИЯ МИГАНИЯ ===== */
.blink {
    color: rgb(186, 233, 15);
    font-size: 24px;
    display: inline-block;
    width: 20px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    vertical-align: middle;
    position: relative;
    overflow: hidden;
}

.blink::before {
    content: 'I';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgb(236, 178, 18);
    animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
    0%, 100% { clip-path: inset(0 0 100% 0); }
    50% { clip-path: inset(0); }
}

/* ===== КОНТЕЙНЕРЫ СКРИПТОВ ===== */
.script-container {
    margin-left: 150px;
}

/* ===== АНИМАЦИЯ ГАЛЕРЕИ ИЗОБРАЖЕНИЙ ===== */
.image-gallery {
    display: flex;
    justify-content: left;
    flex-wrap: wrap;
    gap: 20px;
    margin: 30px 0;
}

.bars-image {
    width: 140px;
    height: 140px;
    border-radius: 10px;
    margin: 20px;
    transition: all 0.3s ease-in-out;
    cursor: pointer;
    object-fit: cover;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.bars-image:hover {
    transform: scale(1.2); /* Увеличение на 20% */
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    z-index: 10; /* Поднимаем над другими элементами */
}

/* Плавное появление изображений при загрузке */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.bars-image {
    animation: fadeInScale 0.5s ease-out;
}

/* Задержка анимации для каждого изображения */
.bars-image:nth-child(1) { animation-delay: 0.1s; }
.bars-image:nth-child(2) { animation-delay: 0.2s; }
.bars-image:nth-child(3) { animation-delay: 0.3s; }
.bars-image:nth-child(4) { animation-delay: 0.4s; }

.bars-image:hover {
    border: 3px solid rgba(61, 255, 35, 0.8); /* Зеленая граница */
    filter: brightness(1.1); /* Легкое увеличение яркости */
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .image-gallery {
        gap: 15px;
    }
    
    .bars-image {
        width: 100px;
        height: 100px;
        margin: 10px;
    }
    
    .bars-image:hover {
        transform: scale(1.15); /* Меньшее увеличение на мобильных */
    }
}

@media (max-width: 480px) {
    .image-gallery {
        gap: 10px;
    }
    
    .bars-image {
        width: 80px;
        height: 80px;
        margin: 8px;
    }
}

/* ===== СОВРЕМЕННЫЙ ЧАТ-БОКС (ИНТЕГРИРОВАННЫЙ) ===== */
#chat-box {
    width: 380px;
    max-width: 90%;
    border: none;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 500px;
    position: fixed;
    top: 65%;
    left: 20px;
    transform: translateY(-50%);
    width: 380px;
    height: 500px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.2) inset;
    backdrop-filter: blur(10px);
    margin: 20px auto;
    animation: chatSlideIn 0.5s ease-out;
}

/* Градиентная рамка */
#chat-box::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #007bff, #b69cd8, #3f51b5);
    border-radius: 22px;
    z-index: -1;
    animation: borderGlow 3s ease-in-out infinite alternate;
}

@keyframes borderGlow {
    0% { opacity: 0.7; }
    100% { opacity: 1; }
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Заголовок чата */
.chat-header {
    background: linear-gradient(135deg, #5d5385 0%, #9779b6 100%);
    color: rgb(255, 255, 255);
    padding: 15px 20px;
    text-align: center;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.chat-header::before {
    content: '💬';
    font-size: 18px;
}

/* Контейнер сообщений */
#chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: rgba(110, 59, 129, 0.8);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Полоса прокрутки */
#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, #007bff, #00bcd4);
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(45deg, #0056b3, #0097a7);
}

/* Контейнер ввода */
.chat-input-container {
    display: flex;
    padding: 15px;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    gap: 10px;
    align-items: center;
}

#chat-input {
    flex: 1;
    border: none;
    padding: 12px 16px;
    border-radius: 25px;
    background: rgba(0, 123, 255, 0.1);
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) inset;
}

#chat-input:focus {
    background: rgba(0, 123, 255, 0.15);
    box-shadow: 
        0 2px 8px rgba(0, 123, 255, 0.2) inset,
        0 0 0 2px rgba(0, 123, 255, 0.3);
}

#chat-input::placeholder {
    color: #6c757d;
}

#send-button {
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    background: linear-gradient(135deg, #4014b8 0%, #521ad4 100%);
    color: rgb(245, 245, 245);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
}

#send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(171, 6, 236, 0.4);
}

#send-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(153, 0, 255, 0.3);
}

/* ===== СОВРЕМЕННЫЕ СТИЛИ СООБЩЕНИЙ ===== */
.message {
    margin: 5px 0;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 80%;
    position: relative;
    animation: messageAppear 0.3s ease-out;
    line-height: 1.4;
    word-wrap: break-word;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.user-message {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: rgb(255, 255, 255);
    align-self: flex-end;
    margin-left: 20%;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.2);
}

.user-message::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-left-color: #007bff;
    border-right: 0;
}

.assistant-message {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #2c3e50;
    align-self: flex-start;
    margin-right: 20%;
    border-bottom-left-radius: 6px;
    box-shadow: 0 4px 10px rgba(33, 150, 243, 0.1);
}

.assistant-message::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-right-color: #e3f2fd;
    border-left: 0;
}

/* Индикатор набора */
.typing-indicator {
    background: rgba(0, 0, 0, 0.05);
    color: #6c757d;
    font-style: italic;
    padding: 10px 16px;
    border-radius: 18px;
    align-self: flex-start;
}

.typing-dots {
    display: inline-flex;
    gap: 3px;
    margin-right: 8px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6c757d;
    animation: typingDots 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingDots {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Статус сообщений */
.status-message {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.2);
    text-align: center;
    font-size: 12px;
    padding: 8px 12px;
}

.error-message {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.2);
    text-align: center;
    font-size: 12px;
    padding: 8px 12px;
}

/* Время сообщений */
.message-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

/* Адаптивность чата */
@media (max-width: 768px) {
    #chat-box {
        width: 100%;
        height: 400px;
        margin: 10px 0;
        border-radius: 15px;
    }
    
    .chat-header {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    #chat-messages {
        padding: 15px;
    }
    
    .message {
        max-width: 85%;
        padding: 10px 14px;
    }
    
    #chat-input {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    #send-button {
        padding: 10px 16px;
        font-size: 13px;
    }
}