:root {
    --c-s-color-bot-content: #9cc3ff;
    --c-s-color-bot-content--repeat: #fd92ac;
    --c-s-color-bot-icon: #2c5cab;
    --c-s-color-respondent-content: #b6f7b6;
    --c-s-color-respondent-icon: #00bb23;
    --c-s-color-send: #3787ff;
    --c-s-color-send-active: #3352fc;
    --c-s-color-send-disabled: #a5b6ff;
    --c-s-border-radius: 6px; /* like bootstrap */
    --c-s-messages-bg: #f9f9f9;
    --c-s-color-respondent-status-send: rgba(11, 20, 26, .2);
    --c-s-color-respondent-status-received: #53bdeb;
}

.c-s-container {
    position: relative;
    display: grid;
    grid-template-areas: "head" "messages" "respondent-input" "note";
    grid-template-rows: auto 1fr auto auto;
    grid-template-columns: 100%;
    height: calc(100vh - 260px); /* calc in js */
    margin: 2px;
    background-color: white;
}

.c-s-container.fullscreen {
    position: fixed;
    top: 6px;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
    margin: 0;
}

.c-s-container .input-group {
    margin: 0;
    display: flex;
    align-items: stretch;
    justify-content: space-between;
}

.c-s-container .input-group .form-control {
    flex-grow: 1;
    display: block;
    border-top-left-radius: 0;
    float: none;
    width: auto;
}

.c-s-container .input-group .input-group-btn {
    width: auto;
}

.c-s-layout-rotate {
    display: none;
    opacity: 0;
}

.c-s-head {
    position: relative;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    padding: 4px 2px;
    font-size: 0.75em;
    color: grey;

}
.c-s-btn-speech {
    background: transparent;
    border: none;
    padding: 1px 5px;
    font-size: 12px;
    line-height: 1.5;
    border-radius: 3px;
}

.c-s-head .btn.active, .c-s-head .btn-default:hover {
    background: unset;
    box-shadow: unset;
    width: unset !important;
}

.c-s-head .btn.active {
    color: #3787ff;
}

.c-s-messages {
    position: relative;
    padding: 8px 6px;
    overflow-y: auto;
    overflow-x: hidden;
    border: thin solid lightgray;
    border-bottom: 0;
    border-top-left-radius: var(--c-s-border-radius);
    border-top-right-radius: var(--c-s-border-radius);
    background: var(--c-s-messages-bg);
    z-index: 0;
}

.c-s-respondent-input {
    position: relative;
    border: thin solid lightgrey;
    border-bottom-left-radius: var(--c-s-border-radius);
    border-bottom-right-radius: var(--c-s-border-radius);
    background-color: white;

}
.c-s-respondent-input-send {
    position: absolute;
    right: 6px;
    bottom: 6px;
    background: transparent;
    border: none;
    color: var(--c-s-color-send);
    font-size: 2.5rem;
    transition: color .2s;
    padding: 0 6px;
}

.c-s-respondent-input-send:hover {
    color: var(--c-s-color-send-active);
}
.c-s-respondent-input-send:disabled {
    color: var(--c-s-color-send-disabled);
}

.c-s-respondent-input-field {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 6px 44px 6px 6px;
    border-bottom-left-radius: var(--c-s-border-radius);
    border-bottom-right-radius: var(--c-s-border-radius);
    background-color: #e5e5e5;
}

