/* chatbot style */
#chatbot-container {
    width: 300px;
    border: 1px solid #ccc;
    padding: 10px;
    margin: 20px;
}

#chatbot-messages {
    height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 5px;
    margin-bottom: 10px;
}

#chatbot-input {
    width: 75%;
}

#chatbot-send {
    width: 20%;
}


.chat-head {
    width: 50px;
    height: 50px;
    background-image: url('/Images/JDi.jpg');
    background-size: cover;
    background-position: center;
    background-color: var(--first-color-lighter);
    border-radius: 50%;
    position: fixed;
    bottom: 20px;
    right: 20px;
    cursor: pointer;
    z-index: 900;
    /* Ensure visibility on first load */
    opacity: 1;
    visibility: visible;
}

.chat-head::after {
    content: '';
    position: absolute;
    top: -10px; /* Adjust these values to increase the hit box */
    left: -10px;
    right: -10px;
    bottom: -10px;
    z-index: 1000; /* Ensure it's below the actual chat head */
    pointer-events: auto; /* Makes this area clickable */
  }

.chat-window {
    width: 300px;
    height: 400px;
    min-width: 250px;
    min-height: 300px;
    max-height: 600px;
    max-width: none !important;
    background-color: var(--body-color);
    position: fixed;
    bottom: 80px;
    right: 20px;
    border: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    z-index: 905;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    resize: both;
    overflow: hidden; /* Hides overflow, allows resize */
}

/* Subtle resize indicator - doesn't block native functionality */
.chat-window::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, transparent 50%, var(--first-color-lighter) 50%);
    opacity: 0.3;
    pointer-events: none; /* Let clicks pass through to native resize */
    transition: opacity 0.2s ease;
}

.chat-window:hover::after {
    opacity: 0.6;
}

/* Resize area cursor - only bottom-right corner */
.chat-window {
    cursor: default;
}

.chat-window.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.hidden {
    display: none;
}

.show {
    display: flex;
}

.chat-header {
    background-color: var(--first-color-lighter);
    color: #fff;
    padding: 10px;
    text-align: center;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chat-header span {
    flex: 1;
}

.chat-close-btn {
    display: none; /* Hidden on desktop */
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 10px;
    line-height: 1;
}

.chat-close-btn:hover {
    opacity: 0.8;
}

.chat-messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    border-top: 1px solid #ccc;
    color: var(--text-color);
}

/* Chat message styles */
.chat-message {
    padding: 0.5rem 0;
    margin: 0.5rem 0;
    word-wrap: break-word;
}

.chat-message.user-message {
    text-align: right;
}

.chat-message.bot-message {
    text-align: left;
}

.chat-label {
    font-weight: 600;
    margin-right: 0.5rem;
    display: inline-block;
}

.chat-label.user {
    color: var(--first-color-lighter);
}

.chat-label.bot {
    color: var(--title-color);
}

.chat-message-text {
    display: inline;
    word-wrap: break-word;
}

.chat-input-container {
    display: flex;
    align-items: center;
    background-color: var(--first-color-alt);
}

#chat-input {
    background-color: var(--first-color-alt);
    color: white;
    font-family: var(--font-family);
    border: none;
    padding: 10px;
    flex: 1;
    box-sizing: border-box;
}

#chat-input::placeholder {
    color: white;
}

.chat-send-btn {
    background: none;
    border: none;
    color: white;
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.chat-send-btn:hover {
    opacity: 0.8;
}

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



.chat-head:hover {
    animation: pulse 1s;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}


/* Mobile responsive styles - Messenger-style floating chat */
@media screen and (max-width: 768px) {
    #chatbot-container {
        width: 90%;
        margin: 10px auto;
    }

    .chat-head {
        width: 50px;
        height: 50px;
        bottom: 20px;
        right: 15px;
        /* Enable touch dragging */
        touch-action: none;
    }

    .chat-window {
        /* Messenger-style floating window */
        width: calc(100vw - 30px);
        height: 350px;
        max-height: 50vh;
        max-width: none !important;
        min-width: 280px;
        min-height: 250px;
        bottom: 80px;
        right: 15px;
        left: auto;
        top: auto;
        border-radius: 12px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
        resize: both;
        overflow: hidden;
    }

    /* Hide resize handle on mobile for better UX */
    .chat-window::after {
        display: none;
    }

    /* When keyboard is open, move window up */
    .chat-window.keyboard-open {
        bottom: auto;
        top: 10px;
        max-height: 40vh;
    }

    .chat-window.show {
        position: fixed;
    }

    /* Ensure messages area is scrollable */
    .chat-window .chat-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Input container styling for mobile */
    .chat-window .chat-input-container {
        border-radius: 0 0 12px 12px;
    }

    .chat-window #chat-input {
        padding: 12px;
        font-size: 16px; /* Prevents iOS zoom on focus */
        border-radius: 0 0 0 12px;
    }

    .chat-window .chat-send-btn {
        border-radius: 0 0 12px 0;
    }

    /* Show close button on mobile */
    .chat-close-btn {
        display: block;
    }

    /* Rounded header on mobile */
    .chat-window .chat-header {
        border-radius: 12px 12px 0 0;
    }

    #chatbot-input {
        width: 100%;
        padding: 8px;
    }

    #chatbot-send {
        width: 100%;
        margin-top: 10px;
    }

    #chatbot-send, #chatbot-input {
        padding: 10px;
    }
}

@media screen and (min-width: 1024px) {
    .chat-head {
        width: 50px;
        height: 50px;
        bottom: 20px;
        right: 20px;
    }

    .chat-window {
        width: 300px;
        height: 400px;
        max-width: none !important;
    }
}