* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0e1621;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.chat-container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    background: #17212b;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: #17212b;
    color: #ffffff;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid #242f3d;
    position: relative;
    z-index: 1;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
}

.header-content h1 {
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    color: #ffffff;
    margin: 0;
}

.faq-button {
    background: linear-gradient(135deg, #2b5278 0%, #1e3a52 100%);
    color: #6ab7ff;
    border: 1px solid #3d6a99;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
    overflow: visible;
    z-index: 100;
}

.faq-button:hover {
    background: linear-gradient(135deg, #3d6a99 0%, #2b5278 100%);
    color: #ffffff;
    border-color: #5288c1;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.faq-button:active {
    transform: scale(0.98);
}

.faq-tooltip {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: #182533;
    border: 1px solid #2b5278;
    border-radius: 12px;
    padding: 20px;
    min-width: 400px;
    max-width: 500px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

.faq-button:hover .faq-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.faq-content {
    color: #e4ecf0;
    font-size: 14px;
    line-height: 1.6;
}

.faq-content p {
    margin: 0 0 12px 0;
}

.faq-content p:last-child {
    margin-bottom: 0;
}

.faq-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.faq-content li {
    margin: 6px 0;
}

.faq-content strong {
    color: #6ab7ff;
}

.faq-link {
    color: #6ab7ff;
    text-decoration: none;
    transition: color 0.2s;
}

.faq-link:hover {
    color: #4a9eff;
    text-decoration: underline;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.refresh-button {
    background: linear-gradient(135deg, #2b5278 0%, #1e3a52 100%);
    color: #6ab7ff;
    border: 1px solid #3d6a99;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
    overflow: hidden;
}

.refresh-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(106, 183, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.refresh-button:hover {
    background: linear-gradient(135deg, #3d6a99 0%, #2b5278 100%);
    color: #ffffff;
    border-color: #5288c1;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), 0 0 12px rgba(106, 183, 255, 0.2);
    transform: translateY(-1px);
}

.refresh-button:hover::before {
    width: 300px;
    height: 300px;
}

.refresh-button:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.refresh-button:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(106, 183, 255, 0.5);
}

.refresh-indicator {
    font-size: 12px;
    color: #708499;
    text-align: center;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #0e1621;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #17212b;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #2b5278;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #3d6a99;
}

.message {
    display: flex;
    flex-direction: column;
    width: 100%;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    background: #182533;
    border-radius: 8px;
    padding: 10px 14px;
    position: relative;
    word-wrap: break-word;
    border-left: 3px solid #5288c1;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.username-container {
    position: relative;
    display: inline-block;
}

.message-username {
    font-weight: 600;
    color: #6ab7ff;
    font-size: 15px;
    cursor: pointer;
    transition: color 0.2s;
    text-decoration: none;
}

.message-username:hover {
    color: #4a9eff;
    text-decoration: underline;
}

.username-container:hover .message-username {
    color: #4a9eff;
}

.message-rating {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(255, 193, 7, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background-color 0.2s ease;
}

.message-user-type {
    background: #2b5278;
    color: #6ab7ff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.message-text {
    color: #e4ecf0;
    font-size: 15px;
    line-height: 1.5;
    margin-top: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-link {
    color: #6ab7ff;
    text-decoration: none;
    transition: color 0.2s;
}

.message-link:hover {
    color: #4a9eff;
    text-decoration: underline;
}

.message-date {
    font-size: 12px;
    color: #708499;
    margin-top: 6px;
    text-align: right;
}

.loading {
    text-align: center;
    color: #708499;
    padding: 40px;
    font-size: 16px;
}

/* Tooltip для пользователя */
.username-tooltip {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: #182533;
    border: 1px solid #2b5278;
    border-radius: 8px;
    padding: 12px 16px;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transform: translateY(5px);
    transition: opacity 0.2s, transform 0.2s;
}

/* Если tooltip близко к верху, показываем его снизу */
.username-container:first-child .username-tooltip,
.message:first-child .username-tooltip {
    bottom: auto;
    top: 100%;
    margin-bottom: 0;
    margin-top: 8px;
}

.username-container:hover .username-tooltip {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.tooltip-rating {
    color: #ffc107;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tooltip-link {
    color: #6ab7ff;
    text-decoration: none;
    font-size: 14px;
    display: inline-block;
    transition: color 0.2s;
}

.tooltip-link:hover {
    color: #4a9eff;
    text-decoration: underline;
}

/* Адаптивность */
@media (max-width: 768px) {
    .chat-container {
        height: 100vh;
        border-radius: 0;
    }
    
    body {
        padding: 0;
    }
    
    .faq-button {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .faq-tooltip {
        min-width: 300px;
        max-width: 90vw;
        top: 70px;
    }
}

