/* Chat Widget Styles */
.chat-widget {
    position: fixed;
    bottom: 70px; /* Position above WhatsApp button: 20px + 60px + 15px = 95px */
    right: 20px; /* Align with floating buttons */
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Chat Toggle Button */
.chat-toggle {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

@media (max-width: 768px) {
    .chat-toggle {
        width: 50px;
        height: 50px;
    }
    .chat-toggle i {
        font-size: 22px;
    }
}

@media (max-width: 576px) {
    .chat-toggle {
        width: 45px;
        height: 45px;
    }
    .chat-toggle i {
        font-size: 20px;
    }
}

@media (max-width: 400px) {
    .chat-toggle {
        width: 40px;
        height: 40px;
    }
    .chat-toggle i {
        font-size: 18px;
    }
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 123, 255, 0.5);
}

.chat-toggle i {
    color: white;
    font-size: 24px;
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px; /* Keep relative to the chat toggle button */
    right: 0;
    width: 420px; /* Increased from 350px to 420px for bigger widget */
    height: 600px; /* Increased from 500px to 600px for more space */
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-content {
    display: flex;
    align-items: center;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
}

.chat-info h6 {
    margin: 0;
    font-weight: 600;
}

.chat-status {
    font-size: 12px;
    opacity: 0.9;
}

.chat-actions {
    display: flex;
    gap: 5px;
}

.btn-minimize,
.btn-close-chat {
    background: none;
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-minimize:hover,
.btn-close-chat:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Welcome */
.chat-welcome {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
}

.welcome-content {
    text-align: center;
    width: 100%;
}

.welcome-avatar {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: white;
    font-size: 24px;
}

.welcome-content h5 {
    color: #333;
    margin-bottom: 10px;
    font-weight: 600;
}

.welcome-content p {
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
    max-height: 400px; /* Set maximum height to ensure scrolling */
    min-height: 300px; /* Set minimum height for consistent layout */
}

.message {
    margin-bottom: 16px;
    display: flex;
    align-items: center; /* Center avatar and message bubble vertically */
    flex-direction: row;
    clear: both;
    max-width: 80%;
}

.message.own {
    flex-direction: row-reverse;
    align-items: center;
    justify-content: flex-start;
    margin-left: auto;
}

.message.admin {
    /* visually distinguish admin/support messages */
    background: #f0f6ff;
    justify-content: flex-start;
    margin-right: auto;
}

.message:not(.own):not(.admin) {
    justify-content: flex-start;
}

.message-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e9ecef;
    color: #555;
    font-weight: bold;
    font-size: 16px;
    margin: 0 12px 0 0;
    flex-shrink: 0;
}

.message.own .message-avatar {
    background: #007bff;
    color: #fff;
    margin: 0 0 0 12px;
}

.message.admin .message-avatar {
    background: #0056b3;
    color: #fff;
}

.message-content {
    width: auto;
    display: flex;
    flex-direction: column;
}

.message.admin .message-content {
    max-width: none;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    max-width: 100%;
    display: inline-block;
    vertical-align: middle;
}

.message.own .message-bubble {
    background: #007bff;
    color: white;
}

.message.admin .message-bubble {
    background: #e3f0ff;
    color: #0056b3;
    border: 1px solid #b3d7ff;
}

.message:not(.own):not(.admin) .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
}

.message-info {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    text-align: right;
    opacity: 0.8;
}

.message.own .message-info {
    text-align: left;
}

/* Chat Input */
.chat-input-area {
    padding: 20px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.chat-input-area .input-group {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #ddd;
    background: white;
    position: relative;
}

.chat-input-area .form-control {
    border: none;
    padding: 16px 60px 16px 16px;
    border-radius: 12px;
    font-size: 14px;
    background: transparent;
    resize: none;
    min-height: 50px;
}

.chat-input-area .form-control:focus {
    box-shadow: none;
    border-color: transparent;
    outline: none;
}

.chat-input-area .btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: #007bff;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    z-index: 10;
    transition: background 0.2s ease;
}

.chat-input-area .btn:hover {
    background: #0056b3;
}

/* Chat Status */
.chat-status-area {
    padding: 10px 15px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    text-align: center;
}

.status-text {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* Start Chat Form */
.start-chat-form .form-control {
    border-radius: 8px;
    border: 1px solid #ddd;
    padding: 12px 15px;
}

.start-chat-form .form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.start-chat-form .btn {
    border-radius: 8px;
    padding: 12px;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-widget {
        bottom: 85px; /* Adjust for mobile: 15px + 50px + 12px gap + 8px buffer = 85px */
        right: 15px; /* Align with floating buttons on mobile */
    }
    
    .chat-window {
        width: calc(100vw - 40px); /* Account for mobile padding */
        max-width: 420px; /* Updated max-width to match new size */
        right: -15px; /* Adjust position for mobile */
    }
}

@media (max-width: 576px) {
    .chat-widget {
        bottom: 82px; /* Adjust for smaller mobile: 12px + 45px + 10px gap + 15px buffer = 82px */
        right: 12px;
    }
    
    .chat-window {
        width: calc(100vw - 30px);
        max-width: 420px;
        right: -12px;
    }
}

@media (max-width: 400px) {
    .chat-widget {
        bottom: 80px; /* Adjust for smallest mobile: 10px + 40px + 8px gap + 22px buffer = 80px */
        right: 10px;
    }
    
    .chat-window {
        width: calc(100vw - 25px);
        max-width: 420px;
        right: -10px;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px; /* Slightly wider scrollbar for better visibility */
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
    transition: background 0.2s ease;
}

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

/* Firefox scrollbar styling */
.chat-messages {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}
