/* ShipControl marketing chat widget
   Uses the shared tokens from variables.css (--deep-navy, --primary-blue, ...). */

.sc-chat {
    position: fixed;
    inset-block-end: 24px;
    inset-inline-end: 24px;
    z-index: 9999;
    font-family: inherit;
}

/* Launcher ------------------------------------------------------------------ */

.sc-chat__launcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary-blue), var(--cyan));
    box-shadow: 0 12px 28px rgba(36, 107, 253, 0.35);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.sc-chat__launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(36, 107, 253, 0.45);
}

.sc-chat__launcher:focus-visible {
    outline: 3px solid rgba(41, 182, 246, 0.55);
    outline-offset: 3px;
}

.sc-chat__launcher svg {
    width: 26px;
    height: 26px;
}

.sc-chat__launcher-close {
    display: none;
}

.sc-chat.is-open .sc-chat__launcher-icon {
    display: none;
}

.sc-chat.is-open .sc-chat__launcher-close {
    display: inline-flex;
}

/* Panel --------------------------------------------------------------------- */

.sc-chat__panel {
    position: absolute;
    inset-block-end: 68px;
    inset-inline-end: 0;
    display: flex;
    flex-direction: column;
    width: min(440px, calc(100vw - 32px));
    height: min(650px, calc(100dvh - 120px));
    padding: 0;
    margin: 0;
    overflow: hidden;
    border-radius: 20px;
    background: #0b1426; /* Dark Navy */
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(0.98);
    transform-origin: bottom;
    transition: opacity var(--transition-base), transform var(--transition-base), visibility var(--transition-base);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.sc-chat.is-open .sc-chat__panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header -------------------------------------------------------------------- */

.sc-chat__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--white);
    background: linear-gradient(135deg, #0f1c35, #162a4d);
    border-block-end: 1px solid rgba(255, 255, 255, 0.06);
}

.sc-chat__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    padding: 4px;
    border-radius: 12px;
    color: var(--white);
    background: var(--white);
}

.sc-chat__avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sc-chat__identity {
    flex: 1 1 auto;
    min-width: 0;
}

.sc-chat__title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.sc-chat__subtitle {
    margin: 2px 0 0;
    font-size: 12px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.72);
}

.sc-chat__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.12);
    transition: background var(--transition-fast);
}

.sc-chat__close:hover {
    background: rgba(255, 255, 255, 0.22);
}

.sc-chat__close svg {
    width: 16px;
    height: 16px;
}

/* Messages ------------------------------------------------------------------ */

.sc-chat__messages {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: #0d1b32; /* Slightly lighter Navy */
}

/* Custom Scrollbar for messages */
.sc-chat__messages::-webkit-scrollbar {
    width: 6px;
}
.sc-chat__messages::-webkit-scrollbar-track {
    background: transparent;
}
.sc-chat__messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
.sc-chat__messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sc-chat__msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    unicode-bidi: plaintext;
}

.sc-chat__msg--bot {
    align-self: flex-start;
    color: #f0f2f5;
    background: #1a2b4b;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border-end-start-radius: 6px;
}

.sc-chat__msg--user {
    align-self: flex-end;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary-blue), var(--bright-blue));
    border-end-end-radius: 6px;
    box-shadow: 0 4px 12px rgba(36, 107, 253, 0.2);
}

.sc-chat__msg--typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 14px;
}

.sc-chat__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #718096;
    animation: sc-chat-blink 1.2s infinite ease-in-out;
}

.sc-chat__dot:nth-child(2) { animation-delay: 0.15s; }
.sc-chat__dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes sc-chat-blink {
    0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-2px); }
}

/* Error --------------------------------------------------------------------- */

.sc-chat__error {
    margin: 0;
    padding: 10px 16px;
    font-size: 13px;
    line-height: 1.5;
    color: #ff8a8a;
    background: rgba(164, 38, 44, 0.2);
    border-block-start: 1px solid rgba(164, 38, 44, 0.3);
}

/* Composer ------------------------------------------------------------------ */

.sc-chat__form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 12px;
    padding-block-end: max(8px, env(safe-area-inset-bottom));
    background: #0b1426;
    border-block-start: 1px solid rgba(255, 255, 255, 0.08);
}

.sc-chat__input {
    flex: 1 1 auto;
    max-height: 104px;
    min-height: 40px;
    padding: 10px 13px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: #f0f2f5;
    background: #1a2b4b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    resize: none;
    overflow-y: auto;
}

.sc-chat__input::placeholder {
    color: #718096;
}

.sc-chat__input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(36, 107, 253, 0.15);
}

.sc-chat__send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 13px;
    cursor: pointer;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary-blue), var(--cyan));
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.sc-chat__send:hover {
    transform: translateY(-1px);
}

.sc-chat__send:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.sc-chat__send svg {
    width: 19px;
    height: 19px;
}

/* RTL: mirror the send arrow so it points away from the text */
[dir="rtl"] .sc-chat__send svg {
    transform: scaleX(-1);
}

/* Proactive teaser ---------------------------------------------------------- */

.sc-chat__teaser {
    position: absolute;
    inset-block-end: 74px;
    inset-inline-end: 0;
    max-width: min(250px, calc(100vw - 48px));
    margin: 0;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.6;
    text-align: start;
    color: #f0f2f5;
    background: #1a2b4b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    border-end-end-radius: 6px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px);
    animation: sc-chat-teaser-in 320ms ease forwards;
}

.sc-chat__teaser:hover,
.sc-chat__teaser:focus-visible {
    border-color: var(--primary-blue);
    background: #233a61;
}

.sc-chat__teaser[hidden],
.sc-chat.is-open .sc-chat__teaser {
    display: none;
}

@keyframes sc-chat-teaser-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sc-chat.is-teasing .sc-chat__launcher {
    animation: sc-chat-pulse 1.8s ease-in-out 2;
}

@keyframes sc-chat-pulse {
    0%,
    100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Mobile -------------------------------------------------------------------- */

@media (max-width: 480px) {
    .sc-chat {
        inset-block-end: 16px;
        inset-inline-end: 16px;
    }

    .sc-chat__launcher {
        width: 54px;
        height: 54px;
    }

    .sc-chat__teaser {
        inset-block-end: 66px;
    }

    .sc-chat__panel {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
    }
}
