/* =========================================================
   MSD OFFLINE ENQUIRY WIDGET
   FLOW: greeting -> offline message -> single visible form
   UI: MSD premium navy/red theme
   Desktop: fixed panel height + internal scroll
   Mobile: responsive, viewport-safe
========================================================= */

#msd-oew {
    --msd-oew-primary: #0b2d5c;
    --msd-oew-primary-dark: #071f40;
    --msd-oew-accent: #d71932;
    --msd-oew-text: #202833;
    --msd-oew-muted: #707985;
    --msd-oew-border: #e3e7ec;
    --msd-oew-surface: #ffffff;
    --msd-oew-chat: #f5f7f9;

    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 999999;

    width: 380px;
    max-width: calc(100vw - 36px);

    font-family: Arial, Helvetica, sans-serif;
}

#msd-oew.msd-oew-left {
    right: auto;
    left: 28px;
}


/* =========================================================
   FLOATING LAUNCHER
========================================================= */

#msd-oew .msd-oew-bubble {
    margin-left: auto;

    min-height: 54px;
    padding: 7px 17px 7px 10px;

    display: flex;
    align-items: center;
    gap: 10px;

    border: 0;
    border-radius: 30px;

    background: var(--msd-oew-primary);
    color: #fff;

    box-shadow: 0 14px 38px rgba(7,31,64,.22);

    cursor: pointer;

    font-family: inherit;
    font-size: 13px;
    font-weight: 700;

    transition: transform .22s ease, box-shadow .22s ease;
}

#msd-oew .msd-oew-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 44px rgba(7,31,64,.27);
}

#msd-oew .msd-oew-bubble-icon {
    width: 38px;
    height: 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: rgba(255,255,255,.13);
}


/* =========================================================
   PANEL
========================================================= */

#msd-oew .msd-oew-panel {
    position: absolute;
    right: 0;
    bottom: 67px;

    width: 380px;
    max-width: min(380px, calc(100vw - 36px));

    /* Compact floating panel: never dominates the desktop viewport */
    height: 65vh;
    min-height: 460px;
    max-height: 680px;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    border: 1px solid rgba(7,31,64,.09);
    border-radius: 16px;

    background: var(--msd-oew-surface);

    box-shadow:
        0 26px 75px rgba(7,31,64,.19),
        0 5px 18px rgba(7,31,64,.07);

    animation: msdOewPanelIn .24s ease both;
}

#msd-oew.msd-oew-left .msd-oew-panel {
    right: auto;
    left: 0;
}

#msd-oew .msd-oew-panel[hidden] {
    display: none !important;
}

@keyframes msdOewPanelIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* =========================================================
   HEADER
========================================================= */

#msd-oew .msd-oew-head {
    flex: 0 0 auto;

    min-height: 104px;
    padding: 20px 20px 18px;

    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    background: linear-gradient(135deg, var(--msd-oew-primary), var(--msd-oew-primary-dark));
    color: #fff;
}

#msd-oew .msd-oew-head-main {
    min-width: 0;
}

#msd-oew .msd-oew-brand {
    display: flex;
    align-items: center;
    gap: 7px;

    margin-bottom: 9px;

    color: rgba(255,255,255,.68);

    font-size: 9px;
    line-height: 1;
    font-weight: 700;
    letter-spacing: 1.7px;
}

#msd-oew .msd-oew-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 4px 5px;

    border: 1px solid rgba(255,255,255,.3);
    border-radius: 4px;

    color: #fff;
    font-size: 8px;
    letter-spacing: 1px;
}

#msd-oew .msd-oew-head h3 {
    margin: 0 0 7px;

    color: #fff;

    font-family: Arial, Helvetica, sans-serif;
    font-size: 21px;
    line-height: 1.2;
    font-weight: 700;
}

#msd-oew .msd-oew-reply-status {
    display: flex;
    align-items: center;
    gap: 7px;

    color: rgba(255,255,255,.88);

    font-size: 11px;
    line-height: 1.3;
}

#msd-oew .msd-oew-status-dot {
    width: 8px;
    height: 8px;

    flex: 0 0 8px;

    border-radius: 50%;
    background: #9da5ad;
}

#msd-oew .msd-oew-close {
    width: 32px;
    height: 32px;

    flex: 0 0 32px;

    margin-left: 12px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 1px solid rgba(255,255,255,.24);
    border-radius: 50%;

    background: rgba(255,255,255,.06);
    color: #fff;

    font-family: Arial, sans-serif;
    font-size: 23px;
    font-weight: 300;
    line-height: 1;

    cursor: pointer;

    transition: background .2s ease;
}

#msd-oew .msd-oew-close:hover {
    background: rgba(255,255,255,.14);
}


/* =========================================================
   SCROLLABLE CHAT AREA
========================================================= */

