.support-chat-layout {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr) minmax(220px, 260px);
    align-items: stretch;
    gap: 1rem;
    min-height: 620px;
}

.support-refund-alerts:empty {
    display: none;
}

.support-refund-alerts {
    display: grid;
    gap: 0.75rem;
    margin: 0 0 1rem;
    padding: 0.9rem;
    border: 1px solid rgba(20, 184, 166, 0.22);
    border-radius: 8px;
    background: #f0fdfa;
}

.support-refund-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.support-refund-head strong,
.support-refund-head span {
    display: block;
}

.support-refund-head strong {
    color: #0f766e;
}

.support-refund-head span {
    margin-top: 0.15rem;
    color: #475569;
    font-size: 0.88rem;
}

.support-refund-list {
    display: grid;
    gap: 0.55rem;
}

.support-refund-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.8rem;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid rgba(15, 118, 110, 0.16);
    border-radius: 8px;
    background: #ffffff;
}

.support-refund-card.is-open {
    border-color: rgba(245, 158, 11, 0.36);
    background: #fffaf0;
}

.support-refund-card.is-focused {
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
}

.support-refund-main {
    min-width: 0;
}

.support-refund-main strong,
.support-refund-main small {
    display: block;
}

.support-refund-main strong {
    overflow: hidden;
    color: #0f172a;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.support-refund-main small {
    color: #64748b;
    font-size: 0.84rem;
}

.support-refund-status {
    display: inline-flex;
    margin-bottom: 0.3rem;
    padding: 0.18rem 0.45rem;
    border-radius: 999px;
    background: rgba(20, 184, 166, 0.14);
    color: #0f766e;
    font-size: 0.74rem;
    font-weight: 800;
}

.support-refund-card.is-open .support-refund-status {
    background: #fef3c7;
    color: #92400e;
}

.support-refund-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.45rem;
}

