/* Explain: Styles for the live chat widget, including responsiveness and status indicators. */
.chat-launcher {
    position: fixed;
    right: 1.1rem;
    bottom: 5.85rem;
    z-index: 70;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(150deg, var(--accent-color), #C2185B);
    color: #FFFFFF;
    font-size: 1.3rem;
    box-shadow: 0 18px 44px rgba(255, 45, 135, 0.42);
    transition: transform 300ms ease, box-shadow 300ms ease;
}

.chat-launcher:hover {
    transform: translateY(-3px);
    box-shadow: 0 22px 54px rgba(255, 45, 135, 0.55);
}

.chat-launcher:focus-visible {
    outline: 2px solid var(--gold-color);
    outline-offset: 3px;
}

.chat-launcher-dot {
    position: absolute;
    top: 0.3rem;
    right: 0.3rem;
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 999px;
    background: var(--gold-color);
    box-shadow: 0 0 0 2px var(--background-color), 0 0 0 3.5px rgba(232, 193, 90, 0.32);
    animation: chat-dot-pulse 2.4s ease-in-out infinite;
}

@keyframes chat-dot-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 2px var(--background-color), 0 0 0 3.5px rgba(232, 193, 90, 0.32);
    }

    50% {
        box-shadow: 0 0 0 2px var(--background-color), 0 0 0 6px rgba(232, 193, 90, 0.12);
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-launcher-dot {
        animation: none;
    }
}

.chat-launcher-dot[hidden] {
    display: none;
}

.chat-panel {
    position: fixed;
    right: 0.8rem;
    left: 0.8rem;
    bottom: 5.5rem;
    bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
    z-index: 71;
    display: none;
    flex-direction: column;
    width: auto;
    max-height: min(74vh, 33rem);
    max-height: min(74dvh, 33rem);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    border-radius: 1.6rem;
    background: var(--surface-color);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.68);
}

.chat-panel.is-open {
    display: flex;
}

.chat-head {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.7rem;
    border-bottom: 1px solid var(--glass-border);
    background: linear-gradient(150deg, rgba(255, 45, 135, 0.22), rgba(232, 193, 90, 0.14));
    padding: 0.8rem 0.9rem;
}

.chat-head-avatar {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    background: rgba(10, 10, 12, 0.5);
    color: var(--gold-color);
    font-size: 1rem;
}

.chat-head-text {
    flex: 1 1 auto;
    min-width: 0;
}

.chat-head-title {
    color: var(--text-color);
    font-family: var(--font-heading);
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.3;
}

.chat-head-status {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    max-width: 100%;
    margin-top: 0.3rem;
    border: 1px solid rgba(74, 222, 128, 0.34);
    border-radius: 999px;
    background: rgba(74, 222, 128, 0.12);
    padding: 0.16rem 0.55rem 0.16rem 0.45rem;
    color: #CDF3D9;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.5;
}

.chat-status-dot {
    flex: 0 0 auto;
    width: 0.42rem;
    height: 0.42rem;
    border-radius: 999px;
    background: #4ADE80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.16);
}

.chat-close {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    background: var(--glass-bg);
    color: var(--text-color);
    transition: background 300ms ease, color 300ms ease;
}

.chat-close:hover {
    background: var(--surface-elevated);
    color: var(--accent-color);
}

.chat-messages {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 0.65rem;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 0.9rem 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(232, 193, 90, 0.4) transparent;
}

.chat-msg {
    max-width: 88%;
    border-radius: 1rem;
    padding: 0.68rem 0.88rem;
    font-size: 0.875rem;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.chat-msg.is-team {
    align-self: flex-start;
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 0.3rem;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-color);
}

.chat-msg.is-visitor {
    align-self: flex-end;
    border-bottom-right-radius: 0.3rem;
    background: var(--accent-color);
    color: #FFFFFF;
}

.chat-msg-time {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.65rem;
    opacity: 0.75;
}

.chat-form {
    display: grid;
    flex: 0 0 auto;
    gap: 0.5rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(10, 10, 12, 0.32);
    padding: 0.7rem 0.9rem 0.85rem;
}

