/*
 * SOPHIA-X homepage chat.
 *
 * This component deliberately owns its complete visual layer so it does not
 * depend on Magento_Ui modal, Luma LESS, jQuery UI, or the legacy theme modal
 * structure.
 */
.sophia-chat-dialog {
    --sophia-chat-bg: #000;
    --sophia-chat-surface: #1f1f1f;
    --sophia-chat-input: #1f1f1f;
    --sophia-chat-border: rgb(255 255 255 / 14%);
    --sophia-chat-text: #f5f5f5;
    --sophia-chat-strong: #fff;
    --sophia-chat-muted: #b7b7b7;
    width: min(78.125rem, calc(100vw - 1.75rem));
    max-width: 78.125rem;
    height: min(47.5rem, calc(100dvh - 1.625rem));
    max-height: calc(100dvh - 1.625rem);
    position: fixed;
    inset: auto;
    top: 50%;
    left: 50vw;
    margin: 0;
    translate: -50% -50%;
    padding: 0;
    overflow: hidden;
    color: var(--sophia-chat-text);
    background: var(--sophia-chat-bg);
    border: 0;
    border-radius: 2.5rem;
    box-shadow: 0 5px 10px rgb(0 0 0 / 35%);
}

body.light-mode .sophia-chat-dialog {
    --sophia-chat-bg: #fff;
    --sophia-chat-surface: #f2f2f2;
    --sophia-chat-input: #f2f2f2;
    --sophia-chat-border: #d7d7d7;
    --sophia-chat-text: #111;
    --sophia-chat-strong: #000;
    --sophia-chat-muted: #111;
}

.sophia-chat-dialog:not([open]) {
    display: none;
}

.sophia-chat-dialog[open] {
    animation: sophia-chat-enter 180ms ease-out;
}

