/* Universal Box Sizing for consistent layout */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Core Chatbot Container */
#aiginno-chatbot-container {
    font-family: sans-serif;
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 50;
}

.aiginno-chatbot-send-button:focus {
    outline: none !important;
}

/* Footer */
.aiginno-chatbot-footer a {
    color: inherit; /* Inherits the text color from the footer element */
    text-decoration: none; /* Removes the default underline from the link */
}

/* Adds an underline when the user hovers over the link */
.aiginno-chatbot-footer a:hover {
    text-decoration: underline;
}

/* Chatbot Icon */
.aiginno-chatbot-icon {
    position: fixed;
    bottom: 1rem; /* bottom-4 */
    right: 1rem; /* right-4 */
    background-color: #2563eb; /* bg-blue-600 */
    color: white; /* text-white - this color will be inherited by SVG's stroke="currentColor" */
    padding: 1rem; /* p-4 */
    border-radius: 9999px; /* rounded-full */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* shadow-lg */
    cursor: pointer;
    transition: all 0.3s ease-in-out; /* transition-all duration-300 ease-in-out */
    border: 4px solid white; /* border-4 border-white */
    z-index: 100000; /* z-index: 100 */
    outline: none; /* focus:outline-none */
}

.aiginno-chatbot-icon:hover {
    background-color: #1d4ed8; /* hover:bg-blue-700 */
}

/* Added focus state for the ring effect */
.aiginno-chatbot-icon:focus {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75), 0 0 0 4px #3b82f6; /* Simulates focus:ring-2 focus:ring-blue-500 focus:ring-opacity-75 */
}

/* SVG icon sizing within the toggle button - NEW */
.aiginno-chatbot-icon svg {
    height: 1.5rem; /* h-6 (24px) */
    width: 1.5rem;  /* w-6 (24px) */
}

.aiginno-chatbot-input-field:focus,
.aiginno-chatbot-send-button:focus {
    outline: none !important;
    box-shadow: none !important;
    /* border-color: inherit !important; */
    text-decoration: none !important;
}

/* Chatbot Footer */
.aiginno-chatbot-footer {
    text-align: center;
    font-size: 0.75rem;
    color: #9ca3af;
    padding: 0.5rem;
}


/* Chatbot Window */
.aiginno-chatbot-window {
    position: fixed;
    bottom: 6rem; /* bottom-24 */
    right: 1rem; /* right-4 */
    width: 20rem; /* w-80 */
    max-width: 24rem; /* md:w-96 */
    background-color: white;
    border-radius: 0.5rem; /* rounded-lg */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); /* shadow-xl */
    display: flex;
    flex-direction: column;
    /* max-height: calc(90vh - 140px); */
    height: 32rem;
    overflow: hidden;
    z-index: 9999999999999999999999999999999999999; /* Ensures the chatbot is on top of other elements */
}

@media (min-width: 768px) {
    .aiginno-chatbot-window {
        width: 24rem; /* md:w-96 */
    }
}

/* Header */
.aiginno-chatbot-header {
    padding: 1rem;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
    background-color: #2563eb; /* bg-blue-600 */
    color: white;
    font-size: 1.125rem; /* text-lg */
    font-weight: 600; /* font-semibold */
}


.aiginno-chatbot-header h3 {
    color: white !important;
}

/* Content area */
.aiginno-chatbot-content {
    display: flex;
    flex-grow: 1;
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
    gap: 1rem; /* space-y-4 */
}

/* Form Styling */
.aiginno-chatbot-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* space-y-3 */
}

.aiginno-chatbot-form label {
    font-size: 0.875rem; /* text-sm */
    font-weight: 500; /* font-medium */
    color: #4b5563; /* text-gray-700 */
    margin-bottom: 0.25rem;
}

.aiginno-chatbot-form input {
    width: 100%;
    padding: 0.5rem;
    border-radius: 0.375rem; /* rounded-md */
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); /* shadow-sm */
    border: 1px solid #d1d5db; /* border-gray-300 */
}

.aiginno-chatbot-form input:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6; /* focus:ring-blue-500 focus:border-blue-500 */
}

