/* Chat Widget Styles - Lightweight & Minimal */
            .chat-widget {
                position: fixed;
                bottom: 20px;
                right: 20px;
                z-index: 9999;
                font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            }
            
            /* Hide floating button on mobile - use bottom nav instead */
            @media (max-width: 640px) {
                .chat-toggle-btn {
                    display: none !important;
                }
                
                /* Ensure popup is still visible on mobile even when button is hidden */
                .chat-widget {
                    display: block !important;
                }
                
                .chat-popup {
                    display: none; /* Hidden by default, shown via JS */
                }
                
                .chat-popup[style*="display: block"],
                .chat-popup[style*="display:block"] {
                    display: block !important;
                }
            }
            
            .chat-toggle-btn {
                width: 60px;
                height: 60px;
                border-radius: 50%;
                background: linear-gradient(135deg, #F28C1A 0%, #D97809 100%);
                border: none;
                color: white;
                cursor: pointer;
                box-shadow: 0 4px 12px rgba(242, 140, 26, 0.3);
                position: relative;
                transition: transform 0.2s, box-shadow 0.2s;
            }
            
            .chat-toggle-btn:hover {
                transform: scale(1.05);
                box-shadow: 0 6px 20px rgba(242, 140, 26, 0.4);
            }
            
            #chat-toggle-btn .chat-icon {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                width: 28px !important;
                height: 28px !important;
            }
            
            .chat-unread-badge {
                position: absolute;
                top: -5px;
                right: -5px;
                background: #ef4444;
                color: white;
                border-radius: 12px;
                padding: 2px 6px;
                font-size: 11px;
                font-weight: 600;
                min-width: 20px;
                text-align: center;
            }
            
            .chat-popup {
                position: absolute;
                bottom: 80px;
                right: 0;
                width: 380px;
                max-width: calc(100vw - 40px);
                height: 500px;
                max-height: calc(100vh - 120px);
                background: white;
                border-radius: 12px;
                box-shadow: 0 10px 40px rgba(0,0,0,0.2);
                display: flex;
                flex-direction: column;
                overflow: hidden;
            }
            
            .chat-popup-header {
                background: linear-gradient(135deg, #F28C1A 0%, #D97809 100%);
                color: white;
                padding: 16px 20px;
                display: flex;
                justify-content: space-between;
                align-items: center;
                flex-shrink: 0;
            }
            
            .chat-header-title {
                display: flex;
                flex-direction: column;
                gap: 2px;
                min-height: 0;
            }
            
            .chat-popup-header h3 {
                margin: 0;
                font-size: 18px;
                font-weight: 600;
                line-height: 1.2;
            }
            
            .chat-operating-hours {
                font-size: 11px;
                opacity: 0.9;
                font-weight: 400;
                display: flex;
                align-items: center;
                gap: 4px;
                line-height: 1.2;
            }
            
            .chat-operating-hours svg {
                width: 12px;
                height: 12px;
                opacity: 0.8;
                flex-shrink: 0;
            }
            
            .chat-header-actions {
                display: flex;
                align-items: center;
                gap: 8px;
            }
            
            /* Notification Toggle Button */
            .btn-notif-toggle {
                background: none;
                border: none;
                color: white;
                font-size: 18px;
                cursor: pointer;
                padding: 4px 8px;
                transition: all 0.2s;
                opacity: 0.8;
            }
            
            .btn-notif-toggle:hover {
                opacity: 1;
                transform: scale(1.1);
            }
            
            /* Icon states */
            .btn-notif-toggle[data-status="not-subscribed"] svg {
                opacity: 0.7;
            }
            
            .btn-notif-toggle[data-status="not-subscribed"]:hover svg {
                opacity: 1;
            }
            
            .btn-notif-toggle[data-status="subscribed"] svg {
                opacity: 1;
                animation: bellRing 2s ease-in-out;
            }
            
            .btn-notif-toggle[data-status="blocked"] svg {
                color: #ff6b6b;
            }
            
            .btn-notif-toggle[data-status="not-supported"] {
                display: none !important;
            }
            
            @keyframes bellRing {
                0%, 100% { transform: rotate(0deg); }
                10%, 30% { transform: rotate(-10deg); }
                20%, 40% { transform: rotate(10deg); }
            }
            
            /* Notification Info Bar */
            .chat-notif-info-bar {
                position: absolute;
                top: 64px;
                left: 0;
                right: 0;
                background: linear-gradient(to right, #e3f2fd, #f5f5f5);
                border-bottom: 1px solid #bbdefb;
                padding: 8px 12px;
                display: flex;
                align-items: center;
                gap: 8px;
                font-size: 12px;
                color: #616161;
                z-index: 10;
                animation: slideDown 0.3s ease;
            }
            
            .chat-notif-info-bar svg {
                flex-shrink: 0;
            }
            
            .chat-notif-info-bar .small {
                flex: 1;
                line-height: 1.4;
            }
            
            .chat-notif-info-bar .btn-dismiss {
                background: none;
                border: none;
                color: #9e9e9e;
                cursor: pointer;
                padding: 0 4px;
                font-size: 16px;
                transition: color 0.2s;
            }
            
            .chat-notif-info-bar .btn-dismiss:hover {
                color: #616161;
            }
            
            @keyframes slideDown {
                from {
                    max-height: 0;
                    opacity: 0;
                }
                to {
                    max-height: 50px;
                    opacity: 1;
                }
            }
            
            .chat-close-btn {
                background: none;
                border: none;
                color: white;
                font-size: 28px;
                line-height: 1;
                cursor: pointer;
                padding: 0;
                width: 30px;
                height: 30px;
            }
            
            .chat-popup-body {
                flex: 1 1 auto;
                display: flex;
                flex-direction: column;
                min-height: 0;
                overflow: hidden;
                height: calc(100% - 64px);
                position: relative;
                transition: padding-top 0.3s ease;
            }
            
            /* Add padding when info bar is visible */
            .chat-popup-body.has-info-bar {
                padding-top: 40px;
            }
            
            .chat-view {
                flex: 1 1 auto;
                display: none;
                flex-direction: column;
                min-height: 0;
                overflow: hidden;
            }
            
            #chat-list-view {
                display: flex;
            }
            
            #chat-messages-view {
                display: none;
            }
            
            #chat-messages-view.active {
                display: flex;
                flex-direction: column;
            }
            
            #chat-new-view {
                display: none;
            }
            
            #chat-new-view.active {
                display: flex;
            }
            
            .chat-conversations-list {
                flex: 1;
                overflow-y: auto;
                padding: 0;
                background: white;
            }
            
            /* Custom Scrollbar for Conversations List */
            .chat-conversations-list::-webkit-scrollbar {
                width: 6px;
            }
            
            .chat-conversations-list::-webkit-scrollbar-track {
                background: #f1f1f1;
            }
            
            .chat-conversations-list::-webkit-scrollbar-thumb {
                background: #F28C1A;
                border-radius: 3px;
            }
            
            .chat-conversations-list::-webkit-scrollbar-thumb:hover {
                background: #D97809;
            }
            
            /* Firefox */
            .chat-conversations-list {
                scrollbar-width: thin;
                scrollbar-color: #F28C1A #f1f1f1;
            }
            
            .chat-conversation-item {
                padding: 12px 16px;
                cursor: pointer;
                display: flex;
                gap: 12px;
                align-items: flex-start;
                transition: background 0.15s ease;
                color: #33371f;
                border-bottom: 1px solid #f0f0f0;
            }
            
            .chat-conversation-item:hover {
                background: #f5f5f5;
            }
            
            .chat-conversation-item.active {
                background: #FFF5EB;
            }
            
            /* WhatsApp-like Avatar */
            .conversation-avatar {
                width: 48px;
                height: 48px;
                border-radius: 50%;
                background: linear-gradient(135deg, #F28C1A 0%, #D97809 100%);
                flex-shrink: 0;
                display: flex;
                align-items: center;
                justify-content: center;
                color: white;
                font-weight: 600;
                font-size: 18px;
            }
            
            .conversation-avatar svg {
                width: 24px;
                height: 24px;
            }
            
            /* WhatsApp-like Content */
            .conversation-content {
                flex: 1;
                min-width: 0;
                display: flex;
                flex-direction: column;
                gap: 4px;
            }
            
            .conversation-header {
                display: flex;
                justify-content: space-between;
                align-items: center;
                gap: 8px;
            }
            
            .conversation-name {
                font-weight: 600;
                font-size: 15px;
                color: #111;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }
            
            .conversation-time {
                font-size: 12px;
                color: #7d8166;
                flex-shrink: 0;
            }
            
            .conversation-preview {
                display: flex;
                justify-content: space-between;
                align-items: center;
                gap: 8px;
            }
            
            .conversation-message {
                font-size: 14px;
                color: #667781;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                margin: 0;
                flex: 1;
            }
            
            .conversation-unread {
                background: #25D366;
                color: white;
                border-radius: 12px;
                padding: 2px 8px;
                font-size: 12px;
                font-weight: 600;
                min-width: 20px;
                text-align: center;
                flex-shrink: 0;
            }
            
            /* Active item styling */
            .chat-conversation-item.active .conversation-name {
                color: #F28C1A;
            }
            
            .chat-conversation-item.active .conversation-time {
                color: #F28C1A;
            }
            
            .chat-new-btn {
                margin: 12px;
                padding: 12px;
                background: linear-gradient(135deg, #F28C1A 0%, #D97809 100%);
                color: white;
                border: none;
                border-radius: 8px;
                cursor: pointer;
                font-weight: 500;
                font-size: 14px;
                display: flex;
                align-items: center;
                justify-content: center;
                gap: 8px;
                transition: all 0.2s;
                flex-shrink: 0;
            }
            
            .chat-new-btn:hover {
                transform: translateY(-1px);
                box-shadow: 0 4px 8px rgba(242, 140, 26, 0.3);
            }
            
            .chat-conversation-title {
                flex: 1;
                font-weight: 600;
                font-size: 16px;
                color: #1f2937;
            }
            
            .chat-messages-container {
                flex: 1;
                overflow-y: auto;
                padding: 16px;
                display: flex;
                flex-direction: column;
                gap: 8px;
                min-height: 0;
                background: #E5DDD5;
            }
            
            /* Custom Scrollbar for Messages Container */
            .chat-messages-container::-webkit-scrollbar {
                width: 6px;
            }
            
            .chat-messages-container::-webkit-scrollbar-track {
                background: rgba(0, 0, 0, 0.05);
            }
            
            .chat-messages-container::-webkit-scrollbar-thumb {
                background: rgba(242, 140, 26, 0.6);
                border-radius: 3px;
            }
            
            .chat-messages-container::-webkit-scrollbar-thumb:hover {
                background: #F28C1A;
            }
            
            /* Firefox */
            .chat-messages-container {
                scrollbar-width: thin;
                scrollbar-color: rgba(242, 140, 26, 0.6) rgba(0, 0, 0, 0.05);
            }
            
            /* WhatsApp Group-like Messages */
            .chat-message {
                display: flex;
                margin-bottom: 4px;
                animation: fadeIn 0.2s ease;
            }
            
            @keyframes fadeIn {
                from { opacity: 0; transform: translateY(10px); }
                to { opacity: 1; transform: translateY(0); }
            }
            
            .chat-message.mine {
                justify-content: flex-end;
            }
            
            .chat-message-bubble {
                max-width: 80%;
                padding: 6px 8px 8px 10px;
                border-radius: 8px;
                position: relative;
                box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
            }
            
            /* Bubble from others (Admin/CS) */
            .chat-message:not(.mine) .chat-message-bubble {
                background: #FFFFFF;
                border-radius: 0 8px 8px 8px;
            }
            
            /* Bubble tail for others */
            .chat-message:not(.mine) .chat-message-bubble::before {
                content: '';
                position: absolute;
                top: 0;
                left: -8px;
                width: 0;
                height: 0;
                border-style: solid;
                border-width: 0 8px 13px 0;
                border-color: transparent #FFFFFF transparent transparent;
            }
            
            /* Bubble from user (mine) */
            .chat-message.mine .chat-message-bubble {
                background: #e4f5d0; /* Light blue for user messages */
                border-radius: 8px 0 8px 8px;
            }
            
            /* Bubble tail for mine */
            .chat-message.mine .chat-message-bubble::before {
                content: '';
                position: absolute;
                top: 0;
                right: -8px;
                width: 0;
                height: 0;
                border-style: solid;
                border-width: 0 0 13px 8px;
                border-color: transparent transparent transparent #eaf5d0;
            }
            
            .message-sender {
                font-size: 12.5px;
                font-weight: 600;
                color: #F28C1A !important;
                margin-bottom: 4px;
            }
            
            .chat-message.mine .message-sender {
                display: none;
            }
            
            /* Message text */
            .message-text {
                font-size: 14px;
                line-height: 19px;
                color: #000000 !important;
                word-wrap: break-word;
                white-space: pre-wrap;
                margin-bottom: 4px;
            }
            
            /* Message metadata (time + status) */
            .message-meta {
                display: flex;
                align-items: center;
                justify-content: flex-end;
                gap: 4px;
                margin-top: 2px;
            }
            
            .message-time {
                font-size: 11px;
                color: #728166 !important;
                line-height: 15px;
            }
            
            /* Use multiple selectors to override global styles */
            .chat-message-bubble .message-status,
            .message-meta .message-status,
            .chat-message .message-status {
                width: 16px !important;
                height: 16px !important;
                min-width: 16px !important;
                min-height: 16px !important;
                max-width: 16px !important;
                max-height: 16px !important;
                flex-shrink: 0;
                color: #728166 !important;
                fill: currentColor !important;
            }
            
            .chat-message:not(.mine) .message-status {
                display: none;
            }
            
            /* Loading dots animation */
            @keyframes loadingDots {
                0%, 20% { content: '.'; }
                40% { content: '..'; }
                60%, 100% { content: '...'; }
            }
            
            .message-status.loading::after {
                content: '...';
                animation: loadingDots 1.5s infinite;
                font-size: 16px;
                line-height: 16px;
            }
            
            .message-status.loading path {
                display: none;
            }
            
            .message-status.failed {
                color: #ef4444 !important;
                cursor: pointer;
            }
            
            .message-status.sent {
                color: #667781 !important;
            }
            
            .chat-new-form {
                flex: 1;
                overflow-y: auto;
                padding: 16px;
                display: flex;
                flex-direction: column;
            }
            
            .chat-new-form form {
                display: flex;
                flex-direction: column;
                gap: 16px;
                flex: 1;
            }
            
            .chat-new-form .form-group {
                display: flex;
                flex-direction: column;
                gap: 6px;
            }
            
            .chat-new-form label {
                font-size: 14px;
                font-weight: 500;
                color: #374151;
            }
            
            .chat-new-form .form-control {
                width: 100%;
                padding: 10px 12px;
                border: 1px solid #d1d5db;
                border-radius: 8px;
                font-size: 14px;
                font-family: inherit;
                transition: border-color 0.2s;
                box-sizing: border-box;
            }
            
            .chat-new-form .form-control:focus {
                outline: none;
                border-color: #F28C1A;
                box-shadow: 0 0 0 3px rgba(242, 140, 26, 0.1);
            }
            
            .chat-new-form textarea.form-control {
                resize: vertical;
                min-height: 100px;
            }
            
            .chat-new-form .btn {
                padding: 12px 20px;
                border: none;
                border-radius: 8px;
                font-size: 15px;
                font-weight: 500;
                cursor: pointer;
                transition: all 0.2s;
                text-align: center;
            }
            
            .chat-new-form .btn-primary {
                background: linear-gradient(135deg, #F28C1A 0%, #D97809 100%);
                color: white;
            }
            
            .chat-new-form .btn-primary:hover {
                transform: translateY(-1px);
                box-shadow: 0 4px 8px rgba(242, 140, 26, 0.3);
            }
            
            .chat-new-form .btn-primary:active {
                transform: scale(0.98);
            }
            
            .chat-new-form .btn-block {
                width: 100%;
                margin-top: auto;
            }
            
            .chat-message-form {
                padding: 12px;
                border-top: 1px solid #e5e7eb;
                display: flex;
                flex-wrap: wrap;
                gap: 8px;
                align-items: flex-end;
                flex-shrink: 0;
                background: white;
            }
            
            .chat-product-card {
                flex: 1 1 100%;
                max-width: 100%;
                display: flex;
                gap: 12px;
                padding: 12px;
                background: #f3f4f6;
                border-radius: 8px;
                margin-bottom: 4px;
                border: 1px solid #e5e7eb;
            }
            
            .chat-product-card img {
                width: 60px;
                height: 60px;
                object-fit: cover;
                border-radius: 6px;
                flex-shrink: 0;
            }
            
            .chat-product-card-content {
                flex: 1;
                min-width: 0;
            }
            
            .chat-product-card-name {
                font-weight: 500;
                font-size: 14px;
                color: #1f2937;
                margin-bottom: 4px;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }
            
            .chat-product-card-variant {
                font-size: 12px;
                color: #74806b;
                margin-bottom: 4px;
            }
            
            .chat-product-card-price {
                font-size: 13px;
                color: #8bea66;
                font-weight: 600;
            }
            
            .chat-product-card-remove {
                align-self: flex-start;
                background: none;
                border: none;
                color: #9ca3af;
                cursor: pointer;
                padding: 4px;
                font-size: 18px;
                line-height: 1;
                transition: color 0.2s;
            }
            
            .chat-product-card-remove:hover {
                color: #ef4444;
            }
            
            /* Product card in messages (read-only display) */
            .message-product-card {
                display: flex;
                gap: 10px;
                padding: 10px;
                background: rgba(255, 255, 255, 0.5);
                border-radius: 8px;
                margin-bottom: 6px;
                border: 1px solid rgba(0, 0, 0, 0.08);
                align-items: center;
            }
            
            .chat-message.mine .message-product-card {
                background: rgba(255, 255, 255, 0.7);
            }
            
            .message-product-card img {
                width: 50px;
                height: 50px;
                object-fit: cover;
                border-radius: 6px;
                flex-shrink: 0;
            }
            
            .message-product-info {
                flex: 1;
                min-width: 0;
            }
            
            .message-product-name {
                font-weight: 500;
                font-size: 13px;
                color: #33371f;
                margin-bottom: 2px;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
                line-height: 1.3;
            }
            
            .message-product-variant {
                font-size: 11px;
                color: #78806b;
                margin-bottom: 2px;
            }
            
            .message-product-price {
                font-size: 12px;
                color: #c7ea66;
                font-weight: 600;
            }
            
            .message-product-link {
                flex-shrink: 0;
                width: 32px;
                height: 32px;
                display: flex;
                align-items: center;
                justify-content: center;
                background: rgba(102, 126, 234, 0.1);
                border-radius: 6px;
                color: #c7ea66;
                text-decoration: none;
                transition: all 0.2s;
            }
            
            .message-product-link:hover {
                background: #b7ea66;
                color: white;
            }
            
            .message-product-link svg {
                width: 16px;
                height: 16px;
            }
            
            .chat-message-input {
                flex: 1;
                border: 1px solid #d1d5db;
                border-radius: 20px;
                padding: 10px 16px;
                resize: none;
                max-height: 100px;
                font-family: inherit;
                font-size: 14px;
                line-height: 1.5;
                box-sizing: border-box;
                overflow-y: hidden;
            }
            
            .chat-message-input:focus {
                outline: none;
                border-color: #F28C1A;
                box-shadow: 0 0 0 3px rgba(242, 140, 26, 0.1);
            }
            
            .chat-send-btn {
                width: 40px;
                height: 40px;
                border-radius: 50%;
                background: linear-gradient(135deg, #F28C1A 0%, #D97809 100%);
                border: none;
                color: white;
                cursor: pointer;
                flex-shrink: 0;
                display: flex;
                align-items: center;
                justify-content: center;
                transition: all 0.2s;
            }
            
            .chat-send-btn:hover {
                transform: scale(1.05);
                box-shadow: 0 2px 8px rgba(242, 140, 26, 0.3);
            }
            
            .chat-send-btn:active {
                transform: scale(0.95);
            }
            
            .chat-loading {
                text-align: center;
                padding: 20px;
                color: #6b7280;
            }
            
            /* Date Separator (WhatsApp-style) */
            .date-separator {
                display: flex;
                align-items: center;
                gap: 12px;
                margin: 24px 0 16px;
                opacity: 0;
                animation: fadeInSeparator 0.3s ease forwards;
            }

            @keyframes fadeInSeparator {
                from {
                    opacity: 0;
                    transform: translateY(-10px);
                }
                to {
                    opacity: 1;
                    transform: translateY(0);
                }
            }

            .date-separator-line {
                flex: 1;
                height: 1px;
                background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.1) 50%, transparent);
            }

            .date-separator-text {
                flex-shrink: 0;
                padding: 4px 12px;
                background: #e9ecef;
                color: #6c757d;
                font-size: 11px;
                font-weight: 600;
                text-transform: uppercase;
                letter-spacing: 0.5px;
                border-radius: 12px;
                box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
            }
            
            /* Mobile responsive */
            @media (max-width: 640px) {
                .chat-popup {
                    position: fixed !important; /* Override absolute positioning */
                    bottom: 45px !important; /* Above bottom nav */
                    right: 0 !important;
                    left: 0 !important;
                    width: 100% !important;
                    max-width: 100% !important;
                    /* Use dvh (dynamic viewport height) for browser UI awareness */
                    height: calc(100dvh - 45px) !important;
                    max-height: calc(100dvh - 45px) !important;
                    /* Fallback for browsers that don't support dvh */
                    height: calc(var(--viewport-height, 100vh) - 45px) !important;
                    max-height: calc(var(--viewport-height, 100vh) - 45px) !important;
                    border-radius: 0 !important;
                    z-index: 9999 !important;
                }
                
                .chat-popup-header {
                    border-radius: 0;
                }
                
                .chat-messages-container,
                .chat-conversations-list {
                    /* Adjust for mobile keyboard using dynamic viewport */
                    max-height: calc(100dvh - 190px);
                    /* Fallback for browsers that don't support dvh */
                    max-height: calc(var(--viewport-height, 100vh) - 190px);
                }
            }
