/* Chat Widget Styles */
.chat-widget-container {
    position: fixed;
    bottom: 90px;
    right: 28px;
    z-index: 9997;
}

.chat-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e63946 0%, #c0303c 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(230,57,70,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    animation: pulse 2s infinite;
}

.chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(230,57,70,0.5);
}

.chat-widget-button .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f4a435;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.chat-widget-preview {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 320px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(13,35,64,0.2);
    border: 1px solid #e4e8ef;
    display: none;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chat-widget-preview.active {
    display: block;
}

.chat-preview-header {
    background: linear-gradient(135deg, #0d2340 0%, #1e3c72 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-preview-header h4 {
    margin: 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-preview-header h4 i {
    color: #e63946;
}

.chat-preview-header button {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.chat-preview-header button:hover {
    color: white;
}

/* Chat Messages Container */
.chat-preview-messages {
    height: 250px;
    overflow-y: auto;
    padding: 16px;
    background: #ffffff;
    display: none; /* Hidden by default */
    min-height: 200px;
    max-height: 300px;
}

.chat-preview-messages.active {
    display: block;
}

/* Ensure messages are visible */
.chat-preview-messages .chat-preview-message {
    margin-bottom: 12px;
    clear: both;
}

/* Individual Message Styles */
.chat-preview-message {
    margin-bottom: 12px;
    font-size: 0.9rem;
    animation: fadeInMessage 0.3s ease;
}

.chat-preview-message.agent {
    text-align: left;
}

.chat-preview-message.agent div {
    background: #f0f2f5;
    padding: 8px 12px;
    border-radius: 12px 12px 12px 4px;
    display: inline-block;
    max-width: 80%;
    color: #0d2340;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    position: relative;
}

.chat-preview-message.agent div small {
    display: block;
    margin-bottom: 4px;
    color: #6c7a8d;
    font-size: 0.7rem;
}

.chat-preview-message.user {
    text-align: right;
}

.chat-preview-message.user div {
    background: linear-gradient(135deg, #e63946 0%, #c0303c 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 12px 12px 4px 12px;
    display: inline-block;
    max-width: 80%;
    box-shadow: 0 2px 4px rgba(230,57,70,0.2);
}

/* Chat Input Footer */
.chat-preview-footer {
    padding: 16px;
    border-top: 1px solid #e4e8ef;
    background: #ffffff;
    display: none; /* Hidden by default */
}

.chat-preview-footer.active {
    display: block;
}

.chat-preview-footer input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e4e8ef;
    border-radius: 99px;
    font-size: 0.9rem;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    background: #ffffff;
    color: #0d2340;
}

.chat-preview-footer input:focus {
    outline: none;
    border-color: #e63946;
    box-shadow: 0 0 0 3px rgba(230,57,70,0.1);
}

.chat-preview-footer input::placeholder {
    color: #6c7a8d;
}

.chat-preview-footer button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #e63946 0%, #c0303c 100%);
    color: white;
    border: none;
    border-radius: 99px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-preview-footer button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(230,57,70,0.3);
}

.chat-preview-footer button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chat-preview-footer small {
    display: block;
    text-align: center;
    margin-top: 8px;
    color: #6c7a8d;
    font-size: 0.7rem;
}

.chat-preview-footer small i {
    color: #2ecc71;
}

/* Visitor Info Form */
.visitor-info-form {
    padding: 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e4e8ef;
    display: none; /* Hidden by default */
}

.visitor-info-form.active {
    display: block;
}

.visitor-info-form h5 {
    margin-bottom: 15px;
    color: #0d2340;
    font-size: 1rem;
    font-weight: 600;
}

.visitor-info-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e4e8ef;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 12px;
    transition: all 0.3s ease;
    background: #ffffff;
    color: #0d2340;
}

.visitor-info-form input:focus {
    outline: none;
    border-color: #e63946;
    box-shadow: 0 0 0 3px rgba(230,57,70,0.1);
}

.visitor-info-form input::placeholder {
    color: #6c7a8d;
}

.visitor-info-form .btn-submit {
    background: linear-gradient(135deg, #0d2340 0%, #1e3c72 100%);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    width: 100%;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.visitor-info-form .btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13,35,64,0.3);
}

.visitor-info-form .btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.visitor-info-form .skip-link {
    text-align: center;
    margin-top: 8px;
}

.visitor-info-form .skip-link a {
    color: #6c7a8d;
    font-size: 0.8rem;
    text-decoration: none;
    transition: color 0.3s ease;
    cursor: pointer;
}

.visitor-info-form .skip-link a:hover {
    color: #e63946;
    text-decoration: underline;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: #f0f2f5;
    border-radius: 20px;
    width: fit-content;
    margin-bottom: 8px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #6c7a8d;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Message Animations */
@keyframes fadeInMessage {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% { 
        transform: scale(1); 
        box-shadow: 0 4px 20px rgba(230,57,70,0.4);
    }
    50% { 
        transform: scale(1.05); 
        box-shadow: 0 8px 25px rgba(230,57,70,0.5);
    }
    100% { 
        transform: scale(1); 
        box-shadow: 0 4px 20px rgba(230,57,70,0.4);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar Styling */
.chat-preview-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-preview-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chat-preview-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.chat-preview-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Loading State */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.chat-loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #e63946;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error State */
.chat-error {
    background: rgba(230,57,70,0.1);
    color: #e63946;
    padding: 12px;
    border-radius: 8px;
    margin: 10px;
    text-align: center;
    font-size: 0.9rem;
    border: 1px solid rgba(230,57,70,0.2);
}

.chat-error i {
    margin-right: 8px;
}

/* Success State */
.chat-success {
    background: rgba(46,204,113,0.1);
    color: #27ae60;
    padding: 12px;
    border-radius: 8px;
    margin: 10px;
    text-align: center;
    font-size: 0.9rem;
    border: 1px solid rgba(46,204,113,0.2);
}

.chat-success i {
    margin-right: 8px;
}

/* Agent Status Indicator */
.agent-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 0.8rem;
    color: #6c7a8d;
}

.agent-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    animation: pulse 2s infinite;
}

.agent-status-dot.away {
    background: #f4a435;
    animation: none;
}

.agent-status-dot.offline {
    background: #95a5a6;
    animation: none;
}

/* Quick Reply Buttons */
.quick-replies {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-top: 1px solid #e4e8ef;
    background: #ffffff;
}

.quick-reply-btn {
    background: #f4f6f9;
    border: 1px solid #e4e8ef;
    padding: 6px 12px;
    border-radius: 99px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #0d2340;
}

.quick-reply-btn:hover {
    background: #e63946;
    color: white;
    border-color: #e63946;
    transform: translateY(-2px);
}

.quick-reply-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* File Attachment */
.chat-attachment {
    padding: 8px 16px;
    border-top: 1px solid #e4e8ef;
    background: #ffffff;
}

.chat-attachment-btn {
    background: transparent;
    border: 1px dashed #e4e8ef;
    padding: 8px;
    border-radius: 8px;
    width: 100%;
    color: #6c7a8d;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.8rem;
}

.chat-attachment-btn:hover {
    border-color: #e63946;
    color: #e63946;
    background: rgba(230,57,70,0.05);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-widget-container {
        bottom: 70px;
        right: 15px;
    }
    
    .chat-widget-button {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .chat-widget-preview {
        width: 280px;
        right: 0;
        bottom: 70px;
    }
    
    .chat-preview-messages {
        height: 220px;
    }
    
    .visitor-info-form input {
        padding: 10px 14px;
    }
    
    .visitor-info-form .btn-submit {
        padding: 10px;
    }
    
    .quick-reply-btn {
        padding: 4px 10px;
        font-size: 0.75rem;
    }
}

/* Tablet Responsive */
@media (min-width: 769px) and (max-width: 1024px) {
    .chat-widget-preview {
        width: 300px;
    }
}

/* Ensure white background everywhere */
.chat-widget-preview,
.chat-preview-messages,
.chat-preview-footer,
.visitor-info-form,
.quick-replies,
.chat-attachment {
    background: #ffffff;
}

.visitor-info-form {
    background: #f8f9fa; /* Slightly off-white for contrast */
}

/* Additional fixes for message display */
.chat-preview-messages {
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    background: #ffffff;
    padding: 16px;
}

.chat-preview-messages .chat-preview-message {
    margin-bottom: 12px;
    clear: both;
}

.chat-preview-message.agent {
    text-align: left;
}

.chat-preview-message.agent div {
    background: #f0f2f5;
    padding: 8px 12px;
    border-radius: 12px 12px 12px 4px;
    display: inline-block;
    max-width: 80%;
    color: #0d2340;
    position: relative;
}

.chat-preview-message.user {
    text-align: right;
}

.chat-preview-message.user div {
    background: linear-gradient(135deg, #e63946 0%, #c0303c 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 12px 12px 4px 12px;
    display: inline-block;
    max-width: 80%;
}