#msd-oew .msd-oew-chat {
    flex: 1 1 auto;
    min-height: 0;

    overflow-y: auto;
    overflow-x: hidden;

    padding: 17px 15px 22px;

    background: var(--msd-oew-chat);

    scrollbar-width: thin;
    scrollbar-color: #c5ccd4 transparent;
}

#msd-oew .msd-oew-chat::-webkit-scrollbar {
    width: 6px;
}

#msd-oew .msd-oew-chat::-webkit-scrollbar-track {
    background: transparent;
}

#msd-oew .msd-oew-chat::-webkit-scrollbar-thumb {
    background: #cbd1d8;
    border-radius: 20px;
}


/* =========================================================
   TIME
========================================================= */

#msd-oew .msd-oew-time {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    margin: 0 auto 16px;

    color: #9aa2ab;

    font-size: 9px;
    font-weight: 700;
    letter-spacing: .9px;
    text-transform: uppercase;
}

#msd-oew .msd-oew-time > span:first-child,
#msd-oew .msd-oew-time > span:last-child {
    width: 22px;
    height: 1px;
    background: #dfe3e7;
}


/* =========================================================
   CHAT MESSAGES
========================================================= */

#msd-oew .msd-oew-message-bubble {
    width: 86%;
    max-width: 310px;

    margin: 0 0 10px;

    padding: 14px 16px;

    border: 1px solid #e8ebee;
    border-radius: 12px;

    background: #fff;

    color: #3f4853;

    box-shadow: 0 4px 14px rgba(7,31,64,.035);
}

#msd-oew .msd-oew-agent-label {
    margin-bottom: 6px;

    color: var(--msd-oew-primary);

    font-size: 10px;
    line-height: 1;
    font-weight: 700;
    letter-spacing: .2px;
}

#msd-oew .msd-oew-message-bubble p {
    margin: 0;

    color: #414a55;

    font-size: 13px;
    line-height: 1.58;
}


/* =========================================================
   FORM CARD
========================================================= */

#msd-oew .msd-oew-form-card {
    width: 100%;

    margin-top: 13px;
    padding: 20px;

    border: 1px solid #e1e6eb;
    border-radius: 13px;

    background: #fff;

    box-shadow: 0 8px 25px rgba(7,31,64,.045);
}

#msd-oew .msd-oew-form-heading {
    margin-bottom: 15px;
}

#msd-oew .msd-oew-form-heading strong {
    display: block;

    margin-bottom: 4px;

    color: var(--msd-oew-primary);

    font-size: 14px;
    line-height: 1.35;
}

#msd-oew .msd-oew-form-heading span {
    display: block;

    color: var(--msd-oew-muted);

    font-size: 10.5px;
    line-height: 1.5;
}

#msd-oew .msd-oew-form[hidden],
#msd-oew .msd-oew-success[hidden] {
    display: none !important;
}


/* =========================================================
   FIELDS
========================================================= */

#msd-oew .msd-oew-field {
    margin-bottom: 12px;
}

#msd-oew .msd-oew-field label {
    display: block;

    margin: 0 0 6px;

    color: #35404c;

    font-size: 10.5px;
    line-height: 1.3;
    font-weight: 700;
}

#msd-oew .msd-oew-field label span {
    color: var(--msd-oew-accent);
}

#msd-oew .msd-oew-field input,
#msd-oew .msd-oew-field textarea {
    width: 100%;

    display: block;

    border: 1px solid var(--msd-oew-border);
    border-radius: 8px;

    background: #fff;
    color: var(--msd-oew-text);

    font-family: inherit;
    font-size: 12px;

    outline: none;
    box-shadow: none;

    transition: border-color .2s ease, box-shadow .2s ease;
}

#msd-oew .msd-oew-field input {
    height: 42px;
    padding: 0 11px;
}

#msd-oew .msd-oew-field textarea {
    min-height: 82px;
    padding: 10px 11px;

    resize: vertical;
    line-height: 1.5;
}

#msd-oew .msd-oew-field input:focus,
#msd-oew .msd-oew-field textarea:focus {
    border-color: var(--msd-oew-primary);
    box-shadow: 0 0 0 3px rgba(11,45,92,.07);
}

#msd-oew .msd-oew-field input::placeholder,
#msd-oew .msd-oew-field textarea::placeholder {
    color: #a0a8b1;
}


/* =========================================================
   ERROR
========================================================= */

#msd-oew .msd-oew-error {
    margin-top: 5px;
    padding: 9px 10px;

    border-radius: 7px;

    background: #fff1f3;
    color: #b42332;

    font-size: 10.5px;
    line-height: 1.45;
}

#msd-oew .msd-oew-error[hidden] {
    display: none !important;
}


