.chat-widget {
    display: none;
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 380px;
    height: 520px;
    background: rgba(18, 18, 40, 0.98);
    border: 1px solid rgba(66, 245, 240, 0.4);
    border-radius: 20px;
    z-index: 1000;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(66, 245, 240, 0.15);
    backdrop-filter: blur(20px);
    font-family: 'Space Mono', monospace;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-widget.active {
    transform: translateY(0);
    opacity: 1;
}

.chat-header {
    background: linear-gradient(135deg, #0f3460 0%, #1a1a2e 100%);
    padding: 20px;
    border-radius: 20px 20px 0 0;
    border-bottom: 1px solid rgba(66, 245, 240, 0.3);
    position: relative;
}

.chat-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--neon-blue) 50%, 
        transparent 100%);
}

.chat-title {
    color: var(--neon-blue);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.5px;
}

.chat-status {
    float: right;
    font-size: 12px;
    padding: 6px 12px;
    background: rgba(76, 175, 80, 0.25);
    border-radius: 12px;
    border: 1px solid rgba(76, 175, 80, 0.4);
    font-weight: 600;
}

.close-chat {
    float: right;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    margin-left: 15px;
    font-size: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: bold;
}

.close-chat:hover {
    background: var(--neon-blue);
    color: var(--space-dark);
    transform: rotate(90deg);
}

.chat-messages {
    height: 360px;
    overflow-y: auto;
    padding: 0;
    background: rgba(12, 12, 28, 0.6);
}

.chat-messages-container {
    padding: 20px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, var(--neon-blue), var(--accent-purple));
    border-radius: 4px;
}

.chat-input-area {
    padding: 20px;
    border-top: 1px solid rgba(66, 245, 240, 0.2);
    background: rgba(20, 25, 45, 0.9);
    backdrop-filter: blur(10px);
}

.chat-input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(66, 245, 240, 0.3);
    border-radius: 25px;
    color: white;
    font-size: 16px;
    font-family: 'Space Mono', monospace;
    transition: all 0.3s ease;
    resize: none;
    min-height: 55px;
    max-height: 120px;
    line-height: 1.4;
}

.chat-input:focus {
    outline: none;
    border-color: var(--neon-blue);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(66, 245, 240, 0.1);
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
    font-size: 15px;
}

.send-button {
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--neon-blue), #20b2aa);
    color: #0a0a2e;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    transition: all 0.3s ease;
    min-width: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 15px rgba(66, 245, 240, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.send-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #20b2aa, var(--neon-blue));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(66, 245, 240, 0.4);
}

.send-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(66, 245, 240, 0.3);
}

.send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chat-toggle-button {
    position: fixed;
    bottom: 25px;
    right: 25px;
    padding: 16px 24px;
    background: rgba(10, 10, 30, 0.95);
    color: #42f5f0;
    border: 2px solid #42f5f0;
    border-radius: 50px;
    cursor: pointer;
    z-index: 999;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.6),
        0 0 15px rgba(66, 245, 240, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    font-weight: 600;
    font-size: 15px;
    font-family: 'Space Mono', monospace;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(10px);
}

