/* AI Chat Widget Styles - Loaded from Vercel */
#ai-chat-widget-container {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 999999 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Chat toggle visibility is managed by JavaScript with animations */

#ai-chat-widget {
    position: relative;
    width: 100%;
    height: 100%;
}

#chat-toggle {
    width: 50px !important;
    height: 50px !important;
    border-radius: 50% !important;

    border: none !important;
    color: white !important;
    font-size: 24px !important;
    cursor: pointer !important;
   background-color: transparent;
    transition: all 0.3s ease !important;
    display: flex; /* Removed !important to allow JavaScript control */
    align-items: center !important;
    justify-content: center !important;
    position: relative !important; /* For pending indicator positioning */
    width: 50px!important;
    height: 50px!important;
    animation: float 6s ease-in-out infinite !important;
}
#chat-toggle img{
    width: 50px!important;
    height: 50px!important;
}

#chat-toggle .close-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    color: white;
    z-index: 10;
    pointer-events: none;
}

#chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

#chat-toggle.active {
    background: transparent !important;
}

.pending-indicator {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 1.5s infinite;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.3);
}

#chat-window {
    position: absolute;
    bottom: 55px;
    right: 0;
    width: 350px;
    
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

#chat-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

.chat-header {
    /* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */

    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: rgb(46, 91, 42);
 
    gap: 10px;
}

.chat-header > div:first-child {
    flex: 1;
    min-width: 0;
}

.chat-title {
    font-weight: 600;
    font-size: 16px;    margin-bottom: 3px;
}

.status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff4757;
    margin-right: 6px;
}

.status-text {
    font-size: 12px;
    color: rgb(46, 91, 42);
    font-weight: 500;
}

.status-dot.connecting {
    background: #ffa502;
    animation: pulse 1.5s infinite;
}

.status-dot.connected {
    background: #2ed573;
}

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

#close-btn {
    background: none;
    border: none;
    color: rgb(46, 91, 42);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
    margin-left: 4px;
}

#close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#refresh-btn {
    margin-left: 6px;
    background: transparent;
    border: none;
    color: #4a4a4a;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}
#refresh-btn:hover {
    background: #e0e0e0;
}

#mute-btn {
    
    background: transparent;
    border: none;
    color: #4a4a4a;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}
#mute-btn:hover {
    background: #e0e0e0;
}


.control-btn {
    padding: 6px 10px;
    border: 1px solid rgba(46, 91, 42, 0.3);
    border-radius: 4px;
    background: white;
    color: rgb(46, 91, 42);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-weight: 500;
}

.control-btn:hover:not(:disabled) {
    background: rgba(46, 91, 42, 0.1);
    border-color: rgb(46, 91, 42);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.control-btn.primary {
    background: black
    color: white;
   
}

.control-btn.primary:hover:not(:disabled) {
   background-color: #000;
   color: white;
}

.control-btn i {
    font-size: 18px;
    vertical-align: middle;
}

#chat-messages {
    height: 340px;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
}

.message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-items: flex-end;
}

.message.assistant {
    align-items: flex-start;
}

.message.system {
    align-items: center;
}

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

.message.user .message-bubble {
     background: #EEF4E7;
    color: #666;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #eee;
    border-bottom-left-radius: 4px;
}

.message.system .message-bubble {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    font-size: 12px;
    text-align: center;
    max-width: 90%;
}

.message-time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    padding: 0 14px;
}

.chat-input {
    padding: 15px;
    border-top: 1px solid #eee;
    background: white;
}

.input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    min-height: 36px;
    max-height: 80px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 18px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
}

#message-input:focus {
    border-color: #000;
}

#send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #999;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

#send-btn:hover:not(:disabled) {
    background: #000;
}

#send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Scrollbar styling */
#chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

#chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive design */
@media (max-width: 400px) {
    #chat-window {
        width: calc(100vw - 40px);
        right: 20px;
        left: 20px;
    }
}

.redesigned-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px 8px 18px;
   
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    gap: 0;
    min-height: 56px;
}
.header-left-ai-chat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    gap: 2px;
}
.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    gap: 10px;
}
.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
    margin-left: 10px;
}

.chat-toggle-img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0 auto;
  
   
}
.mute-toggle-img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}
.chat-toggle-fa {
    font-size: 20px;
    color: #333;
    display: block;
    margin: 0 auto;
    transition: color 0.2s;
}
#chat-toggle.active .chat-toggle-fa {
    color: #b23b3b;
}
.header-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
    width: 100%;
}
.header-title {
    font-size: 16px;
    font-weight: 600;
    color: #222;
    letter-spacing: 0.01em;
    margin-bottom: 0;
    white-space: nowrap;
}
.status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
    white-space: nowrap;
}
.chat-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

@keyframes float {
    0% {
        box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.0);
        transform: translatey(0px);
    }
    50% {
        box-shadow: 0 25px 15px 0px rgba(0, 0, 0, 0.2);
        transform: translatey(-20px);
    }
    100% {
        box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.0);
        transform: translatey(0px);
    }
}