/* Floating Chat Button */
#chat-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--color-primary);
    color: var(--color-secondary);
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 30px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    z-index: 9999;
}
#chat-btn img{
    filter: brightness(0) invert(1);
    object-fit: contain;
}

/* Chat Box */
#chat-box {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 360px;
    max-height: 500px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 10px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Header */
#chat-header {
    background: var(--color-primary);
    color: var(--color-secondary);
    padding: 10px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#chat-options {
    display: flex;
    gap: 5px;
    align-items: center;
}

#chat-box .btn-chat {
    background: var(--color-primary);
    color: var(--color-secondary);
    border: 1px solid var(--color-secondary);
    border-radius: 5px;
    padding: 4px 8px;
    cursor: pointer;
    font-weight: bold;
}

#chat-box .btn-chat.btn-action {
    appearance: none;
    padding: 2px 4px;
    border-radius: 0;
    border: none;
    background: transparent;
}

#chat-box .chat-header-title {
    width: 100px;
    font-size: 15px;
    flex: 1;
}

#chat-box .btn-chat:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* #toggle-tts {
    background: #ffc107;
    color: #333;
} */

/* #end-chat {
    background: #dc3545;
    display: none;
    color: #fff;
} */
#chat-box .chat-controls {
    display: flex;
    gap: 5px;
    align-items: center;
    background-color: #fff;
    border-radius: 20px;
    padding: 0 4px;
}

/* Chat log */
#chat-log {
    padding: 10px 5px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#chat-log::-webkit-scrollbar-track {
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    background-color: transparent;
}

#chat-log::-webkit-scrollbar {
    width: 4px;
    height: 4px;
    background-color: transparent;
}

#chat-log::-webkit-scrollbar-thumb {
    border-radius: 10px;
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
    background-color: var(--color-primary);
}

#chat-box .chat-message {
    width: 100%;
    /* padding: 8px 12px; */
    border-radius: 15px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
}

#chat-box .input-error {
    color: red;
    font-size: 12px;
    margin-top: 4px;
    display: block;
    margin-bottom: 4px;
}

#chat-box .chat-description {
    margin-top: 2px;
    margin-bottom: 0px;
    font-style: italic;
}

#chat-box .sent {
    align-self: flex-end;
    /* background: var(--color-primary); */
    color: var(--color-secondary);
    border-bottom-right-radius: 0;
}

#chat-box .received {
    align-self: flex-start;
    /* background: #f1f0f0; */
    color: #333;
    border-bottom-left-radius: 0;
}

#chat-box .quick-replies button {
    margin: 3px 3px 3px 0;
}

/* Chat input */
#chat-input {
    display: none;
    border-top: 1px solid #ccc;
    padding: 8px;
    display: flex;
    gap: 5px;
    align-items: center;
}

#chat-input input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 13px;
}

#chat-input input:focus-visible {
    outline: 1px solid #777777;
}

#chat-input button {
    padding: 8px 12px;
    border: none;
    background: var(--color-primary);
    color: var(--color-secondary);
    cursor: pointer;
    border-radius: 50%;
    font-size: 18px;
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Voice recording */
#record-mode {
    display: none;
    align-items: center;
    justify-content: space-between;
    max-width: 100%;
    background: var(--color-secondary);
    /* border-radius: 5px; */
    padding: 6px 10px;
    border: 1px solid #ddd;
}

#timer {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    display: flex;
    align-items: center;
}

#red-dot {
    width: 10px;
    height: 10px;
    background: red;
    border-radius: 50%;
    margin-right: 6px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }

    100% {
        opacity: 1;
    }
}

#chat-box .record-action {
    display: flex;
    gap: 10px;
}

#chat-box .record-action button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    font-size: 15px;
    cursor: pointer;
    align-items: center;
}

#cancel-voice-btn {
    background: #ddd;
    color: #333;
}

#send-voice-btn {
    background: #28a745;
    color: #fff;
}

/* Chat controls */
#chat-controls {
    display: flex;
    gap: 5px;
    padding: 0px 10px;
    border-top: 1px solid #ccc;
    background: #fff;

    width: 26px;
    height: 26px;
    justify-content: center;
    align-items: center;
}

#chat-box .requst_data {
    display: block;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    margin-bottom: 5px;
    width: 100%;
}

#chat-box .requst_data_button {
    background: var(--color-primary);
    color: var(--color-secondary);
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    padding: 4px 10px;
}


/* ===============================
   CHAT LOG BASE
================================ */

#chat-log {
    position: relative;
    overflow-y: auto;
    min-height: 100%;
    transition: min-height 0.25s ease;
}

/* ===============================
   CHAT OVERLAY (SCOPED)
================================ */

#chat-box .chat-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    z-index: 10;
    animation: fadeIn 0.2s ease;
}

/* ===============================
   MODAL CENTER WRAPPER
================================ */

#chat-box .chat-modal-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 11;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    /* allow clicks only on modal */
}

/* ===============================
   INLINE CHAT MODAL
================================ */

#chat-box .chat-inline-modal {
    pointer-events: auto;
    width: 85%;
    max-width: 360px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    /* animation: fadeUp 0.25s ease; */
}