/* =========================================================
   BUTTON
========================================================= */

#msd-oew .msd-oew-primary-btn {
    width: 100%;
    min-height: 45px;

    margin-top: 14px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    border: 0;
    border-radius: 8px;

    background: var(--msd-oew-primary);
    color: #fff;

    font-family: inherit;
    font-size: 12px;
    font-weight: 700;

    cursor: pointer;

    transition: background .2s ease, transform .2s ease;
}

#msd-oew .msd-oew-primary-btn:hover {
    background: var(--msd-oew-primary-dark);
    transform: translateY(-1px);
}

#msd-oew .msd-oew-primary-btn:disabled {
    opacity: .72;
    cursor: wait;
    transform: none;
}

#msd-oew .msd-oew-submit-arrow {
    font-size: 15px;
}

#msd-oew .msd-oew-spinner {
    display: none;

    width: 14px;
    height: 14px;

    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;

    animation: msdOewSpin .7s linear infinite;
}

#msd-oew .msd-oew-submit.is-loading .msd-oew-spinner {
    display: block;
}

@keyframes msdOewSpin {
    to { transform: rotate(360deg); }
}


/* =========================================================
   SUCCESS
========================================================= */

#msd-oew .msd-oew-success {
    padding: 25px 8px 10px;
    text-align: center;
}

#msd-oew .msd-oew-success-icon {
    width: 52px;
    height: 52px;

    margin: 0 auto 13px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: rgba(215,25,50,.09);
    color: var(--msd-oew-accent);

    font-size: 23px;
    font-weight: 700;
}

#msd-oew .msd-oew-success h4 {
    margin: 0 0 7px;

    color: var(--msd-oew-primary);

    font-size: 18px;
}

#msd-oew .msd-oew-success p {
    margin: 0 auto;

    color: var(--msd-oew-muted);

    font-size: 12px;
    line-height: 1.6;
}

#msd-oew .msd-oew-secondary-btn {
    margin-top: 17px;

    min-height: 38px;
    padding: 0 21px;

    border: 1px solid var(--msd-oew-border);
    border-radius: 8px;

    background: #fff;
    color: var(--msd-oew-primary);

    font-family: inherit;
    font-size: 11px;
    font-weight: 700;

    cursor: pointer;
}


/* =========================================================
   FOOTER
========================================================= */

#msd-oew .msd-oew-footer {
    flex: 0 0 35px;

    min-height: 35px;
    padding: 0 16px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;

    border-top: 1px solid #edf0f3;

    background: #fbfcfd;

    color: #8d96a0;

    font-size: 9px;
    font-weight: 600;
}

#msd-oew .msd-oew-footer span:first-child {
    color: var(--msd-oew-primary);
    font-weight: 800;
    letter-spacing: 1px;
}


/* =========================================================
   MOBILE
   Panel uses viewport height and internal chat scroll.
========================================================= */

@media (max-width: 600px) {

    #msd-oew {
        right: 12px;
        bottom: 12px;

        width: calc(100vw - 24px);
        max-width: 380px;
    }

    #msd-oew.msd-oew-left {
        left: 12px;
        right: auto;
    }

    #msd-oew .msd-oew-panel {
        right: 0;
        bottom: 64px;

        /*
         * Intentionally NOT fullscreen.
         * Approx. 70% viewport height and a compact floating width.
         * The chat area scrolls internally when the form is longer.
         */
        width: min(340px, 88vw);
        max-width: 88vw;

        height: 70vh;
        min-height: 430px;
        max-height: 620px;

        border-radius: 14px;
    }

    #msd-oew.msd-oew-left .msd-oew-panel {
        left: 0;
        right: auto;
    }

    #msd-oew .msd-oew-head {
        min-height: 94px;
        padding: 18px 17px 16px;
    }

    #msd-oew .msd-oew-chat {
        padding: 15px 12px 20px;
    }

    #msd-oew .msd-oew-message-bubble {
        width: 91%;
    }

    #msd-oew .msd-oew-form-card {
        padding: 18px;
    }
}


/* =========================================================
   SMALL MOBILE
========================================================= */

@media (max-width: 380px) {

    #msd-oew {
        right: 8px;
        bottom: 8px;

        width: calc(100vw - 16px);
    }

    #msd-oew .msd-oew-panel {
        right: 0;
        bottom: 62px;

        width: min(330px, 88vw);
        max-width: 88vw;

        height: 70vh;
        min-height: 400px;
        max-height: 560px;

        border-radius: 12px;
    }

    #msd-oew .msd-oew-head h3 {
        font-size: 19px;
    }

    #msd-oew .msd-oew-message-bubble {
        width: 94%;
    }

    #msd-oew .msd-oew-form-card {
        padding: 16px;
    }
}
