/* -------- Topbar -------- */
#topbar_layer {
    --topbar-bg-rgb: 255, 255, 255;
    z-index: 10; /* floating layer */
    position: absolute;
    top: 100px;
    left: 40px;
    width: 1000px;
    height: 384px;
    background: rgb(var(--topbar-bg-rgb));
    box-shadow: 0px 0px 60px rgba(0, 0, 0, 0.25);
    border: 1px solid #fff;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

#topbar_layer .text_container {
    position: absolute;
    top: 91px;
    left: 300px;
    width: 670px;
    height: 201px;
    display: flex;
    align-items: center;
}

#topbar_layer .text_container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 0%; /* hidden initially on engagement page */
    height: 42px;
    background: linear-gradient(to bottom, rgba(var(--topbar-bg-rgb), 1), rgba(var(--topbar-bg-rgb), 0.7) 40%, rgba(var(--topbar-bg-rgb), 0.5) 70%);
    pointer-events: none; /* Allow clicks to pass through */
    z-index: 12; /* Ensure it's above the text */
}

#topbar_layer .text_container #agent_text {
    width: 100%;
    max-height: 201px;
    font-family: 'Work Sans';
    font-style: normal;
    font-weight: 400;
    font-size: 57px;
    line-height: 67px;
    color: #121212;
    overflow-y: auto;
    white-space: pre-wrap; /* Preserve whitespace and wrap as needed */
    word-wrap: break-word;
    flex: none;
    order: 1;
    flex-grow: 0;
}
#topbar_layer .text_container #agent_text::-webkit-scrollbar {
    display: none; /* hide scrollbar in Chrome, Safari, Opera */
}

#topbar_layer .text_container #agent_text span {
    opacity: 0;
    animation: agentTextFadeIn 0.6s ease forwards;
}

@keyframes agentTextFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

#topbar_layer .avatar_icon {
    position: absolute;
    top: 72px;
    left: 20px;
    width: 240px;
    height: 240px;
    box-sizing: border-box;
    border-radius: 50%;
}

/* Termination countdown ring sweep */
@property --termination-progress {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

#topbar_layer .avatar_icon.terminating {
    border: 4px solid transparent;
    border-radius: 50%;
    --termination-progress: 0deg;

    /* draw the sweep only in the border ring, keep center transparent */
    background:
        conic-gradient(
            from 0deg,
            #6b7280 0deg var(--termination-progress),
            rgb(var(--topbar-bg-rgb)) var(--termination-progress) 360deg
        ) border-box,
        transparent padding-box;
    background-clip: border-box, padding-box;

    animation: avatarTerminationSweep var(--termination-duration, 10s) linear forwards;
}

@keyframes avatarTerminationSweep {
    to { --termination-progress: 360deg; }
}

#topbar_layer .voice_icon {
    display: none; /* Hidden by default until activate_topbar is called */
    position: absolute;
    top: 120px;
    left: 131px;
    width: 64px;
    height: 64px;
}

/* -------- User Input -------- */
#user_input_layer {
    z-index: 10; /* floating layer */
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 301px;
    background: #fff;
    box-shadow: 0px 0px 40px rgba(18, 18, 18, 0.25);
    display: none; /* hidden by default, shown when activated */
}

#user_input_layer .prompt {
    position: absolute;
    width: 1000px;
    height: 63px;
    left: 40px;
    top: 20px;
}

#user_input_layer .prompt #user_input_text {
    position: absolute;
    width: 936px;
    height: 28px;
    left: 0px;
    top: 17px;
    font-family: 'Work Sans';
    font-style: normal;
    font-weight: 600;
    font-size: 24px;
    line-height: 28px;
    color: #BFBFBF;
    white-space: nowrap;
    overflow-x: hidden;
    /* Input reset — strip browser defaults */
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    outline: none;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    cursor: default;
    -webkit-user-select: none;
    user-select: none;
}

#user_input_layer .prompt #user_input_text::placeholder {
    color: #BFBFBF;
    font-weight: 600;
}

