﻿/* Header buttons container */
.header-buttons {
    display: flex;
    gap: 8px;
}

/* Reset button */
.reset-btn {
    background: rgba(255, 255, 255, 0.25);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 20px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

    .reset-btn:hover {
        background: rgba(255, 255, 255, 0.4);
        transform: rotate(180deg);
    }

/* Input wrapper to position dots inside the input */
.input-wrapper {
    position: relative;
    flex: 1;
}

    .input-wrapper input {
        width: 100%;
        padding-left: 16px;
        padding-right: 16px;
    }

        /* Hide placeholder when typing indicator is active */
        .input-wrapper input.typing::placeholder {
            color: transparent;
        }

/* Typing indicator (three bouncing dots) */
.typing-indicator {
    position: absolute;
    left: 26px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

    .typing-indicator.active {
        opacity: 1;
    }

    .typing-indicator span {
        width: 7px;
        height: 7px;
        background-color: #999;
        border-radius: 50%;
        display: inline-block;
        animation: typingBounce 1.4s infinite ease-in-out;
    }

        .typing-indicator span:nth-child(1) {
            animation-delay: 0s;
        }

        .typing-indicator span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .typing-indicator span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* -------------------- TOGGLE BUTTON -------------------- */
.chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, orange, orangered);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(255, 69, 0, 0.4);
    z-index: 1001;
    transition: all 0.3s ease;
    border: none;
    user-select: none;
}

    .chat-toggle:hover {
        transform: scale(1.1) rotate(10deg);
        box-shadow: 0 12px 35px rgba(255, 69, 0, 0.6);
    }

/* -------------------- CHAT CONTAINER -------------------- */
.chat-container {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 800px;
    max-width: 90vw;
    height: 1000px;
    max-height: 90vh;
    border: 1px solid #ccc;
    border-radius: 10px;
    background: white;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    font-family: 'Segoe UI', Arial, sans-serif;
    z-index: 9999999;
    overflow: hidden;
    animation: slideUp 0.35s ease-out forwards;
    transform-origin: bottom right;
    display: none;
}

/* Slide-up animation */
@keyframes slideUp {
    from {
        transform: translateY(100%) scale(0.8);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.chat-container.closing {
    animation: fadeOut 0.25s ease-in forwards;
}

@keyframes fadeOut {
    to {
        transform: translateY(50px) scale(0.9);
        opacity: 0;
    }
}

/* -------------------- HEADER -------------------- */
.chat-header {
    position: relative;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 15px 18px;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10;
}

.close-btn {
    background: rgba(255, 255, 255, 0.25);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 22px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

    .close-btn:hover {
        background: rgba(255, 255, 255, 0.4);
        transform: rotate(90deg);
    }

/* -------------------- MESSAGES AREA – ABSOLUTE POSITIONING (SCROLL GUARANTEED) -------------------- */
.chat-messages {
    position: absolute;
    top: 60px; /* Below header */
    left: 0;
    right: 0;
    bottom: 70px; /* Above input */
    padding: 15px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    background: #f8f9fa;
    /* FORCE VISIBLE & CLICKABLE SCROLLBAR */
    scrollbar-width: auto;
    -ms-overflow-style: auto;
    /* WebKit */
    :: -webkit-scrollbar

{
    width: 14px !important;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
    border: 1px solid #ddd;
}

::-webkit-scrollbar-thumb {
    background: #007bff;
    border-radius: 10px;
    border: 3px solid #f1f1f1;
    min-height: 40px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: #0056b3;
    }

}

/* -------------------- MESSAGE BUBBLES -------------------- */
.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 20px;
    word-wrap: break-word;
    line-height: 1.45;
    font-size: 14.5px;
    margin-bottom: 10px;
    animation: messagePop 0.3s ease-out;
}

@keyframes messagePop {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    background: linear-gradient(135deg, #dcf8c6, #a8e6cf);
    margin-left: auto;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.ai-message {
    background: white;
    margin-right: auto;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
    color: #2c3e50;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    max-width: 100%;
    padding-right: 10px;
    margin-right: 0;
}

.message a {
    color: #007bff;
    text-decoration: underline;
    font-weight: 500;
}

    .message a:hover {
        color: #0056b3;
        text-decoration: none;
    }

/* -------------------- INPUT AREA -------------------- */
.chat-input {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    border-top: 1px solid #dee2e6;
    padding: 15px;
    background: #f8f9fa;
    gap: 10px;
}

    .chat-input input {
        flex: 1;
        padding: 12px 16px;
        border: 1px solid #ced4da;
        border-radius: 25px;
        font-size: 14px;
        outline: none;
    }

        .chat-input input:focus {
            border-color: #007bff;
            box-shadow: 0 0 0 3px rgba(0,123,255,0.15);
        }

    .chat-input button {
        padding: 12px 24px;
        background: #007bff;
        color: white;
        border: none;
        border-radius: 25px;
        cursor: pointer;
        font-weight: 500;
        font-size: 14px;
        min-width: 70px;
    }

        .chat-input button:hover:not(:disabled) {
            background: #0056b3;
        }

/* -------------------- MOBILE FULL-SCREEN -------------------- */
@media (max-width: 500px) {
    .chat-container {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .chat-toggle {
        bottom: 15px;
        right: 15px;
        width: 56px;
        height: 56px;
        font-size: 26px;
        display: block;
    }

    .chat-messages {
        top: 70px;
        bottom: 80px;
        padding: 18px;
    }

    .chat-input {
        padding: 18px;
    }

        .chat-input input {
            font-size: 16px;
            padding: 14px 18px;
        }

        .chat-input button {
            padding: 14px 26px;
            font-size: 15px;
        }
}

/* -------------------- UTILITY -------------------- */
.hidden {
    display: none !important;
}