.sophia-chat-dialog::backdrop {
    background: rgb(0 0 0 / 58%);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.sophia-chat-dialog .sophia-chat-shell {
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden !important;
    background: var(--sophia-chat-bg);
}

.sophia-chat-dialog .sophia-chat-header {
    grid-row: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 2.125rem 1.875rem 0;
    border-bottom: 0;
}

.sophia-chat-dialog .sophia-chat-title {
    max-width: 64rem;
    margin: 0;
    color: var(--sophia-chat-strong);
    font-size: 1.5rem;
    font-weight: 500;
    line-height: 1.25;
}

.sophia-chat-dialog .sophia-product-title {
    display: inline;
}

.sophia-chat-dialog .sophia-product-title-icon {
    display: inline-block;
    width: 1.625rem;
    height: auto;
    margin-right: .25rem;
    vertical-align: -.1rem;
    filter: grayscale(1) invert(1);
    opacity: .58;
}

body.light-mode .sophia-chat-dialog .sophia-product-title-icon {
    filter: grayscale(1);
}

.sophia-chat-dialog .sophia-product-title-name,
.sophia-chat-dialog .sophia-product-title-separator {
    color: var(--toneart-orange, #fb8500);
}

.sophia-chat-dialog .sophia-chat-close {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    color: var(--toneart-orange, #fb8500);
    background: transparent;
    border: 0;
    border-radius: 9999px;
    cursor: pointer;
}

.sophia-chat-dialog .sophia-chat-close:hover,
.sophia-chat-dialog .sophia-chat-close:focus-visible {
    color: var(--toneart-orange-hover, #ff9f2e);
    background: transparent;
    outline: 2px solid var(--toneart-orange, #fb8500);
    outline-offset: 2px;
}

.sophia-chat-dialog .sophia-chat-close svg {
    width: 1rem;
    height: 1rem;
    stroke: currentColor;
    stroke-width: 2;
}

.sophia-chat-dialog #chatgpt-messages2 {
    grid-row: 2;
    grid-column: 1;
    min-height: 0;
    max-height: none !important;
    margin: 0 !important;
    padding: 1.25rem 1.5rem !important;
    overflow: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

.sophia-chat-dialog #chatgpt-messages2::-webkit-scrollbar {
    width: 5px;
}

.sophia-chat-dialog #chatgpt-messages2::-webkit-scrollbar-thumb {
    background: var(--toneart-orange, #fb8500);
    border-radius: 9999px;
}

.sophia-chat-dialog .sophia-chat-message {
    margin: 0 0 1rem;
}

.sophia-chat-dialog .sophia-chat-message-user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.sophia-chat-dialog .chatgpt-user-avtar,
.sophia-chat-dialog .shopia-avtar {
    display: inline-flex !important;
    align-items: center;
    gap: .35rem !important;
    width: fit-content;
    max-width: 100%;
    margin: 0 0 .35rem !important;
    padding: .35rem .65rem !important;
    color: var(--toneart-orange, #fb8500) !important;
    font-size: .875rem;
    font-weight: 600;
    border: 1px solid currentColor !important;
    border-radius: 9999px 9999px .625rem 9999px !important;
}

.sophia-chat-dialog .chatgpt-user-image,
.sophia-chat-dialog .chatgpt-user-image svg {
    display: block;
    width: 1.25rem !important;
    height: 1.25rem !important;
}

.sophia-chat-dialog .sophia-profile-image {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
}

.sophia-chat-dialog .chatgpt-user-input,
.sophia-chat-dialog .chatgpt-response {
    max-width: min(50rem, 92%);
    margin: 0 !important;
    padding: .75rem 1rem !important;
    overflow-wrap: anywhere;
    line-height: 1.55;
    border-radius: 1rem;
}

.sophia-chat-dialog .chatgpt-user-input {
    color: #fff;
    background: var(--toneart-orange, #fb8500);
    border-bottom-right-radius: .25rem;
}

.sophia-chat-dialog .chatgpt-response {
    color: var(--sophia-chat-text);
    background: var(--sophia-chat-surface);
    border-bottom-left-radius: .25rem;
}

.sophia-chat-dialog .sophia-chat-message-error .chatgpt-response {
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.sophia-chat-dialog .chatgpt-response > :first-child {
    margin-top: 0;
}

.sophia-chat-dialog .chatgpt-response > :last-child {
    margin-bottom: 0;
}

.sophia-chat-dialog .chatgpt-response :is(h1, h2, h3) {
    margin: 1em 0 .45em;
    color: var(--sophia-chat-strong);
    font-weight: 600;
    line-height: 1.3;
}

.sophia-chat-dialog .chatgpt-response h1 {
    font-size: 1.5rem !important;
}

.sophia-chat-dialog .chatgpt-response h2 {
    font-size: 1.25rem !important;
}

.sophia-chat-dialog .chatgpt-response h3 {
    font-size: 1.1rem !important;
}

.sophia-chat-dialog .chatgpt-response :is(ul, ol) {
    margin: .65rem 0;
    padding-inline-start: 1.4rem;
}

.sophia-chat-dialog .chatgpt-response ul {
    list-style: disc;
}

.sophia-chat-dialog .chatgpt-response ol {
    list-style: decimal;
}

.sophia-chat-dialog .chatgpt-response a {
    color: var(--toneart-orange, #d96300);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.sophia-chat-dialog .chatgpt-response code {
    padding: .1rem .3rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .9em;
    background: rgb(127 127 127 / 15%);
    border-radius: .25rem;
}

.sophia-chat-dialog .chatgpt-response .sophia-product-image-preview {
    display: block;
    width: min(25rem, 100%);
    height: auto;
    max-height: 25rem;
    margin: .75rem 0;
    object-fit: contain;
    border-radius: 1rem;
}

.sophia-chat-dialog .chatpopup-bottom-content {
    grid-row: 2;
    grid-column: 1;
    align-self: center;
    justify-self: center;
    margin: auto !important;
    padding: 0;
    text-align: center;
}

.sophia-chat-dialog .sophia-big-image {
    width: 9.375rem;
    height: 9.375rem;
    height: auto;
    margin: 0 auto;
    border-radius: 9999px !important;
}

.sophia-chat-dialog .sophiax-name {
    display: block !important;
    margin: 1.1875rem 0 0;
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    color: var(--toneart-orange, #fb8500) !important;
    background: none !important;
    -webkit-background-clip: initial;
    background-clip: border-box;
    -webkit-text-fill-color: var(--toneart-orange, #fb8500) !important;
}

.sophia-chat-dialog .sophia-version {
    margin: 0;
    color: var(--sophia-chat-muted);
    font-size: .7rem;
    line-height: 1.2;
    text-align: center;
}

.sophia-chat-dialog .chatgpt-input-container {
    grid-row: 3;
    position: relative !important;
    inset: auto !important;
    width: auto !important;
    padding: 0 1.875rem 1.9375rem !important;
    background: var(--sophia-chat-bg);
    border-top: 0;
}

.sophia-chat-dialog .typing-indicator-container {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100% !important;
    height: auto !important;
    min-height: 1.75rem;
    margin: 0 0 .35rem !important;
    padding: 0 !important;
    background: transparent;
}

.sophia-chat-dialog .typing-indicator {
    display: flex;
    align-items: center;
    margin-right: .45rem;
}

.sophia-chat-dialog .typing-indicator .dot {
    width: .5rem;
    height: .5rem;
    margin: 0 .12rem !important;
    background: var(--toneart-orange, #fb8500);
    border-radius: 9999px;
    animation: sophia-chat-typing 1.4s infinite ease-in-out;
}

.sophia-chat-dialog .typing-indicator .dot:nth-child(1) {
    animation-delay: -.32s;
}

.sophia-chat-dialog .typing-indicator .dot:nth-child(2) {
    animation-delay: -.16s;
}

.sophia-chat-dialog .typing-text {
    margin: 0;
    color: var(--sophia-chat-muted);
    font-size: .8rem;
    font-style: italic;
}

.sophia-chat-dialog .textarea-animated-container {
    position: relative;
    width: 100%;
    padding: 2px !important;
    overflow: hidden;
    isolation: isolate;
    border-radius: .9375rem;
}

.sophia-chat-dialog .textarea-animated-container::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    width: auto;
    height: auto;
    background: conic-gradient(from 0deg, transparent 65%, #fff, #ff6b35, transparent 85%);
    border-radius: inherit;
    transform: none;
    animation: sophia-chat-border-spin 7s linear infinite;
}

.sophia-chat-dialog .textarea-animated-container.is-disabled::after {
    content: none !important;
}

.sophia-chat-dialog #chatgpt-input2 {
    display: block;
    width: 100%;
    min-height: 6.25rem !important;
    max-height: 14rem !important;
    height: 6.25rem !important;
    margin: 0;
    padding: .75rem 4rem .75rem .625rem !important;
    overflow: auto !important;
    color: var(--sophia-chat-text) !important;
    font: inherit;
    font-size: 1rem !important;
    line-height: 1.45;
    resize: vertical !important;
    background: var(--sophia-chat-input) !important;
    border: 1px solid var(--sophia-chat-border) !important;
    border-radius: calc(.9375rem - 2px) !important;
    box-shadow: none !important;
}

.sophia-chat-dialog #chatgpt-input2::placeholder {
    color: #5f5f5f;
    opacity: 1;
}

body.light-mode .sophia-chat-dialog #chatgpt-input2::placeholder {
    color: #666;
}

.sophia-chat-dialog #chatgpt-input2:focus {
    border-color: var(--toneart-orange, #fb8500) !important;
    outline: 2px solid color-mix(in srgb, var(--toneart-orange, #fb8500) 35%, transparent);
    outline-offset: 1px;
}

.sophia-chat-dialog #chatgpt-input2:disabled {
    cursor: wait;
    opacity: .65;
}

.sophia-chat-dialog .sophia-sendmessage {
    position: absolute !important;
    right: 1.125rem !important;
    bottom: 1.25rem !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    margin: 0 !important;
    padding: 0 !important;
    color: #111;
    background: var(--toneart-orange, #fb8500) !important;
    border: 0 !important;
    border-radius: 9999px !important;
    cursor: pointer;
}

.sophia-chat-dialog #chatgpt-send2 {
    top: auto !important;
    right: 1.25rem !important;
    bottom: 1.25rem !important;
    color: #111 !important;
    background: #fb8500 !important;
    border: 0 !important;
}

.sophia-chat-dialog .sophia-sendmessage:hover,
.sophia-chat-dialog .sophia-sendmessage:focus-visible {
    color: #111;
    background: var(--toneart-orange-hover, #ff9f2e) !important;
    outline: 2px solid var(--toneart-orange, #fb8500);
    outline-offset: 2px;
}

.sophia-chat-dialog #chatgpt-send2:hover,
.sophia-chat-dialog #chatgpt-send2:focus-visible {
    color: #111 !important;
    background: #ff9f2e !important;
}

.sophia-chat-dialog .sophia-sendmessage:disabled {
    cursor: not-allowed;
    opacity: 1;
}

.sophia-chat-dialog .sophia-sendmessage svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
}

.sophia-chat-dialog .chatgpt-disclaimer-notice {
    margin: 1.125rem 0 0;
    padding: 0 !important;
    color: var(--sophia-chat-muted) !important;
    font-size: .75rem;
    line-height: 1.35;
    text-align: center;
}

@media (min-width: 48.0625rem) {
    .sophia-chat-dialog .chatpopup-bottom-content {
        align-self: start;
        margin-top: 2.25rem !important;
    }
}

html.open-modal {
    overflow: hidden;
}

@keyframes sophia-chat-enter {
    from {
        opacity: 0;
        transform: translateY(.75rem) scale(.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes sophia-chat-typing {
    0%, 80%, 100% {
        opacity: .4;
        transform: scale(.7);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes sophia-chat-border-spin {
    to {
        transform: rotate(1turn);
    }
}

@media (max-width: 48rem) {
    .sophia-chat-dialog {
        inset: 0 !important;
        width: 100vw;
        max-width: none;
        height: 100dvh;
        max-height: none;
        margin: 0 !important;
        translate: 0 0;
        border: 0;
        border-radius: 0;
    }

    .sophia-chat-dialog[open] {
        animation-name: sophia-chat-drawer-enter;
    }

    .sophia-chat-dialog .sophia-chat-header {
        padding: 1rem;
    }

    .sophia-chat-dialog .sophia-chat-title {
        font-size: 1rem;
    }

    .sophia-chat-dialog #chatgpt-messages2 {
        max-height: none !important;
        margin: 0 !important;
        padding: 1rem !important;
    }

    .sophia-chat-dialog .chatgpt-input-container {
        position: relative !important;
        inset: auto !important;
        width: auto !important;
        padding: .65rem .75rem max(.75rem, env(safe-area-inset-bottom)) !important;
    }

    .sophia-chat-dialog .chatgpt-user-input,
    .sophia-chat-dialog .chatgpt-response {
        max-width: 95%;
        font-size: .875rem !important;
    }

    .sophia-chat-dialog .chatpopup-bottom-content {
        position: static;
        inset: auto;
        margin: auto !important;
        padding: .75rem;
    }

    .sophia-chat-dialog #chatgpt-input2 {
        min-height: 5.5rem !important;
        height: 5.5rem !important;
    }

    .sophia-chat-dialog #chatgpt-send2 {
        top: auto !important;
        right: 1rem !important;
        bottom: 1.5rem !important;
        background: #fb8500 !important;
    }
}

@keyframes sophia-chat-drawer-enter {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .sophia-chat-dialog[open],
    .sophia-chat-dialog .typing-indicator .dot,
    .sophia-chat-dialog .textarea-animated-container::after {
        animation: none;
    }

    .sophia-chat-dialog #chatgpt-messages2 {
        scroll-behavior: auto;
    }
}
