/* ===== ОСНОВНЫЕ СТИЛИ ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scroll-behavior: smooth;
    text-wrap: balance;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0a0a0a;
    min-height: 100vh;
    color: #ffffff;
}

/* ===== КОНТЕЙНЕР ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== ШАПКА ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.95);
    border-bottom: 3px solid #ffd000;
    border-radius: 12px 12px 0 0;
    margin-bottom: 30px;
    box-shadow: 0 4px 30px rgba(255, 208, 0, 0.15);
}

header h1 {
    color: #ffd000;
    font-size: 2rem;
    text-shadow: 0 0 20px rgba(255, 208, 0, 0.3);
}

header p {
    color: #cccccc;
    font-size: 1.1rem;
}

/* ===== ХЕДЕР ЧАТА ===== */
.chat-header-page {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.95);
    border-bottom: 3px solid #ffd000;
    border-radius: 12px 12px 0 0;
    margin-bottom: 20px;
}

.chat-header-page .header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.chat-header-page .header-left h1 {
    color: #ffd000;
    font-size: 1.5rem;
    text-shadow: 0 0 20px rgba(255, 208, 0, 0.2);
}

.back-button {
    color: #ffd000;
    text-decoration: none;
    font-weight: 600;
    padding: 8px 18px;
    border: 2px solid #ffd000;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.back-button:hover {
    background: #ffd000;
    color: #0a0a0a;
    box-shadow: 0 0 25px rgba(255, 208, 0, 0.3);
}

.delete-chat {
    background: transparent;
    color: #ff6b6b;
    border: 2px solid #ff6b6b;
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.delete-chat:hover {
    background: #ff6b6b;
    color: #0a0a0a;
    box-shadow: 0 0 25px rgba(255, 107, 107, 0.3);
}

/* ===== КАРТОЧКИ ЧАТОВ ===== */
.chats-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.chat-card {
    background: rgba(255, 208, 0, 0.05);
    border: 2px solid rgba(255, 208, 0, 0.2);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-card:hover {
    transform: translateY(-5px);
    border-color: #ffd000;
    background: rgba(255, 208, 0, 0.1);
    box-shadow: 0 8px 30px rgba(255, 208, 0, 0.15);
}

.chat-card .chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.chat-card .chat-header h4 {
    color: #ffd000;
    font-size: 1.2rem;
}

.chat-card .message-count {
    color: #888;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 12px;
    border-radius: 20px;
}

.chat-card .chat-date {
    color: #666;
    font-size: 0.85rem;
}

/* ===== НОВЫЙ ЧАТ ===== */
.new-chat-card {
    background: rgba(255, 208, 0, 0.05);
    border: 2px solid rgba(255, 208, 0, 0.2);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
}

.new-chat-card h3 {
    color: #ffd000;
    font-size: 1.3rem;
    margin-bottom: 15px;
}

.new-chat-form {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.new-chat-form input {
    flex: 1;
    min-width: 200px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 208, 0, 0.2);
    border-radius: 8px;
    color: #ffffff;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.new-chat-form input:focus {
    outline: none;
    border-color: #ffd000;
    box-shadow: 0 0 20px rgba(255, 208, 0, 0.1);
}

.new-chat-form input::placeholder {
    color: #666;
}

/* ===== ОБЛАСТЬ СООБЩЕНИЙ ===== */
.chat-container {
    background: rgba(0, 0, 0, 0.8);
    border-radius: 12px;
    border: 1px solid rgba(255, 208, 0, 0.15);
    overflow: hidden;
}

.chat-messages {
    height: 500px;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(0, 0, 0, 0.4);
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ffd000;
    border-radius: 4px;
}

/* ===== СООБЩЕНИЯ ===== */
.message {
    max-width: 80%;
    animation: fadeInUp 0.3s ease;
}

.user-message {
    align-self: flex-end;
}

.bot-message {
    align-self: flex-start;
}

.message-content {
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 1rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.user-message .message-content {
    background: linear-gradient(135deg, #ffd000, #f5c400);
    color: #0a0a0a;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    background: rgba(255, 208, 0, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 208, 0, 0.2);
    border-bottom-left-radius: 4px;
}

.bot-message .message-content code {
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: #ffd000;
}

.bot-message .message-content pre {
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid rgba(255, 208, 0, 0.1);
    margin: 10px 0;
}

.bot-message .message-content pre code {
    background: transparent;
    padding: 0;
    color: #ffd000;
}

.bot-message .message-content h1,
.bot-message .message-content h2,
.bot-message .message-content h3 {
    color: #ffd000;
    margin: 15px 0 10px 0;
}

.bot-message .message-content ul,
.bot-message .message-content ol {
    padding-left: 25px;
    margin: 10px 0;
}

.bot-message .message-content a {
    color: #ffd000;
    text-decoration: underline;
}

.bot-message .message-content blockquote {
    border-left: 4px solid #ffd000;
    padding-left: 15px;
    margin: 10px 0;
    color: #cccccc;
}

.bot-message .message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
}

.bot-message .message-content th,
.bot-message .message-content td {
    border: 1px solid rgba(255, 208, 0, 0.2);
    padding: 8px 12px;
    text-align: left;
}

.bot-message .message-content th {
    background: rgba(255, 208, 0, 0.1);
    color: #ffd000;
}

/* ===== ОБЛАСТЬ ВВОДА ===== */
.input-area {
    padding: 20px;
    background: rgba(0, 0, 0, 0.6);
    border-top: 1px solid rgba(255, 208, 0, 0.1);
}

.chat-form {
    display: flex;
    gap: 15px;
}

.chat-form input {
    flex: 1;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 208, 0, 0.2);
    border-radius: 8px;
    color: #ffffff;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.chat-form input:focus {
    outline: none;
    border-color: #ffd000;
    box-shadow: 0 0 20px rgba(255, 208, 0, 0.1);
}

.chat-form input::placeholder {
    color: #666;
}

.chat-form input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== КНОПКИ ===== */
button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #ffd000, #f5c400);
    color: #0a0a0a;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 208, 0, 0.3);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

#submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 120px;
}

/* ===== ИНДИКАТОР ПЕЧАТИ ===== */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    background: rgba(255, 208, 0, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 208, 0, 0.1);
    margin-bottom: 15px;
    color: #cccccc;
    font-size: 0.95rem;
}

