.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #198754;
    color: #fff;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 9998;
    transition: transform 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-fab:hover {
    transform: scale(1.1);
    background: #157347;
}

.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 370px;
    max-height: 520px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: #198754;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 1rem;
}

.chat-header-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-header-btn:hover {
    opacity: 1;
}

.chat-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-body {
    padding: 20px 16px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.chat-form-intro p {
    margin-bottom: 16px;
    color: #555;
    font-size: 0.95rem;
}

.chat-waiting-content {
    text-align: center;
    padding: 30px 10px;
}

.chat-ended-content {
    text-align: center;
    padding: 20px 10px;
}

.chat-offline-content {
    text-align: center;
    padding: 20px 10px;
}

.chat-message-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    min-height: 250px;
    max-height: 320px;
}

.chat-msg {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
}

.chat-msg-visitor {
    align-items: flex-end;
}

.chat-msg-admin,
.chat-msg-system {
    align-items: flex-start;
}

.chat-msg-bubble {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-msg-visitor .chat-msg-bubble {
    background: #198754;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg-admin .chat-msg-bubble {
    background: #e9ecef;
    color: #212529;
    border-bottom-left-radius: 4px;
}

.chat-msg-system .chat-msg-bubble {
    background: transparent;
    color: #6c757d;
    font-size: 0.8rem;
    font-style: italic;
    text-align: center;
    max-width: 100%;
}

.chat-msg-sender {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 2px;
    padding: 0 4px;
}

.chat-msg-time {
    font-size: 0.7rem;
    color: #aaa;
    margin-top: 2px;
    padding: 0 4px;
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 8px 0 4px;
    flex-shrink: 0;
}

.chat-input-area .form-control {
    border-radius: 20px;
    font-size: 0.9rem;
}

.chat-input-area .btn {
    border-radius: 50%;
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-actions {
    text-align: center;
    padding: 6px 0 2px;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .chat-widget {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 10px;
        max-height: calc(100vh - 80px);
    }

    .chat-fab {
        bottom: 16px;
        right: 16px;
    }
}
