/*
 * Sanchar Saathi: the look of the autofill awareness popup and notice (ss-autofill.js). Linked in the head of the five
 * pages that carry them (home, Chakshu, the fraud and spam forms, RICWIN).
 *
 * - Every class starts with "ssa-". Spacing and layout are Bootstrap classes in the markup; this file has only colours,
 *   borders, shapes, the two drawn icons, motion, reduced motion and high contrast.
 * - Colours are the page's own DBIM variables (style/dbim.css), with the Blue group's values after them.
 * - Movement only inside prefers-reduced-motion: no-preference, in the chat window's style (ss-chat.css).
 * - High contrast (html.dbim-hc): the site's black and yellow.
 */

/* ---------- The notice ---------- */

.ssa-notice {
    background: #ffffff;
    border: 1px solid var(--dbim-c4, #A3BBF3);
    border-left: 0.375rem solid var(--dbim-c2, #214AAB);
}

.ssa-badge {
    width: 3.25rem;
    height: 3.25rem;
    color: #ffffff;
    background-color: var(--dbim-hover, #214AAB);
    background-image: linear-gradient(135deg, var(--dbim-c1, #162F6A) 0%, var(--dbim-hover, #214AAB) 100%);
    box-shadow: 0 3px 10px rgba(var(--dbim-c1-rgb, 22, 47, 106), 0.32);
}

.ssa-badge .dbim-ico {
    margin: 0;
    color: #ffffff;
}

.ssa-notice-title {
    color: var(--dbim-c1, #162F6A);
}

/* The notice folds away when the chat is not there (ss-autofill.js) */
.ssa-notice-row.ssa-folding {
    max-height: 0 !important;
    opacity: 0;
    margin-top: 0;
    margin-bottom: 0;
    overflow: hidden;
}

/* ---------- The popup's steps (the one the example shows is marked) ---------- */

.ssa-step-no {
    width: 2rem;
    height: 2rem;
    flex: none;
    color: var(--dbim-c1, #162F6A);
    background: var(--dbim-c5, #D2DFFF);
    border: 1px solid var(--dbim-c4, #A3BBF3);
    font-weight: 700;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.ssa-step.ssa-now .ssa-step-no {
    color: #ffffff;
    background: var(--dbim-c1, #162F6A);
    border-color: var(--dbim-c1, #162F6A);
}

.ssa-step-title {
    color: var(--dbim-c1, #162F6A);
}

.ssa-safety .dbim-ico {
    margin: 0;
    color: var(--dbim-c1, #162F6A);
}

/* ---------- The example: the chat beside the form ---------- */

.ssa-demo {
    overflow: hidden;
    background: var(--dbim-c5, #D2DFFF);
    border: 1px solid var(--dbim-c4, #A3BBF3);
}

/* The example keeps the height it is given: the chat's messages scroll inside it, as in the chat window */
.ssa-row-demo,
.ssa-row-demo > * {
    min-height: 0;
}

.ssa-tag {
    color: var(--dbim-c1, #162F6A);
    background: #ffffff;
    border: 1px solid var(--dbim-c4, #A3BBF3);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: var(--dbim-fs-small, 0.75rem);
}

.ssa-replay {
    background: #ffffff;
    transition: width 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.ssa-replay:hover {
    background: var(--bs-btn-hover-bg);
}

/* Two classes: Bootstrap's .d-inline-flex (display !important) comes after its [hidden] rule and would win */
.ssa-replay[hidden],
.ssa-face[hidden] {
    display: none !important;
}

.ssa-replay .dbim-ico {
    margin: 0;
}

.ssa-face {
    white-space: nowrap;
}

/* The notice's "Describe your incident" while it changes to "Opening the chat..." and back (ss-autofill.js) */
.ssa-start.ssa-swapping {
    white-space: nowrap;
}

/* Pause and play are not in the site's icon set: drawn in its line style (24 grid, 1.5 line, round joins, as its
   refresh.svg) and shown the DBIM way. Two classes: dbim-icons.css (linked later, by header.jsp) blanks the others */
.dbim-ico.ssa-ico-pause {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2024%2024'%20fill%3D'none'%20stroke%3D'%23000'%20stroke-width%3D'1.5'%20stroke-linejoin%3D'round'%20stroke-linecap%3D'round'%3E%3Crect%20x%3D'6.75'%20y%3D'5.25'%20width%3D'3.5'%20height%3D'13.5'%20rx%3D'1'%2F%3E%3Crect%20x%3D'13.75'%20y%3D'5.25'%20width%3D'3.5'%20height%3D'13.5'%20rx%3D'1'%2F%3E%3C%2Fsvg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2024%2024'%20fill%3D'none'%20stroke%3D'%23000'%20stroke-width%3D'1.5'%20stroke-linejoin%3D'round'%20stroke-linecap%3D'round'%3E%3Crect%20x%3D'6.75'%20y%3D'5.25'%20width%3D'3.5'%20height%3D'13.5'%20rx%3D'1'%2F%3E%3Crect%20x%3D'13.75'%20y%3D'5.25'%20width%3D'3.5'%20height%3D'13.5'%20rx%3D'1'%2F%3E%3C%2Fsvg%3E");
}

.dbim-ico.ssa-ico-play {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2024%2024'%20fill%3D'none'%20stroke%3D'%23000'%20stroke-width%3D'1.5'%20stroke-linejoin%3D'round'%20stroke-linecap%3D'round'%3E%3Cpath%20d%3D'M7%205.9v12.2a.75.75%200%200%200%201.15.63l9.55-6.1a.75.75%200%200%200%200-1.26L8.15%205.27A.75.75%200%200%200%207%205.9z'%2F%3E%3C%2Fsvg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2024%2024'%20fill%3D'none'%20stroke%3D'%23000'%20stroke-width%3D'1.5'%20stroke-linejoin%3D'round'%20stroke-linecap%3D'round'%3E%3Cpath%20d%3D'M7%205.9v12.2a.75.75%200%200%200%201.15.63l9.55-6.1a.75.75%200%200%200%200-1.26L8.15%205.27A.75.75%200%200%200%207%205.9z'%2F%3E%3C%2Fsvg%3E");
}

.ssa-chat,
.ssa-pane {
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(var(--dbim-c1-rgb, 22, 47, 106), 0.12), 0 0 0 1px rgba(var(--dbim-c1-rgb, 22, 47, 106), 0.06);
}

.ssa-chat {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.ssa-chat-head {
    flex: none;
    color: #ffffff;
    background-color: var(--dbim-hover, #214AAB);
    background-image: linear-gradient(135deg, var(--dbim-c1, #162F6A) 0%, var(--dbim-hover, #214AAB) 100%);
    font-size: 0.875rem;
}

.ssa-chat-head .dbim-ico {
    margin: 0;
    color: #ffffff;
}

.ssa-msgs {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    font-size: var(--dbim-fs-small, 0.75rem);
    line-height: 1.4;
}

.ssa-user {
    align-self: flex-end;
    max-width: 92%;
    padding: 0.5em 0.7em;
    border-radius: 14px 4px 14px 14px;
    color: #ffffff;
    background-color: var(--dbim-hover, #214AAB);
    background-image: linear-gradient(135deg, var(--dbim-hover, #214AAB) 0%, var(--dbim-c1, #162F6A) 100%);
    box-shadow: 0 2px 6px rgba(var(--dbim-c1-rgb, 22, 47, 106), 0.18);
}

.ssa-bot {
    align-self: flex-start;
    max-width: 96%;
    padding: 0.5em 0.7em;
    border-radius: 4px 14px 14px 14px;
    background: #ffffff;
    border: 1px solid var(--dbim-c4, #A3BBF3);
    box-shadow: 0 2px 6px rgba(var(--dbim-c1-rgb, 22, 47, 106), 0.18);
}

.ssa-dots {
    align-self: flex-start;
    display: inline-flex;
    gap: 4px;
    padding: 0.65em 0.8em;
    border-radius: 4px 14px 14px 14px;
    background: #ffffff;
    border: 1px solid var(--dbim-c4, #A3BBF3);
}

.ssa-dots i {
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--dbim-c3, #5279D7);
}

.ssa-action {
    align-self: flex-start;
    font-size: var(--dbim-fs-small, 0.75rem);
    font-weight: 700;
    color: var(--dbim-c1, #162F6A);
    background: #ffffff;
    border: 1px solid var(--dbim-c2, #214AAB);
    border-radius: 0.5rem;
    padding: 0.3rem 0.6rem;
    transition: transform 0.12s ease, background-color 0.15s ease;
}

.ssa-action .dbim-ico {
    margin: 0;
}

.ssa-action.ssa-pressed {
    transform: scale(0.94);
    background: var(--dbim-c5, #D2DFFF);
}

.ssa-hide {
    visibility: hidden;
    opacity: 0;
}

.ssa-gone {
    display: none !important;
}

.ssa-pane {
    position: relative;
    overflow: hidden;
}

.ssa-pane iframe {
    position: absolute;
    left: 0;
    top: 0;
    border: 0;
    transform-origin: 0 0;
    pointer-events: none;
}

/* Phones and small windows: the chat above the form, each its own height; the popup's body may scroll.
   !important and two classes: the markup's Bootstrap h-100 (for the side-by-side layout) is !important too, and on a
   phone it would leave the form's pane no height at all (its iframe is absolutely placed) */
@media (max-width: 991.98px) {
    .ssa-row-demo .ssa-chat {
        height: 18rem !important;
    }

    .ssa-row-demo .ssa-pane {
        height: 22rem !important;
    }
}

/* Short windows (laptops): less space around the popup, so the whole of it fits; Bootstrap still sizes it */
@media (max-height: 700px) {
    #autofill-modal {
        --bs-modal-margin: 0.5rem;
        --bs-modal-header-padding: 0.625rem 1rem;
    }

    #autofill-modal .modal-footer {
        padding-top: 0.375rem;
        padding-bottom: 0.375rem;
    }
}

@media (max-width: 575.98px) {
    .ssa-notice .btn {
        flex: 1 1 auto;
    }
}

/* ---------- Movement ---------- */

@media (prefers-reduced-motion: no-preference) {

    .ssa-notice-row.ssa-folding {
        transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
    }

    .ssa-steps .ssa-step {
        animation: ssa-from-right 0.34s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
    }

    .ssa-steps .ssa-step:nth-child(2) {
        animation-delay: 0.08s;
    }

    .ssa-steps .ssa-step:nth-child(3) {
        animation-delay: 0.16s;
    }

    .ssa-user.ssa-in {
        animation: ssa-from-right 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    }

    .ssa-bot.ssa-in {
        animation: ssa-from-left 0.34s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    }

    .ssa-dots.ssa-in {
        animation: ssa-from-left 0.24s ease both;
    }

    .ssa-dots i {
        animation: ssa-beat 1.1s infinite ease-in-out;
    }

    .ssa-dots i:nth-child(2) {
        animation-delay: 0.14s;
    }

    .ssa-dots i:nth-child(3) {
        animation-delay: 0.28s;
    }

    .ssa-action.ssa-in {
        animation: ssa-from-below 0.3s ease both;
    }

    /* Pause stops the chat; never the button itself */
    .ssa-paused .ssa-chat,
    .ssa-paused .ssa-chat * {
        animation-play-state: paused !important;
    }

    /* The button's change: the old face fades, the new icon pops in (the refresh arrow turning), its words fade in */
    .ssa-face.ssa-out {
        animation: ssa-fade-out 0.12s ease both;
    }

    .ssa-face.ssa-in .dbim-ico {
        animation: ssa-pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.35) both;
    }

    .ssa-face.ssa-in .dbim-ico-refresh {
        animation: ssa-spin-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
    }

    .ssa-face.ssa-in .ssa-face-words {
        animation: ssa-fade-in 0.25s ease 0.05s both;
    }

    /* The notice's button changes the same way ("Describe your incident" <-> "Opening the chat..."); Bootstrap's own
       colour changes are kept. The spinner keeps turning as it pops in (its size grows on "scale", not "transform") */
    .ssa-notice .ssa-start {
        transition: width 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    }

    .ssa-start > .ssa-out {
        animation: ssa-fade-out 0.12s ease both;
    }

    .ssa-start > .dbim-ico.ssa-in {
        animation: ssa-pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.35) both;
    }

    .ssa-start > .spinner-border.ssa-in {
        animation: ssa-pop-scale 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.35) both, spinner-border 0.75s linear infinite;
    }

    .ssa-start > span.ssa-in:not(.spinner-border) {
        animation: ssa-fade-in 0.25s ease 0.05s both;
    }
}

@keyframes ssa-pop-scale {
    from { opacity: 0; scale: 0.4; }
    to { opacity: 1; scale: 1; }
}

@keyframes ssa-from-right {
    from { opacity: 0; transform: translateX(18px); }
    to { opacity: 1; transform: none; }
}

@keyframes ssa-from-left {
    from { opacity: 0; transform: translateX(-18px); }
    to { opacity: 1; transform: none; }
}

@keyframes ssa-from-below {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

@keyframes ssa-pop {
    from { opacity: 0; transform: scale(0.4); }
    to { opacity: 1; transform: none; }
}

@keyframes ssa-spin-in {
    from { opacity: 0; transform: rotate(-180deg) scale(0.4); }
    to { opacity: 1; transform: none; }
}

@keyframes ssa-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ssa-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes ssa-beat {
    0%, 60%, 100% { transform: none; opacity: 0.5; }
    30% { transform: translateY(-3px); opacity: 1; }
}

/* ---------- High contrast: the site's black and yellow ---------- */

html.dbim-hc .ssa-notice,
html.dbim-hc .ssa-badge,
html.dbim-hc .ssa-step-no,
html.dbim-hc .ssa-demo,
html.dbim-hc .ssa-tag,
html.dbim-hc .ssa-chat,
html.dbim-hc .ssa-chat-head,
html.dbim-hc .ssa-user,
html.dbim-hc .ssa-bot,
html.dbim-hc .ssa-dots,
html.dbim-hc .ssa-action,
html.dbim-hc .ssa-pane,
html.dbim-hc .ssa-replay {
    background: #000000;
    background-image: none;
    color: #ffff00;
    border-color: #ffff00;
    box-shadow: none;
}

html.dbim-hc .ssa-notice {
    border: 1px solid #ffff00;
    border-left: 0.375rem solid #ffff00;
}

html.dbim-hc .ssa-badge,
html.dbim-hc .ssa-user,
html.dbim-hc .ssa-chat-head,
html.dbim-hc .ssa-demo,
html.dbim-hc .ssa-chat,
html.dbim-hc .ssa-pane {
    border: 1px solid #ffff00;
}

html.dbim-hc .ssa-badge .dbim-ico,
html.dbim-hc .ssa-chat-head .dbim-ico,
html.dbim-hc .ssa-safety .dbim-ico,
html.dbim-hc .ssa-notice-title,
html.dbim-hc .ssa-step-title {
    color: #ffff00;
}

html.dbim-hc .ssa-dots i {
    background: #ffff00;
}

html.dbim-hc .ssa-step.ssa-now .ssa-step-no {
    background: #ffff00;
    color: #000000;
    border-color: #ffff00;
}