.chat-toggle-button:hover {
    transform: translateY(-2px);
    background: rgba(15, 15, 40, 0.98);
    border-color: #52ffff;
    color: #52ffff;
    box-shadow: 
        0 6px 25px rgba(0, 0, 0, 0.7),
        0 0 20px rgba(66, 245, 240, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.chat-message {
    margin-bottom: 18px;
    padding: 14px 18px;
    border-radius: 18px;
    max-width: 85%;
    word-wrap: break-word;
    position: relative;
    animation: messageSlideIn 0.4s ease-out;
    font-size: 15px;
    line-height: 1.5;
}

.message-client {
    background: linear-gradient(135deg, var(--neon-blue), #20b2aa);
    margin-left: auto;
    color: #0a0a2e;
    border-bottom-right-radius: 8px;
    box-shadow: 0 2px 10px rgba(66, 245, 240, 0.3);
}

.message-operator {
    background: linear-gradient(135deg, #2d2d5a, #21214d);
    margin-right: auto;
    color: #ffffff;
    border: 1px solid rgba(66, 245, 240, 0.25);
    border-bottom-left-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.message-system {
    text-align: center;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin: 15px 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-sender {
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 14px;
    opacity: 0.9;
}

.message-client .message-sender {
    color: #0a0a2e;
}

.message-operator .message-sender {
    color: var(--neon-blue);
}

.message-text {
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 5px;
}

.message-time {
    font-size: 12px;
    opacity: 0.7;
    text-align: right;
}

.message-typing {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: rgba(66, 245, 240, 0.15);
    border-radius: 18px;
    border-bottom-left-radius: 8px;
    color: var(--neon-blue);
    font-style: italic;
    font-size: 14px;
    border: 1px solid rgba(66, 245, 240, 0.2);
}

.typing-dots {
    display: inline-flex;
    gap: 3px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-notification {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--stardust);
    border-radius: 50%;
    color: white;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
    font-weight: bold;
    box-shadow: 0 0 10px var(--stardust);
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 10px var(--stardust); }
    50% { transform: scale(1.1); box-shadow: 0 0 20px var(--stardust); }
    100% { transform: scale(1); box-shadow: 0 0 10px var(--stardust); }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .chat-widget {
        width: calc(100vw - 30px);
        height: 75vh;
        right: 15px;
        left: 15px;
        bottom: 85px;
        border-radius: 16px;
    }
    
    .chat-messages {
        height: calc(75vh - 150px);
    }
    
    .chat-header {
        padding: 16px;
    }
    
    .chat-title {
        font-size: 16px;
    }
    
    .chat-messages-container {
        padding: 16px;
    }
    
    .chat-input-area {
        padding: 16px;
    }
    
    .chat-input {
        font-size: 16px;
        padding: 14px 18px;
    }
    
    .send-button {
        padding: 14px 18px;
        min-width: 60px;
        font-size: 16px;
    }
    
    .chat-toggle-button {
        bottom: 20px;
        right: 20px;
        padding: 16px 22px;
        font-size: 15px;
    }
    
    .chat-message {
        font-size: 14px;
        max-width: 90%;
        padding: 12px 16px;
    }
    
    .message-text {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .chat-widget {
        width: calc(100vw - 20px);
        right: 10px;
        left: 10px;
        bottom: 80px;
        height: 70vh;
    }
    
    .chat-messages {
        height: calc(70vh - 140px);
    }
    
    .chat-header {
        padding: 14px;
    }
    
    .chat-messages-container {
        padding: 14px;
    }
    
    .chat-input-area {
        padding: 14px;
    }
    
    .chat-input-container {
        gap: 8px;
    }
    
    .chat-input {
        padding: 12px 16px;
        font-size: 16px;
    }
    
    .send-button {
        padding: 12px 16px;
        min-width: 55px;
    }
    
    .chat-toggle-button {
        bottom: 15px;
        right: 15px;
        padding: 14px 20px;
        font-size: 14px;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 360px) {
    .chat-widget {
        width: calc(100vw - 10px);
        right: 5px;
        left: 5px;
    }
    
    .chat-input {
        font-size: 16px; /* Минимальный размер шрифта для читаемости */
    }
    
    .message-text {
        font-size: 14px;
    }
}

/* Анимации для пользователей с предпочтением reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .chat-widget,
    .chat-message,
    .chat-toggle-button,
    .send-button {
        transition: none;
        animation: none;
    }
    
    .typing-dot {
        animation: none;
    }
    
    .chat-notification {
        animation: none;
    }
}

/* Улучшение читаемости для людей с ослабленным зрением */
@media (prefers-contrast: high) {
    .chat-widget {
        background: #121225;
        border: 2px solid var(--neon-blue);
    }
    
    .chat-input {
        background: #1a1a1a;
        border: 2px solid var(--neon-blue);
    }
    
    .send-button {
        background: var(--neon-blue);
        color: #000;
    }
}

/* Поддержка темной темы по умолчанию */
@media (prefers-color-scheme: dark) {
    .chat-widget {
        background: rgba(15, 15, 25, 0.98);
    }
}