/* Cortex by HPCR Chat Widget Styles */

/* Chat Icon */
#cortex-chat-icon {
    position: fixed;
    bottom: 25px;
    right: 25px;
    /* Adjusted dimensions - tweak these to your image's best look */
    width: 150px; 
    height: 50px;  
    
    /* background-image is set by PHP inline style now */
    background-size: contain; /* Ensures the whole image fits within the new dimensions */
    background-repeat: no-repeat;
    background-position: center center; /* Explicitly center horizontally and vertically */
    background-color: #fff;
    border-radius: 12px; 
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); 
    cursor: pointer;
    z-index: 9998;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    border: 1px solid #E2E8F0; /* Optional border */
}

#cortex-chat-icon:hover {
    transform: scale(1.05); 
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

/* Main Chat Widget Container */
#cortex-chat-widget {
    position: fixed;
    bottom: 90px; /* Adjusted to be above the potentially taller icon */
    right: 25px;
    width: 360px; 
    max-width: calc(100vw - 40px);
    height: 500px; 
    max-height: calc(100vh - 110px); /* Adjusted */
    background: #fff;
    border: 1px solid #E2E8F0; 
    border-radius: 20px; 
    box-shadow: 0 5px 20px rgba(0,0,0,0.1); 
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden; 
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

/* Chat Header */
#cortex-chat-header {
    background-color: #4b81c2; 
    color: white;
    padding: 12px 15px;
    font-size: 1.1em;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #E2E8F0;
}

#cortex-close-chat {
    font-size: 1.6em;
    font-weight: bold;
    color: white;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}
#cortex-close-chat:hover {
    opacity: 0.8;
}

/* Messages Area */
#cortex-chat-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cortex-chat-message {
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 80%;
    line-height: 1.5;
    word-wrap: break-word;
}

.cortex-chat-message.cortex-user {
    background-color: #4b81c2; 
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 3px; 
}

.cortex-chat-message.cortex-bot {
    background-color: #F0F4F8; 
    color: #2D3748; 
    align-self: flex-start;
    border-bottom-left-radius: 3px; 
}
.cortex-chat-message.cortex-bot strong { 
    color: #EC5654; 
}

.cortex-chat-message.cortex-error {
    background-color: #f8d7da; 
    color: #721c24; 
    align-self: flex-start;
}

.cortex-typing-indicator {
    font-style: italic;
    color: #666;
    font-size: 0.9em;
    align-self: flex-start;
    padding: 5px 0;
}

/* Input Area */
#cortex-chat-input-area {
    padding: 10px 15px;
    border-top: 1px solid #E2E8F0; 
    background-color: #f8f9fa; 
}

#cortex-user-input {
    width: calc(100% - 22px); 
    padding: 10px;
    border: 1px solid #CBD5E0; 
    border-radius: 8px; 
    resize: none;
    font-size: 1em;
    line-height: 1.4;
    box-sizing: border-box;
    margin-bottom: 8px;
    min-height: 40px; 
}

#cortex-chat-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#cortex-send-message,
#cortex-submit-callback {
    padding: 8px 15px; 
    background-color: #4b81c2; 
    color: white;
    border: none;
    border-radius: 5px; 
    cursor: pointer;
    font-size: 0.95em; 
    transition: background-color 0.2s ease-in-out; 
}
#cortex-send-message:hover,
#cortex-submit-callback:hover {
    background-color: #3a66a0; 
}
#cortex-send-message:disabled,
#cortex-submit-callback:disabled {
    background-color: #a0aec0;
    cursor: not-allowed;
}

/* Callback Option */
#cortex-callback-option {
    margin-top: 8px;
    font-size: 0.9em;
    display: flex;
    align-items: center;
}
#cortex-callback-option label {
    color: #4A5568; 
    margin-left: 5px;
    cursor: pointer;
}
#cortex-callback-option input[type="checkbox"] {
    margin-right: 5px;
    vertical-align: middle;
    cursor: pointer;
}

/* Callback Form */
#cortex-callback-form {
    margin-bottom: 10px;
}
#cortex-callback-form input[type="text"],
#cortex-callback-form input[type="tel"] {
    display: block;
    width: calc(100% - 22px); 
    padding: 8px 10px; 
    margin-bottom: 8px;
    border: 1px solid #CBD5E0; 
    border-radius: 5px; 
    box-sizing: border-box;
}
#cortex-callback-form-status {
    font-size: 0.85em;
    margin-top: 5px;
}
.cortex-callback-success {
    color: #155724; 
}
.cortex-callback-error {
    color: #721c24; 
}

/* Utility class for hiding */
.cortex-hidden {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    #cortex-chat-widget {
			width: 80%);
/*	width: calc(100% - 40px);
    right: 10px;
    bottom: 80px;  */
        height: calc(100% - 100px); 
        max-height: 60%;
    }

    #cortex-chat-icon { /* Ensure icon adapts too */
        bottom: 20px;
        right: 20px;
        width: 120px; /* Example smaller width for mobile */
        height: 50px; /* (120px / 3) */
    }
     #cortex-chat-controls {
        flex-direction: column;
        align-items: stretch;
     }
     #cortex-send-message {
         width: 100%;
         margin-bottom: 8px;
     }
     #cortex-callback-option {
         justify-content: center;
     }
}