/* ==================== Chat Widget Styles ==================== */

/* Floating Chat Button */
.chat-toggle-btn {
    position: fixed;
    bottom: 40px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
    border: none;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(78, 115, 223, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-toggle-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(78, 115, 223, 0.6);
}

.chat-toggle-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74a3b;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Chat Widget Container */
.chat-widget {
    position: fixed;
    bottom: 112px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.chat-widget.open {
    display: flex;
    animation: chatSlideUp 0.3s ease;
}

@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.chat-widget-header {
    background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-widget-header .chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-widget-header .chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chat-widget-header .chat-header-text h6 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.chat-widget-header .chat-header-text small {
    opacity: 0.85;
    font-size: 12px;
}

.chat-widget-header .chat-close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 0;
    line-height: 1;
}

.chat-widget-header .chat-close-btn:hover {
    opacity: 1;
}

/* Connection Status */
.chat-connection-status {
    padding: 6px 16px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    display: none;
}

.chat-connection-status.connecting {
    display: block;
    background: #fff3cd;
    color: #856404;
}

.chat-connection-status.disconnected {
    display: block;
    background: #f8d7da;
    color: #721c24;
}

/* Start Form */
.chat-start-form {
    padding: 24px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chat-start-form h6 {
    margin-bottom: 4px;
    font-weight: 600;
    color: #333;
}

.chat-start-form p {
    margin-bottom: 20px;
    color: #6c757d;
    font-size: 14px;
}

.chat-start-form .form-control {
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    border: 1.5px solid #dee2e6;
    transition: border-color 0.2s;
}

.chat-start-form .form-control:focus {
    border-color: #4e73df;
    box-shadow: 0 0 0 3px rgba(78, 115, 223, 0.15);
}

.chat-start-form .btn-start-chat {
    background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 11px;
    font-weight: 600;
    font-size: 14px;
    width: 100%;
    margin-top: 8px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.chat-start-form .btn-start-chat:hover {
    opacity: 0.9;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fc;
    min-height: 280px;
    max-height: 320px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.chat-msg.customer {
    align-self: flex-end;
}

.chat-msg.admin {
    align-self: flex-start;
}

.chat-msg .msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
}

.chat-msg.customer .msg-bubble {
    background: #4e73df;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.admin .msg-bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.chat-msg .msg-time {
    font-size: 11px;
    color: #adb5bd;
    margin-top: 3px;
    padding: 0 4px;
}

.chat-msg.customer .msg-time {
    text-align: right;
}

/* Chat Input */
.chat-input-area {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.chat-input-area .chat-input {
    flex: 1;
    border: 1.5px solid #dee2e6;
    border-radius: 20px;
    padding: 9px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
}

.chat-input-area .chat-input:focus {
    border-color: #4e73df;
}

.chat-input-area .chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #4e73df;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chat-input-area .chat-send-btn:hover {
    background: #224abe;
}

.chat-input-area .chat-send-btn:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

/* Session Closed Message */
.chat-closed-msg {
    padding: 16px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
    background: #f8f9fc;
}

/* Welcome message */
.chat-welcome {
    text-align: center;
    padding: 20px;
    color: #6c757d;
}

.chat-welcome i {
    font-size: 40px;
    color: #4e73df;
    margin-bottom: 12px;
    display: block;
}

/* Bot Message Style */
.chat-msg.bot {
    align-self: flex-start;
}

.chat-msg.bot .msg-bubble {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
    border-bottom-left-radius: 4px;
}

/* File/Image in Chat */
.chat-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
    transition: opacity 0.2s;
}

.chat-image:hover {
    opacity: 0.85;
}

.chat-file-link {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-file-link:hover {
    text-decoration: underline;
}

.chat-msg.customer .chat-file-link {
    color: #fff;
}

/* Attach Button */
.chat-attach-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: none;
    border: 1.5px solid #dee2e6;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-attach-btn:hover {
    border-color: #4e73df;
    color: #4e73df;
}

/* Upload Progress */
.chat-upload-progress {
    padding: 4px 16px 8px;
    background: #fff;
    text-align: center;
    font-size: 12px;
    color: #6c757d;
}

/* Rating Form */
.chat-rating-form {
    padding: 24px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #f8f9fc;
}

.chat-rating-form .rating-icon {
    font-size: 36px;
    color: #4e73df;
    margin-bottom: 8px;
}

.chat-rating-form h6 {
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
}

.chat-rating-form p {
    color: #6c757d;
    font-size: 14px;
    margin-bottom: 12px;
}

.rating-stars {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.rating-stars i {
    font-size: 28px;
    color: #f6c23e;
    cursor: pointer;
    transition: transform 0.15s;
}

.rating-stars i:hover {
    transform: scale(1.2);
}

.chat-rating-form .form-control {
    border-radius: 10px;
    font-size: 13px;
    max-width: 300px;
}

.chat-rating-form .btn-start-chat {
    max-width: 300px;
}

.chat-rating-form .btn-start-chat:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .chat-toggle-btn {
        bottom: 32px;
        right: 16px;
        width: 54px;
        height: 54px;
        font-size: 22px;
    }

    .chat-messages {
        max-height: calc(100vh - 200px);
    }
}
