/* Live Chat Widget Styles - Modern Edition */
.live-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Chat Button - Enhanced */
.chat-button {
    width: 51px;
    height: 51px;
    background: linear-gradient(135deg, #0a1628 0%, #0d2044 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    color: white;
    font-size: 28px;
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.chat-button:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.6);
}

.chat-button:active {
    transform: scale(0.95);
}

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #ff8c00 0%, #e06000 100%);
    color: white;
    border-radius: 16px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 700;
    min-width: 22px;
    text-align: center;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(245, 87, 108, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Chat Window - Modern Design (responsive across screens) */
.chat-window {
    position: absolute;
    bottom: 84px;
    right: 0;
    /* Comfortable default that never exceeds the viewport */
    width: 420px;
    max-width: calc(100vw - 32px);
    height: 640px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

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

/* Large desktops: allow a slightly roomier panel */
@media (min-width: 1400px) and (min-height: 900px) {
    .chat-window {
        width: 460px;
        height: 720px;
    }
}

/* Tablets & small laptops */
@media (max-width: 768px) {
    .chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 130px);
        bottom: 84px;
        right: 16px;
    }
}

/* Phones — full-height sheet anchored to the corner */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100dvh - 100px);
        bottom: 78px;
        right: 10px;
    }

    .live-chat-widget {
        right: 16px;
        bottom: 61px;
    }
}

/* Chat Header - Modernized */
.chat-header {
    background: linear-gradient(135deg, #0a1628 0%, #0d2044 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.chat-header-info h6 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.chat-status {
    font-size: 13px;
    opacity: 0.95;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

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

.chat-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.chat-header-btn:active {
    transform: scale(0.95);
}

/* Chat Messages - Enhanced */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(to bottom, #f8fafc 0%, #f1f5f9 100%);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

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

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

.welcome-icon {
    font-size: 56px;
    color: #ff8c00;
    margin-bottom: 16px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.welcome-message h6 {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}

.welcome-message p {
    font-size: 14px;
    margin: 0;
    color: #64748b;
}

/* Message Bubbles - Modern Style */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: messageSlide 0.3s ease;
}

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

.message.customer {
    align-self: flex-end;
    align-items: flex-end;
}

.message.agent,
.message.ai {
    align-self: flex-start;
    align-items: flex-start;
}

.message-bubble {
    padding: 14px 18px;
    border-radius: 20px;
    word-wrap: break-word;
    line-height: 1.6;
    max-width: 100%;
    white-space: pre-wrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
}

.message.customer .message-bubble {
    background: linear-gradient(135deg, #0a1628 0%, #0d2044 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.agent .message-bubble {
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 6px;
}

.message.ai .message-bubble {
    background: linear-gradient(135deg, #ffffff 0%, #f6f8fb 100%);
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-bubble .message-text {
    margin-bottom: 8px;
    line-height: 1.6;
}

.message-bubble .customer-details {
    background: rgba(255, 255, 255, 0.6);
    padding: 14px;
    border-radius: 12px;
    margin: 10px 0;
    font-size: 14px;
    backdrop-filter: blur(10px);
}

.message-bubble .customer-details-line {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
    line-height: 1.8;
}

.message-bubble .customer-details-icon {
    font-size: 18px;
    min-width: 24px;
}

.message-bubble p {
    margin: 0.3em 0;
    line-height: 1.6;
}

.message-bubble .chat-section-heading {
    display: block;
    font-weight: 700;
    margin: 0.6em 0 0.3em 0;
    font-size: 1.05em;
}

.message-bubble .chat-message-list {
    margin: 0.3em 0;
    padding-left: 1.4em;
    list-style-type: disc;
}

.message-bubble .chat-message-list li {
    margin: 0.2em 0;
    line-height: 1.6;
}

/* Product Card Styles - Enhanced */
.chat-product-card {
    margin-top: 14px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.chat-product-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
    border-color: #ff8c00;
}

.product-card-link {
    display: flex;
    text-decoration: none;
    color: inherit;
    gap: 14px;
    padding: 14px;
}

.product-card-image {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.chat-product-card:hover .product-card-image img {
    transform: scale(1.1);
}

.product-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

.product-card-name {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 6px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card-price {
    font-size: 18px;
    font-weight: 800;
    background: linear-gradient(135deg, #0a1628 0%, #0d2044 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-top: auto;
}

.product-card-desc {
    font-size: 12px;
    color: #64748b;
    margin: 4px 0 0 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.message-sender {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 6px;
    font-weight: 500;
}

/* Typing Indicator - Enhanced */
.typing-indicator {
    padding: 12px 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, 0.5);
}

.typing-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #0a1628 0%, #0d2044 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
}

.typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
    background: white;
    padding: 10px 14px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #ff8c00;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-12px);
        opacity: 1;
    }
}

/* Chat Input - Modern Design */
.chat-input-area {
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 16px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 10px;
}

.chat-input {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 16px;
    font-size: 14px;
    resize: none;
    max-height: 120px;
    font-family: inherit;
    line-height: 1.5;
    transition: all 0.2s;
    background: #f8fafc;
}

.chat-input:focus {
    outline: none;
    border-color: #ff8c00;
    background: white;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.chat-send-btn {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #0a1628 0%, #0d2044 100%);
    color: white;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
    cursor: not-allowed;
    box-shadow: none;
}

.chat-attach-btn {
    width: 48px;
    height: 48px;
    background: #f1f5f9;
    color: #64748b;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-attach-btn:hover {
    background: white;
    color: #ff8c00;
    border-color: #ff8c00;
    transform: scale(1.05);
}

.chat-attach-btn:active {
    transform: scale(0.95);
}

.file-preview-container {
    padding: 12px;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    margin-bottom: 12px;
}

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.file-preview-item:last-child {
    margin-bottom: 0;
}

.file-preview-icon {
    font-size: 28px;
    color: #ff8c00;
}

.file-preview-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid #e2e8f0;
}

.file-preview-info {
    flex: 1;
    min-width: 0;
}

.file-preview-name {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.file-preview-size {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

.file-preview-remove {
    background: #fee2e2;
    color: #dc2626;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

.file-preview-remove:hover {
    background: #fecaca;
    transform: scale(1.1);
}

.message-attachment {
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.message-attachment-image {
    max-width: 200px;
    border-radius: 12px;
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

.chat-action-btn {
    padding: 10px 16px;
    background: #f1f5f9;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #475569;
    transition: all 0.2s;
}

.chat-action-btn:hover {
    background: white;
    border-color: #ff8c00;
    color: #ff8c00;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.chat-action-btn:active {
    transform: translateY(0);
}

.chat-action-btn i {
    font-size: 16px;
}

/* Loading State */
.chat-loading {
    text-align: center;
    padding: 24px;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
}

/* Guest Form Styles - Enhanced */
.guest-form-container {
    padding: 20px;
    background: white;
    border-radius: 16px;
    margin: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.guest-form-message {
    margin-bottom: 18px;
    color: #475569;
    font-size: 14px;
    font-weight: 500;
}

.guest-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group label i {
    font-size: 16px;
    color: #ff8c00;
}

.form-group input {
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    background: #f8fafc;
}

.form-group input:focus {
    outline: none;
    border-color: #ff8c00;
    background: white;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.guest-form-submit {
    padding: 14px 20px;
    background: linear-gradient(135deg, #0a1628 0%, #0d2044 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.guest-form-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.guest-form-submit:active {
    transform: translateY(0);
}

.guest-form-submit i {
    font-size: 18px;
}