#chat-box .chat-inline-modal .chat-modal-header {
    padding: 6px 10px;
    font-weight: 600;
    border-bottom: 1px solid #eee;
}

#chat-box .chat-inline-modal .chat-modal-body {
    padding: 6px 10px;
    font-size: 13px;
    color: #555;
}

#chat-box .chat-inline-modal .chat-modal-footer {
    padding: 6px 10px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#chat-box .chat-inline-modal .btn-modal {
    padding: 6px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 13px;
}

#chat-box .chat-inline-modal .btn-modal.cancel {
    background: #f1f1f1;
}

#chat-box .chat-inline-modal .btn-modal.confirm {
    background: var(--color-primary);
    color: #fff;
}

/* ===============================
   ANIMATIONS
================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


#chat-box .chat-feedback {
    text-align: center;
}

#chat-box .chat-feedback .emoji-list {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 12px 0;
}

#chat-box .chat-feedback .emoji img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    transition: transform 0.15s ease;
}

#chat-box .chat-feedback .emoji:hover img {
    transform: scale(1.15);
}

#chat-box .chat-feedback .emoji.active img {
    transform: scale(1.25);
}


#chat-box .chat-feedback .feedback-label {
    margin-top: 8px;
    font-size: 13px;
    color: #555;
}

/* Sound wave animation */
#bars {
    display: flex;
    justify-content: center;
    align-items: center;
    /*     background: black; */
}

#chat-box .bar {
    background: #505050;
    bottom: 1px;
    height: 3px;
    width: 3px;
    margin: 0px 4px;
    border-radius: 5px;
    animation: sound 0ms -600ms linear infinite alternate;
}

@keyframes sound {
    0% {
        opacity: .35;
        height: 3px;
    }

    100% {
        opacity: 1;
        height: 25px;
    }
}

#chat-box .bar:nth-child(1) {
    left: 1px;
    animation-duration: 474ms;
}

#chat-box .bar:nth-child(2) {
    left: 15px;
    animation-duration: 433ms;
}

#chat-box .bar:nth-child(3) {
    left: 29px;
    animation-duration: 407ms;
}

#chat-box .bar:nth-child(4) {
    left: 43px;
    animation-duration: 458ms;
}

#chat-box .bar:nth-child(5) {
    left: 57px;
    animation-duration: 400ms;
}

#chat-box .bar:nth-child(6) {
    left: 71px;
    animation-duration: 427ms;
}

#chat-box .bar:nth-child(7) {
    left: 85px;
    animation-duration: 441ms;
}

#chat-box .bar:nth-child(8) {
    left: 99px;
    animation-duration: 419ms;
}

#chat-box .bar:nth-child(9) {
    left: 113px;
    animation-duration: 487ms;
}

#chat-box .bar:nth-child(10) {
    left: 127px;
    animation-duration: 442ms;
}


/* Chat avatar */
#chat-box .chat-message {
    display: flex;
    align-items: flex-end;
    margin-bottom: 12px;
}

/* BOT (LEFT) */
#chat-box .chat-message.received {
    flex-direction: row;
}

/* USER (RIGHT) */
#chat-box .chat-message.sent {
    flex-direction: row-reverse;
}

/* Avatar */
#chat-box .chat-message .avatar {
    width: 32px;
    height: 32px;
    margin: 0 8px 0px 4px;
    flex-shrink: 0;
}

#chat-box .chat-message.received .avatar {
    width: 42px;
    height: 42px;
    margin: 0 4px 0px 8px;
    flex-shrink: 0;
}

#chat-box .chat-message .avatar img {
    width: 100%;
    height: 100%;
    /* border-radius: 50%; */
    object-fit: cover;
}

/* Message bubble */
#chat-box .chat-message .bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.4;
}

/* Bot bubble */
#chat-box .chat-message.received .bubble {
    background: #f1f1f1;
    color: #333;
    border-bottom-left-radius: 4px;
    position: relative;
}
#chat-box .chat-message.received .bubble .replay-btn{
    position: absolute;
    right: -4px;
    bottom: -12px;
    cursor: pointer;
}
#chat-box .chat-message.received .bubble .replay-btn .chat-audio-play-btn{
    width: 28px;
    height: 28px;
    /* border-radius: 50%; */
    float: right;
    margin: 0px -8px 0px 5px;
    /* filter: drop-shadow(0px 0px 1px lightgray); */
}

/* User bubble */
#chat-box .chat-message.sent .bubble {
    background: var(--color-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

#chat-box .brand-footer-text {
    font-size: 12px;
    color: #777;
    text-align: center;
    padding: 6px 0;
}

#chat-box .brand-footer-text a {
    color: var(--color-primary);
    font-weight: 500;
    text-decoration: none;
}

#chat-box .chat-audio-play-btn {
    width: 18px;
    height: 18px;
    float: right;
    margin: 0px -8px 0px 5px;
}

#chat-box .chat-message .bubble:has(.request_data) {
    width: 65%;  
}
#chat-box .chat-message .request_data {
    width:100%;
    border: 1px solid #ccc;
}