.chat-identity {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.chat-identity input,
.chat-compose textarea {
    width: 100%;
    border: 1px solid var(--glass-border);
    border-radius: 0.8rem;
    background: var(--field-bg);
    padding: 0.55rem 0.7rem;
    color: var(--text-color);
    font-family: var(--font-body);
    font-size: 0.8rem;
    outline: none;
}

.chat-identity input:focus,
.chat-compose textarea:focus {
    border-color: var(--accent-color);
}

.chat-identity input::placeholder,
.chat-compose textarea::placeholder {
    color: var(--text-muted);
}

.chat-compose {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.chat-compose textarea {
    max-height: 6rem;
    line-height: 1.5;
    resize: none;
}

.chat-send {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    border: 0;
    border-radius: 999px;
    background: var(--accent-color);
    color: #FFFFFF;
    transition: background 300ms ease, transform 300ms ease;
}

.chat-send:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.chat-note {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    margin: 0;
    border: 1px solid var(--glass-border);
    border-radius: 0.7rem;
    background: rgba(255, 255, 255, 0.04);
    padding: 0.45rem 0.6rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    line-height: 1.5;
}

.chat-note i {
    flex: 0 0 auto;
    margin-top: 0.16rem;
    color: var(--gold-color);
    font-size: 0.65rem;
}

.chat-note.is-error {
    border-color: rgba(255, 123, 156, 0.45);
    background: rgba(255, 123, 156, 0.08);
    color: #FF9CB5;
}

.chat-note.is-error i {
    color: #FF9CB5;
}

.chat-staff .chat-widget {
    display: none;
}

.inbox-auth {
    border-radius: 2rem;
    padding: clamp(1.5rem, 4vw, 2.4rem);
}

.inbox-form {
    display: grid;
    gap: 0.6rem;
    margin-top: 1.2rem;
}

.inbox-form[hidden] {
    display: none;
}

.inbox-input {
    width: 100%;
    border: 1px solid var(--glass-border);
    border-radius: 0.9rem;
    background: var(--field-bg);
    padding: 0.8rem 0.95rem;
    color: var(--text-color);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
}

.inbox-input:focus {
    border-color: var(--accent-color);
}

.inbox-status {
    min-height: 1.2rem;
    margin-top: 0.9rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
}

.inbox-status.is-error {
    color: #FF7B9C;
}

.inbox-app[hidden] {
    display: none;
}

.inbox-shell {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.inbox-side {
    overflow: hidden;
    border: 1px solid var(--glass-border);
    border-radius: 1.6rem;
    background: rgba(27, 23, 32, 0.6);
}

.inbox-side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 1.1rem;
}

.inbox-side-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
}

.inbox-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.3rem;
    height: 2.3rem;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    background: var(--glass-bg);
    color: var(--text-color);
    transition: background 300ms ease, color 300ms ease;
}

.inbox-icon-btn:hover {
    background: var(--surface-elevated);
    color: var(--accent-color);
}

.inbox-threads {
    display: grid;
    gap: 0.35rem;
    max-height: 26rem;
    overflow-y: auto;
    padding: 0.5rem;
}

.inbox-thread {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 1rem;
    background: transparent;
    padding: 0.7rem 0.8rem;
    color: var(--text-color);
    text-align: left;
    transition: background 300ms ease, border-color 300ms ease;
}

.inbox-thread:hover {
    background: rgba(255, 255, 255, 0.05);
}

.inbox-thread.is-active {
    border-color: var(--glass-border);
    background: var(--pink-soft);
}

.inbox-thread-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
}

.inbox-thread-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.inbox-thread-time {
    color: var(--text-muted);
    font-size: 0.68rem;
}

.inbox-thread-preview {
    display: block;
    margin-top: 0.25rem;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inbox-threads-empty {
    padding: 1.2rem 0.8rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.65;
    text-align: center;
}

.inbox-main {
    display: flex;
    flex-direction: column;
    min-height: 30rem;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    border-radius: 1.6rem;
    background: rgba(27, 23, 32, 0.6);
}

.inbox-main-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--glass-border);
    padding: 0.9rem 1.1rem;
}

.inbox-thread-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
}

.inbox-thread-meta {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.inbox-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 16rem;
    max-height: 28rem;
    overflow-y: auto;
    padding: 1rem;
}

.inbox-reply {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    border-top: 1px solid var(--glass-border);
    padding: 0.8rem 1rem;
}

.inbox-reply textarea {
    flex: 1;
    border: 1px solid var(--glass-border);
    border-radius: 0.9rem;
    background: var(--field-bg);
    padding: 0.6rem 0.8rem;
    color: var(--text-color);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    resize: none;
}

.inbox-reply textarea:focus {
    border-color: var(--accent-color);
}

.inbox-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.7rem;
    height: 2.7rem;
    border: 0;
    border-radius: 999px;
    background: var(--accent-color);
    color: #FFFFFF;
    transition: background 300ms ease;
}

.inbox-send:hover {
    background: var(--accent-hover);
}

@media (min-width: 480px) {
    .chat-panel {
        left: auto;
        width: min(calc(100vw - 2.2rem), 24rem);
    }
}

@media (min-width: 768px) {
    .chat-launcher,
    .chat-panel {
        right: 1.6rem;
        bottom: 1.6rem;
    }

    .chat-panel {
        left: auto;
    }
}

@media (max-width: 359px) {
    .chat-identity {
        grid-template-columns: 1fr;
    }
}

@media (max-height: 640px) {
    .chat-panel {
        max-height: calc(100dvh - 4.5rem);
    }
}

@media (min-width: 900px) {
    .inbox-shell {
        grid-template-columns: 20rem 1fr;
    }
}