/* Typing mode: keyboard is open and user can edit */
#user_input_layer .prompt #user_input_text:not([readonly]) {
    cursor: text;
    color: #121212;
    border-bottom: 2px solid #728E69;
    -webkit-user-select: text;
    user-select: text;
}

#user_input_layer #suggestions_row_1 {
    position: absolute;
    width: 1040px;
    height: 62px;
    left: 40px;
    top: 112px;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0px;
    gap: 16px;
    overflow-x: auto;
}

#user_input_layer #suggestions_row_1::-webkit-scrollbar {
    display: none; /* hide scrollbar in Chrome, Safari, Opera */
}

#user_input_layer #suggestions_row_2 {
    position: absolute;
    width: 1040px;
    height: 62px;
    left: 40px;
    top: 196px;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0px;
    gap: 16px;
    overflow-x: auto;
}

#user_input_layer #suggestions_row_2::-webkit-scrollbar {
    display: none; /* hide scrollbar in Chrome, Safari, Opera */
}

#user_input_layer .suggestion {
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 16px;
    gap: 10px;
    background: #fff;
    border: 1px solid #728E69;
    flex: none;
    order: 0;
    flex-grow: 0;
    font-family: 'Work Sans';
    font-style: normal;
    font-weight: 600;
    font-size: 24px;
    line-height: 28px;
    color: #728E69;
}

#user_input_layer .customer_voice_icon {
    position: absolute;
    width: 64px;
    height: 64px;
    left: 990px;
    top: 24px;
    border-radius: 50%;
    overflow: hidden;
    clip-path: circle(24px at 50% 50%);
    cursor: pointer;
}

#user_input_layer .customer_voice_icon::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(200, 200, 200, 0.50);
    transition: background 0.15s ease;
    pointer-events: none;
}

#user_input_layer .customer_voice_icon[speaking-state="user-speaking"]::after {
    background: rgba(20, 190, 255, 0.50);
}

/* Muted state: darker gray overlay to clearly distinguish from idle */
#user_input_layer .customer_voice_icon[speaking-state="muted"]::after {
    background: rgba(80, 80, 80, 0.20);
}

#user_input_layer .customer_voice_icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* -------- Global Interaction Blocking -------- */
body.interaction-blocked * {
    pointer-events: none !important;
}

body.interaction-blocked #inactivity_modal_layer,
body.interaction-blocked #inactivity_modal_layer * {
    pointer-events: auto !important;
}

/* -------- Inactivity Modal -------- */
#inactivity_modal_layer {
    z-index: 100;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    /* hidden by default */
}

#inactivity_modal_layer:not(.hidden) {
    display: block !important;
}

#inactivity_modal_layer.hidden {
    display: none !important;
}

#inactivity_overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

#inactivity_dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    background: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0px 4px 24px rgba(0, 0, 0, 0.15);
    padding: 32px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

#inactivity_message {
    font-family: 'Work Sans';
    font-style: normal;
    font-weight: 600;
    font-size: 24px;
    line-height: 32px;
    color: #121212;
    margin: 0;
}

#inactivity_actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.inactivity_btn {
    width: 100%;
    height: 56px;
    border-radius: 8px;
    font-family: 'Work Sans';
    font-style: normal;
    font-weight: 600;
    font-size: 18px;
    line-height: 24px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

#inactivity_btn_continue {
    background: #F5F5F5;
    color: #121212;
}

#inactivity_btn_continue:hover {
    background: #E0E0E0;
}

#inactivity_btn_start_new {
    background: #728E69;
    color: #FFFFFF;
}

#inactivity_btn_start_new:hover {
    background: #5A7352;
}

#inactivity_btn_end {
    font-family: 'Work Sans';
    font-style: normal;
    font-weight: 400;
    font-size: 16px;
    line-height: 24px;
    text-decoration-line: underline;
    color: #4B6F44;
    cursor: pointer;
    margin-top: 8px;
    display: block;
    background: none;
    border: none;
    width: auto;
    align-self: center;
}