.typing-dots {
    display: flex;
    gap: 5px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffd000;
    animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ===== СПИННЕР ===== */
.spinner {
    border: 2px solid rgba(10, 10, 10, 0.1);
    border-top: 2px solid #0a0a0a;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== НАСТРОЙКИ СКОРОСТИ ===== */
.speed-controls {
    margin-top: 30px;
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 12px;
    border: 1px solid rgba(255, 208, 0, 0.15);
}

.speed-controls h3 {
    color: #ffd000;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.speed-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.speed-buttons button {
    padding: 8px 18px;
    background: rgba(255, 208, 0, 0.1);
    color: #ffd000;
    border: 2px solid rgba(255, 208, 0, 0.2);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.speed-buttons button:hover {
    background: rgba(255, 208, 0, 0.2);
    border-color: #ffd000;
    transform: translateY(-2px);
}

.speed-buttons span {
    color: #cccccc;
    margin-left: 10px;
}

#current-speed {
    color: #ffd000;
    font-weight: 700;
}

/* ===== АНИМАЦИИ ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== АДАПТИВНОСТЬ ===== */
@media screen and (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        text-align: center;
        padding: 15px 20px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .chat-header-page {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 15px 20px;
    }

    .chat-header-page .header-left {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .chat-header-page .header-left h1 {
        font-size: 1.2rem;
    }

    .chat-form {
        flex-direction: column;
    }

    #submit-btn {
        min-width: 100%;
    }

    .message {
        max-width: 95%;
    }

    .speed-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .chats-list {
        grid-template-columns: 1fr;
    }

    .new-chat-form {
        flex-direction: column;
    }

    .new-chat-form input {
        min-width: auto;
    }
}

@media screen and (max-width: 480px) {
    header h1 {
        font-size: 1.2rem;
    }

    .chat-messages {
        height: 350px;
        padding: 15px;
    }

    .message-content {
        font-size: 0.9rem;
        padding: 10px 14px;
    }

    .speed-controls {
        padding: 15px;
    }

    .back-button,
    .delete-chat {
        text-align: center;
        width: 100%;
    }
}

/* ===== СОСТОЯНИЕ "НЕТ ЧАТОВ" ===== */
.no-chats {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.no-chats h3 {
    color: #ffd000;
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.no-chats p {
    color: #666;
}

/* ===== СТИЛИ ДЛЯ СТРАНИЦЫ ОШИБКИ ===== */
.error {
    color: #ff6b6b;
    text-align: center;
    padding: 40px 20px;
    font-size: 1.1rem;
}