.support-chat-sidebar,
.support-chat-window {
    min-width: 0;
    border: 1px solid rgba(30, 41, 56, 0.12);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.support-chat-sidebar {
    display: grid;
    grid-template-rows: auto 1fr;
}

.support-chat-toolbar,
.support-chat-head,
.support-chat-reply {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid rgba(30, 41, 56, 0.1);
}

.support-chat-toolbar select {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid rgba(30, 41, 56, 0.18);
    border-radius: 8px;
    background: #fff;
    color: inherit;
    font: inherit;
}

.support-chat-list {
    overflow: auto;
}

.support-chat-empty,
.support-chat-loading {
    padding: 1rem;
    color: #64748b;
    text-align: center;
}

.support-chat-item {
    width: 100%;
    display: grid;
    gap: 0.35rem;
    padding: 0.9rem 1rem;
    border: 0;
    border-bottom: 1px solid rgba(30, 41, 56, 0.08);
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.support-chat-item:hover,
.support-chat-item.is-active {
    background: rgba(52, 152, 219, 0.08);
}

.support-chat-item-top,
.support-chat-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.support-chat-customer {
    min-width: 0;
    overflow: hidden;
    color: #1e2938;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.support-chat-preview {
    overflow: hidden;
    color: #64748b;
    font-size: 0.9rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.support-chat-badge {
    flex: 0 0 auto;
    padding: 0.22rem 0.5rem;
    border-radius: 999px;
    background: #edf2f7;
    color: #334155;
    font-size: 0.75rem;
    font-weight: 800;
}

.support-chat-badge.waiting_operator {
    background: #fff1d6;
    color: #9a5b00;
}

.support-chat-badge.operator {
    background: #dff7ea;
    color: #0f7a3f;
}

.support-chat-badge.closed {
    background: #f1f5f9;
    color: #64748b;
}

.support-chat-window {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.support-chat-head {
    align-items: flex-start;
    gap: 1rem;
    justify-content: space-between;
}

.support-chat-title {
    flex: 1 1 auto;
    min-width: 0;
}

.support-chat-title strong,
.support-chat-title span {
    display: block;
}

.support-chat-title strong {
    overflow: hidden;
    color: #1e2938;
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.support-chat-title span {
    margin-top: 0.15rem;
    color: #64748b;
    font-size: 0.85rem;
}

.support-chat-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.support-chat-actions [hidden] {
    display: none !important;
}

.support-chat-messages {
    display: grid;
    align-content: start;
    gap: 0.7rem;
    padding: 1rem;
    overflow: auto;
    background: #f8fafc;
}

.support-chat-context {
    margin: 0;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid rgba(30, 41, 56, 0.1);
    background: #f8fafc;
    color: #334155;
}

.support-context-title {
    display: block;
    margin-bottom: 0.7rem;
    color: #1e2938;
    font-size: 0.9rem;
    font-weight: 800;
}

.support-context-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 280px));
    gap: 0.65rem;
    max-height: min(330px, 42vh);
    overflow: auto;
    padding-right: 0.2rem;
    align-items: start;
    justify-content: start;
}

.support-context-card {
    min-width: 0;
    padding: 0.75rem;
    border: 1px solid rgba(30, 41, 56, 0.08);
    border-radius: 8px;
    background: #fff;
}

.support-context-card > strong {
    display: block;
    margin-bottom: 0.45rem;
    color: #0f172a;
    font-size: 0.82rem;
}

.support-context-rows {
    display: grid;
    gap: 0.5rem;
}

.support-context-row {
    display: grid;
    gap: 0.1rem;
}

.support-context-row.is-record-title {
    margin-top: 0.25rem;
    padding: 0.45rem 0.55rem;
    border-radius: 7px;
    background: rgba(14, 165, 233, 0.1);
}

.support-context-row.is-record-title.is-active-ticket {
    background: rgba(14, 165, 233, 0.13);
    border-left: 3px solid #0ea5e9;
}

.support-context-row.is-record-title.is-pending {
    background: rgba(245, 158, 11, 0.16);
    border-left: 3px solid #f59e0b;
}

.support-context-row.is-record-title.is-used {
    background: rgba(239, 68, 68, 0.13);
    border-left: 3px solid #ef4444;
}

.support-context-row.is-record-title.is-refund {
    background: rgba(20, 184, 166, 0.13);
    border-left: 3px solid #14b8a6;
}

.support-context-row.is-record-title + .support-context-row {
    margin-top: 0.15rem;
}

.support-context-row span {
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.support-context-row b,
.support-context-card p {
    color: #1e2938;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.support-context-row.is-record-title span {
    color: #0369a1;
}

.support-context-row.is-record-title b {
    color: #0f172a;
    font-size: 0.9rem;
}

.support-context-row.is-record-title.is-pending span {
    color: #92400e;
}

.support-context-row.is-record-title.is-used span {
    color: #991b1b;
}

.support-context-row.is-record-title.is-refund span {
    color: #0f766e;
}

.support-context-card p {
    margin: 0;
    font-weight: 600;
}

.support-chat-message {
    max-width: 78%;
    padding: 0.75rem 0.85rem;
    border-radius: 12px;
    background: #fff;
    color: #1e2938;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.support-chat-message.is-user {
    justify-self: start;
    border-bottom-left-radius: 4px;
}

.support-chat-message.is-operator,
.support-chat-message.is-ai {
    justify-self: end;
    border-bottom-right-radius: 4px;
    background: #1f7bb6;
    color: #fff;
}

.support-chat-message.is-pending {
    opacity: 0.72;
}

.support-chat-message.is-system {
    justify-self: center;
    max-width: 90%;
    background: #fff7ed;
    color: #9a3412;
    text-align: center;
    font-weight: 800;
}

.support-chat-typing {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    width: max-content;
    padding: 0.7rem 0.85rem;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    background: #fff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.support-chat-typing span {
    width: 0.42rem;
    height: 0.42rem;
    border-radius: 999px;
    background: #64748b;
    animation: supportChatTyping 1s infinite ease-in-out;
}

.support-chat-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.support-chat-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes supportChatTyping {
    0%,
    80%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.support-chat-message small {
    display: block;
    margin-top: 0.35rem;
    opacity: 0.72;
    font-size: 0.72rem;
}

.support-chat-message a {
    color: inherit;
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.support-chat-message code {
    padding: 0.08rem 0.28rem;
    border-radius: 5px;
    background: rgba(15, 23, 42, 0.08);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.9em;
}

.support-chat-message.is-operator code,
.support-chat-message.is-ai code {
    background: rgba(255, 255, 255, 0.18);
}

.support-chat-reply {
    align-items: flex-end;
    border-top: 1px solid rgba(30, 41, 56, 0.1);
    border-bottom: 0;
}

.support-reply-tools {
    display: grid;
    align-content: start;
    gap: 0.75rem;
    min-width: 0;
    padding: 1rem;
    border: 1px solid rgba(30, 41, 56, 0.12);
    border-radius: 10px;
    background: #fff;
    overflow: auto;
}

.support-quick-replies {
    display: grid;
    gap: 0.45rem;
    min-width: 0;
}

.support-quick-reply,
.support-ai-suggest {
    border: 1px solid rgba(30, 41, 56, 0.14);
    border-radius: 8px;
    background: #fff;
    color: #1e2938;
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1.3;
    overflow-wrap: anywhere;
    white-space: normal;
}

.support-quick-reply {
    padding: 0.48rem 0.65rem;
    text-align: left;
    width: 100%;
}

.support-quick-reply:hover,
.support-ai-suggest:hover {
    border-color: rgba(31, 123, 182, 0.45);
    background: rgba(52, 152, 219, 0.08);
}

.support-ai-suggest {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    justify-content: center;
    padding: 0.55rem 0.75rem;
    width: 100%;
}

.support-ai-suggest:disabled,
.support-quick-reply:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.support-chat-reply textarea {
    flex: 1;
    min-height: 46px;
    max-height: 140px;
    padding: 0.75rem 0.85rem;
    border: 1px solid rgba(30, 41, 56, 0.18);
    border-radius: 8px;
    font: inherit;
    resize: vertical;
}

.support-chat-send-icon {
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0 !important;
    justify-content: center;
    border-radius: 50% !important;
}

@media (max-width: 1120px) {
    .support-chat-layout {
        grid-template-columns: minmax(230px, 320px) minmax(0, 1fr);
    }

    .support-reply-tools {
        grid-column: 2;
    }
}

@media (max-width: 860px) {
    .support-refund-head,
    .support-refund-card {
        align-items: stretch;
        flex-direction: column;
    }

    .support-refund-card {
        grid-template-columns: 1fr;
    }

    .support-refund-actions {
        justify-content: stretch;
    }

    .support-refund-actions .btn {
        flex: 1 1 140px;
        justify-content: center;
    }

    .support-chat-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .support-chat-sidebar {
        max-height: 360px;
    }

    .support-chat-window {
        min-height: 560px;
    }

    .support-chat-message {
        max-width: 92%;
    }

    .support-chat-reply {
        align-items: stretch;
        gap: 0.6rem;
    }

    .support-chat-reply textarea {
        min-width: 0;
        width: 100%;
    }

    .support-chat-reply .btn {
        flex: 0 0 auto;
        width: auto;
        min-width: 112px;
        justify-content: center;
        padding-left: 0.85rem;
        padding-right: 0.85rem;
        white-space: nowrap;
    }

    .support-chat-reply .support-chat-send-icon {
        flex: 0 0 44px;
        width: 44px;
        min-width: 44px;
        max-width: 44px;
        height: 44px;
        border-radius: 50% !important;
        padding: 0 !important;
    }

    .support-reply-tools {
        grid-column: auto;
    }

    .support-ai-suggest {
        justify-content: center;
        width: 100%;
    }
}

@media (max-width: 520px) {
    .support-chat-reply {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .support-chat-reply .btn {
        min-width: 92px;
        font-size: 0.82rem;
    }

    .support-chat-reply .support-chat-send-icon {
        min-width: 44px;
        font-size: 1rem;
    }
}