.aiginno-chatbot-form-button {
    width: 100%;
    padding: 0.5rem 1rem;
    background-color: #2563eb; /* bg-blue-600 */
    color: white;
    border-radius: 0.375rem; /* rounded-md */
    cursor: pointer;
    transition: background-color 0.2s;
    border: none;
}

.aiginno-chatbot-form-button:hover {
    background-color: #1d4ed8; /* hover:bg-blue-700 */
}

.aiginno-chatbot-form-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.aiginno-chatbot-form-error {
    color: #ef4444; /* text-red-500 */
    font-size: 0.875rem; /* text-sm */
}

/* Chat Messages Area */
.aiginno-chatbot-messages {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem; /* space-y-4 */
    background-color: #f3f4f6; /* A light background for the chat area */
}

/* Individual message styling */
.aiginno-chat-message-user {
    display: flex;
    justify-content: flex-end;
}

.aiginno-chat-message-bot {
    display: flex;
    justify-content: flex-start;
    align-items: flex-end;
}

.aiginno-chat-bubble {
    padding: 0.75rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    max-width: 75%;
    word-wrap: break-word;
}

.aiginno-chat-bubble-user {
    background-color: #3b82f6; /* bg-blue-500 */
    color: white;
    border-bottom-right-radius: 0;
}

.aiginno-chat-bubble-bot {
    background-color: #e5e7eb; /* bg-gray-200 */
    color: black;
    border-bottom-left-radius: 0;
    margin-left: 0.5rem; /* ml-2 */
}

/* Bot avatar */
.aiginno-bot-avatar {
    width: 1.5rem; /* w-6 */
    height: 1.5rem; /* h-6 */
    min-width: 1.5rem; /* For flex-shrink-0 */
    border-radius: 9999px;
    background-color: #3b82f6; /* bg-blue-500 */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid #60a5fa;
}

.aiginno-bot-avatar svg {
    width: 1rem;
    height: 1rem;
    color: white;
}

/* Markdown styling within bot message */
.aiginno-chat-bubble-bot a {
    color: #2563eb;
    text-decoration: underline;
}
.aiginno-chat-bubble-bot p { margin: 0; }
.aiginno-chat-bubble-bot ul, .aiginno-chat-bubble-bot ol { margin: 0; padding-left: 1.5rem; }
.aiginno-chat-bubble-bot li { margin-bottom: 0.25rem; }
.aiginno-chat-bubble-bot h1, .aiginno-chat-bubble-bot h2, .aiginno-chat-bubble-bot h3 { margin-top: 0; margin-bottom: 0.5rem; }

/* Input area */
.aiginno-chatbot-input-area {
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: flex-start; /* Ensures vertical centering of items */
    background-color: white;
    gap: 0.5rem; /* Provides space between the input and the button */
    padding-bottom: 0rem; /* Ensures padding at the bottom */
}

.aiginno-chatbot-input-field {
    flex-grow: 1; /* Allows the input to take up available space */
    height: 2.5rem;
    border-radius: 0.375rem;
    border: 1px solid #d1d5db;
    padding: 0 0.75rem;
    color: black;
    vertical-align: middle; /* Explicitly align to the middle */
}

.aiginno-chatbot-input-field:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

.aiginno-chatbot-send-button {
    height: 2.5rem; /* Explicitly set height to match input */
    width: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    background-color: #2563eb;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
    border: none;
    flex-shrink: 0; /* Prevents button from shrinking */
    vertical-align: middle; /* Explicitly align to the middle */
}

.aiginno-chatbot-send-button:hover {
    background-color: #1d4ed8;
}

.aiginno-chatbot-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading/typing indicator */
.aiginno-chatbot-loading {
    display: flex;
    justify-content: flex-start;
}

.aiginno-chatbot-loading-bubble {
    background-color: #e5e7eb;
    color: #4b5563;
    padding: 0.75rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    border-bottom-left-radius: 0;
    margin-left: 0.5rem;
}

.aiginno-chatbot-loading-bubble span {
    animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}


/* Error message styling */
.aiginno-chat-error-message {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #FEE2E2;
    border: 1px solid #F87171;
    color: #DC2626;
    padding: 12px;
    margin: 8px;
    border-radius: 6px;
    font-weight: 500;
}

.aiginno-chat-error-message svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}