/* Chat Widget Container */
.chat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999; /* Increased z-index to ensure it's above everything */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    max-width: 380px; /* Prevent widget from becoming too wide */
}
/* Chat Toggle Button */
.chat-toggle-button {
    position: relative;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(220, 38, 38, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
    min-width: 160px;
    height: 60px;
}
.chat-toggle-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(220, 38, 38, 0.5);
}
.chat-button-content {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: white;
}
.chat-icon {
    font-size: 24px;
    margin-right: 12px;
}
.chat-button-text {
    flex: 1;
}
.chat-button-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
}
.chat-button-subtitle {
    font-size: 12px;
    opacity: 0.9;
    line-height: 1.2;
}
.online-indicator {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    margin-left: 8px;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    max-width: 100%; /* Ensure it doesn't exceed viewport */
    height: 600px;
    max-height: calc(100vh - 120px); /* Ensure it fits on screen */
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}
.chat-window.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
}
/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.chat-header-info {
    display: flex;
    align-items: center;
}
.agent-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: 12px;
    font-size: 18px;
}
.agent-details .agent-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 2px;
}
.agent-status {
    display: flex;
    align-items: center;
    font-size: 12px;
    opacity: 0.9;
}
.status-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-indicator.online {
    background: #10b981;
}
.chat-actions {
    display: flex;
    gap: 8px;
}
.chat-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}
/* Pre-Chat Form */
.pre-chat-form {
    flex: 1;
    padding: 0;
    overflow-y: auto;
}
.pre-chat-content {
    padding: 24px;
}
.welcome-message {
    text-align: center;
    margin-bottom: 24px;
}
.welcome-message h3 {
    color: #1f2937;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}
.welcome-message p {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}
.chat-contact-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.form-group {
    display: flex;
    flex-direction: column;
}
.form-group label {
    font-weight: 500;
    color: #374151;
    font-size: 14px;
    margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}
.start-chat-btn {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.start-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}
.chat-privacy-notice {
    text-align: center;
    margin-top: 16px;
    color: #6b7280;
    font-size: 12px;
}
/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
}
.messages-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.message {
    display: flex;
    flex-direction: column;
}
.message.system-message .message-content {
    background: #dbeafe;
    color: #1e40af;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
}
.message.user-message .message-content {
    background: #dc2626;
    color: white;
    border-radius: 18px 18px 4px 18px;
    padding: 12px 16px;
    margin-left: 60px;
    align-self: flex-end;
}
.message.agent-message .message-content {
    background: white;
    color: #1f2937;
    border-radius: 18px 18px 18px 4px;
    padding: 12px 16px;
    margin-right: 60px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.message-text {
    font-size: 14px;
    line-height: 1.4;
}
.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
}
/* Chat Input Area */
.chat-input-area {
    border-top: 1px solid #e5e7eb;
    background: white;
}
.typing-indicator {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 13px;
}
.typing-dots {
    display: flex;
    gap: 3px;
}
.typing-dots span {
    width: 4px;
    height: 4px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}
.chat-input-container {
    padding: 16px;
}
.input-wrapper {
    display: flex;
    align-items: center;
    background: #f3f4f6;
    border-radius: 24px;
    padding: 8px;
    gap: 8px;
}
.input-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: #6b7280;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.input-action-btn:hover {
    background: #e5e7eb;
    color: #374151;
}
#chatInput {
    flex: 1;
    border: none;
    background: none;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
}
.send-button {
    width: 32px;
    height: 32px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.send-button:hover {
    background: #b91c1c;
    transform: scale(1.05);
}
.send-button:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
}
/* Quick Replies */
.quick-replies {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.quick-reply-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.quick-reply-item:hover {
    background: #f3f4f6;
    border-color: #dc2626;
}
.quick-reply-item i {
    font-size: 12px;
    color: #dc2626;
}
/* Chat Footer */
.chat-footer {
    padding: 12px 16px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-footer-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #6b7280;
}
.status-dot {
    width: 4px;
    height: 4px;
    background: #10b981;
    border-radius: 50%;
}
.response-time {
    font-size: 10px;
    color: #9ca3af;
}
.chat-footer-actions {
    display: flex;
    gap: 8px;
}
.footer-action {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: #6b7280;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.footer-action:hover {
    background: #e5e7eb;
    color: #374151;
}
@media (max-width: 768px) {
    .chat-widget-container {
        bottom: 15px;
        right: 15px;
        max-width: calc(100vw - 30px); /* Ensure it fits on mobile */
    }
    .chat-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 120px);
        bottom: 70px;
        right: 0; /* Align with container */
        border-radius: 12px; /* Slightly smaller radius for mobile */
    }
    .chat-toggle-button {
        min-width: 120px;
        height: 50px;
        border-radius: 25px;
    }
    .chat-button-content {
        padding: 10px 16px;
    }
    .chat-icon {
        font-size: 20px;
        margin-right: 8px;
    }
    .chat-button-title {
        font-size: 13px;
    }
    .chat-button-subtitle {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .chat-widget-container {
        bottom: 10px;
        right: 10px;
        max-width: calc(100vw - 20px);
    }
    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 60px;
        right: 0;
        border-radius: 8px; /* Even smaller radius for very small screens */
    }
    .chat-toggle-button {
        min-width: 100px;
        height: 45px;
        border-radius: 22px;
    }
    .chat-button-content {
        padding: 8px 12px;
    }
    .chat-icon {
        font-size: 18px;
        margin-right: 6px;
    }
    .chat-button-title {
        font-size: 12px;
    }
    .chat-button-subtitle {
        font-size: 10px;
    }
}
.hidden {
    display: none !important;
}

/* Ensure chat widget doesn't conflict with other fixed elements */
.chat-widget-container {
    /* Ensure it doesn't interfere with any existing layout */
    pointer-events: auto !important;
}

/* Fix any potential margin/padding issues */
.chat-widget-container * {
    box-sizing: border-box;
}

/* Prevent any layout shift when chat widget appears */
body:has(.chat-widget-container) {
    /* Ensure smooth interaction without layout shifts */
    overflow-x: hidden;
}