/* Hide scrollbar for IE, Edge and Firefox */
.c-s-respondent-input-field {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
/* Hide scrollbar for Chrome, Safari and Opera */
.c-s-respondent-input-field::-webkit-scrollbar {
    display: none;
}

.c-s-respondent-input-field:disabled {
    cursor: not-allowed;
    background-color: var(--c-s-messages-bg);
}

.c-s-btn-scroll {
    position: absolute;
    right: 24px;
    top: -40px;
    color: var(--c-s-color-send);
    opacity: 0;
    transition: opacity .2s;
}

@keyframes conversationalSurveyMessageBot {
    0% {
        opacity: 0;
        transform: scale(0.5) translateX(100px);
    }
    80% {
        opacity: 1;
        transform: scale(1.01) translateX(-5px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateX(0);
    }
}
@keyframes conversationalSurveyMessageBotReplaced {
    0%, 20%, 40%, 60%, 80%, 100% {
        transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
    }
    0% {
        opacity: 0;
        transform: scale(0.6);
    }
    20% {
        transform: scale(1.05);
    }
    40% {
        transform: scale(0.95);
    }
    60% {
        opacity: 1;
        transform: scale(1.02);
    }
    80% {
        transform: scale(0.98);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes conversationalSurveyMessageBotRepeated {
    0%, 100% {
        transform: translate3d(0, 0, 0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translate3d(-15px, 0, 0);
    }
    20%, 40%, 60%, 80% {
        transform: translate3d(15px, 0, 0);
    }
}

@keyframes conversationalSurveyMessageRespondent {
    0% {
        opacity: 0;
        transform: scale(0.5) translateX(100px);
    }
    80% {
        opacity: 1;
        transform: scale(1.01) translateX(5px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateX(0);
    }
}

.c-s-msg {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 12px;
    opacity: 0;
    animation-fill-mode: both;
    animation-duration: 200ms;
}

.c-s-messages-system {
    position: absolute;
    top: calc(100% + 1px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 360px;
    max-width: 360px;

    padding: 4px 10px;

    border: thin solid lightgray;
    border-top: 0;
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 14px;

    font-size: 13px;
    line-height: 1.2;
    background-color: #fcf8e3;
    color: #3e2723;
    text-align: center;
    z-index: 1;
}

.c-s-msg.--shown {
    opacity: 1;
}

.c-s-msg.--bot:not(.--replaced):not(.--repeat) {
    flex-direction: row;
    animation-name: conversationalSurveyMessageBot;
}
.c-s-msg.--bot.--replaced .c-s-msg-content {
    animation-name: conversationalSurveyMessageBotReplaced;
}

.c-s-msg.--bot.--repeat .c-s-msg-content {
    animation-name: conversationalSurveyMessageBotRepeated;
}

.c-s-msg.--respondent {
    flex-direction: row-reverse;
    animation-name: conversationalSurveyMessageRespondent;
}


.c-s-msg-avatar {
    border: thin solid;
    width: 4rem;
    height: 4rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    font-size: 2.5rem;
    overflow: hidden;
}

.--bot .c-s-msg-avatar {
    border-color: var(--c-s-color-bot-icon);
    color: var(--c-s-color-bot-icon);
}

.--respondent .c-s-msg-avatar {
    border-color: var(--c-s-color-respondent-icon);
    color: var(--c-s-color-respondent-icon);
}

.c-s-msg-avatar img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.c-s-msg-content {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-width: calc(100% - 20rem);
    position: relative;
    border-radius: 1rem;
    padding: .8rem .8rem;
    animation-fill-mode: both;
    animation-duration: 500ms;
}

.c-s-msg-content::before,
.c-s-msg-content::after {
    content: '';
    position: absolute;
    bottom: 0;
}
.c-s-msg-content::after {
    top: 0;
    left: 0;
    right: 0;
    border-radius: 1rem;
    z-index: -1;
}
.c-s-msg-content::before {
    border: 0.7rem solid transparent;
    z-index: -2;
}

.--bot .c-s-msg-content,
.--bot .c-s-msg-content::after {
    border-bottom-left-radius: 0;
}
.--bot .c-s-msg-content::before {
    box-shadow: 2px 2px 4px lightgrey;
    left: -1.2rem;
}

.--bot:not(.--repeat) .c-s-msg-content::after {
    background-color: var(--c-s-color-bot-content);
    box-shadow: -2px 0 0 var(--c-s-color-bot-content), 2px 2px 4px lightgrey;
}
.--bot:not(.--repeat) .c-s-msg-content::before {
    border-bottom-color: var(--c-s-color-bot-content);
    border-right-color: var(--c-s-color-bot-content);
}

.--bot.--repeat .c-s-msg-content::after {
    background-color: var(--c-s-color-bot-content--repeat);
    box-shadow: -2px 0 0 var(--c-s-color-bot-content--repeat), 2px 2px 4px lightgrey;
}
.--bot.--repeat .c-s-msg-content::before {
    border-bottom-color: var(--c-s-color-bot-content--repeat);
    border-right-color: var(--c-s-color-bot-content--repeat);
}

.--respondent .c-s-msg-content,
.--respondent .c-s-msg-content::after {
    border-bottom-right-radius: 0;
}
.--respondent .c-s-msg-content::after {
    background-color: var(--c-s-color-respondent-content);
    box-shadow: 2px 0 0 var(--c-s-color-respondent-content), -2px 2px 4px lightgrey;
}
.--respondent .c-s-msg-content::before {
    box-shadow: -2px 2px 4px lightgrey;
    right: -1.2rem;
    border-bottom-color: var(--c-s-color-respondent-content);
    border-left-color: var(--c-s-color-respondent-content);
}

.c-s-msg-content-texts {
    display: grid;
    grid-template-columns: 1fr 32px;
    align-items: start;
    width: 100%;
    justify-content: space-between;
    gap: 10px;
}

.c-s-msg-content-text {
    max-width: 100%;
    white-space: pre-wrap;
    word-break: break-word;
}

.c-s-msg-content-text.question-text {
    font-size: inherit;
}

.--loader .c-s-msg-content-text {
    white-space: normal;
}

.c-s-btn-round {
    border-radius: 22px;
    width: 32px;
    height: 32px;
    border: 0;
}

.c-s-btn-play {
    opacity: 0;
    transition: opacity .2s;
    background-color: #fff;
}

.c-s-msg-content-header {
    font-size: .74em;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    min-width: 180px;
    align-items: center;
}

.c-s-msg-content-footer {
    display: flex;
    font-size: .65em;
    justify-content: flex-end;
}

.--respondent .c-s-msg-content-footer-status {
    position: relative;
    transform: scale(1.4, 1);
    right: 1px;
    top: 1px;
}

.--respondent .c-s-msg-content-footer-status::before {
    content: '\2713';
    color: var(--c-s-color-respondent-status-send);
}

.--respondent .c-s-msg-content-footer-status-received::before {
    color: var(--c-s-color-respondent-status-received);
}

.--respondent .c-s-msg-content-footer-status-received::after {
    content: '\2713';
    color: var(--c-s-color-respondent-status-received);
    position: absolute;
    right: -3px;
}

.c-s-bot-typing {
    position: relative;
    display: inline-block;
    width: 32px;
    color: #777;
}

.c-s-bot-typing svg {
    position: absolute;
    top: -10px;
}

.c-s-container-note {
    font-size: 0.75em;
    color: grey;
}

.c-s-container-note-text {
    padding: 2px 4px;
}

.c-s-messages-system,
.c-s-btn-play,
.c-s-btn-scroll {
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

.c-s-messages-system.--shown,
.c-s-btn-play.--shown,
.c-s-btn-scroll.--shown {
    opacity: 1;
    pointer-events: auto;
}

@keyframes c-s-btn-play-pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.5); }
    100% { box-shadow: 0 0 0 9px rgba(0, 123, 255, 0); }
}

.c-s-btn-play.--pulse {
    animation: c-s-btn-play-pulse 1.4s ease-out infinite;
}

.respondent-input-field {
    position: relative;
    min-height: 5rem;
    max-height: 12rem;
    width: 100%;
    overflow-y: auto;
    word-break: break-word;
    border: thin solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.42857143;
    background-color: white;
    outline: none;
    padding: 6px 8px;
}

.respondent-input-field.disabled {
    cursor: not-allowed;
    background-color: #eee;
}

.respondent-input-field:focus {
    border-color: #66afe9;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6);
}

.respondent-input-field.empty::before {
    content: attr(data-placeholder);
    color: #999;
    pointer-events: none;
    position: absolute;
    left: 8px;
    top: 6px;
}

.rotate-message {
    display: none;
}

.row-controls-frame {
    display: grid;
    grid-template-areas: "h-left h-center h-right";
    grid-auto-columns: 1fr 1fr 1fr;
    justify-content: space-between;
    align-items: center;
}

.h-left {
    grid-area: h-left;
    text-align: left;
}

.h-center {
    grid-area: h-center;
    text-align: center;
}

.h-right {
    grid-area: h-right;
    text-align: right;
}

.btn-active-speech.active, .btn-active-speech.active:hover {
    color: blue;
}

.btn-active-speech:hover, .btn-active-speech.active:hover {
    background-color: #e6e6e6;
    border-color: #adadad;
}

@media only screen and (max-width: 668px) {
    .c-s-container {
        height: calc(100vh - 152px);
    }

    .c-s-msg-content {
        max-width: calc(100% - 6rem);
    }

    .c-s-head .btn,
    .c-s-btn-scroll,
    .c-s-btn-speech {
        width: unset !important;
    }
}

@media (max-width: 991px) {
    .row-controls-frame {
        grid-template-areas:  "h-right" "h-left" "h-center";
        grid-auto-columns: 1fr;
    }

    .row-controls-frame .btn {
        width: 100%;
    }

    .c-s-head .btn,
    .c-s-btn-scroll,
    .c-s-btn-speech {
        width: unset !important;
    }
}

@media screen and (max-height: 380px), screen and (min-width:320px) and (max-width:767px) and (orientation:landscape) {
    .c-s-head .btn,
    .c-s-respondent-input .btn {
        width: unset !important;
    }

    .c-s-layout-rotate {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        opacity: .75;
        background-color: black;
        z-index: 2;

        i {
            color: white;
            font-size: 5em;
            animation: noRotate 1s infinite;
            opacity: 0.6;
        }

        .rotate-message {
            font-size: 1.5em;
            color: white;
        }
    }
}

@keyframes noRotate {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}
