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

.chat-widget-button {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
}

.chat-widget-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.chat-widget-button i {
    font-size: 20px;
}

.chat-widget-container {
    display: flex;
    flex-direction: column;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.chat-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    font-weight: 600;
    font-size: 16px;
}

.chat-widget-header > div {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Header actions container (close button + contact tech) */
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-contact-tech {
    background: rgba(255,255,255,0.12);
    color: white;
    border: 1px solid rgba(255,255,255,0.18);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, transform 0.12s;
}

.chat-contact-tech:hover {
    background: rgba(255,255,255,0.18);
    transform: translateY(-1px);
}

/* Make contact button more compact on small screens */
@media (max-width: 480px) {
    .chat-contact-tech {
        padding: 6px 8px;
        font-size: 12px;
    }
}

.chat-widget-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

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

.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.chat-widget-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

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

.chat-message {
    display: flex;
    margin-bottom: 8px;
}

.message-content {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

.user-message {
    justify-content: flex-end;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message {
    justify-content: flex-start;
}

.bot-message .message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
    max-width: 95%;
}

.error-message .message-content {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.error-message i {
    margin-right: 6px;
}

.product-suggestions {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.product-suggestion {
    display: flex;
    gap: 12px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.2s;
}

.product-suggestion:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.product-suggestion img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.product-name {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-price {
    font-size: 14px;
    color: #dc3545;
    font-weight: 700;
}

.view-product {
    display: inline-block;
    font-size: 12px;
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    margin-top: 2px;
}

.view-product:hover {
    text-decoration: underline;
}

.chat-widget-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.chat-widget-input input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-widget-input input:focus {
    border-color: #667eea;
}

.chat-widget-input input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.chat-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

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

.chat-send-btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

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

.chat-connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    font-size: 12px;
    color: #666;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffc107;
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    background: #28a745;
    animation: none;
}

.status-indicator.disconnected {
    background: #dc3545;
    animation: none;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .chat-widget-container {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        max-height: 600px;
    }
    
    .chat-widget {
        bottom: 10px;
        right: 10px;
    }
}

/* System messages (advisor join/leave, notices) */
.chat-message.bot-message.system .message-content {
    background: #f1f7ff; /* subtle blue */
    color: #0b3d91; /* darker blue for emphasis */
    border: 1px dashed rgba(11,61,145,0.12);
    font-style: italic;
    text-align: left;
    max-width: 95%;
}

/* Reduce spacing for system messages and make them less prominent than normal bot replies */
.chat-message.bot-message.system {
    margin-bottom: 6px;
}

/* Make the contact button show clear leave state when admin joined */
.chat-contact-tech.btn-danger {
    background: #dc3545 !important;
    color: #fff !important;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: none;
}

.chat-contact-tech.btn-danger:hover {
    filter: brightness(0.95);
    transform: none;
}

/* Slight visual hint when assigned: add small dot next to button */
.chat-contact-tech.btn-danger::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    margin-left: 8px;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.08);
}
