/* ============================================================
   Support Page Styles
   ============================================================ */

/* ── Tabs Bar ── */
.tabs-bar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-s);
    margin-bottom: 16px;
}

.tabs-bar .tab-btn {
    padding: 10px 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: var(--fs-base, 13px);
    font-family: sans-serif;
    color: var(--text-2, #555);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition, 0.18s);
}

.tabs-bar .tab-btn:hover {
    color: var(--primary, #B8960C);
}

.tabs-bar .tab-btn.active {
    color: var(--primary, #B8960C);
    border-bottom-color: var(--primary, #B8960C);
    font-weight: 600;
}

/* ── WS Badge ── */
.ws-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: var(--fs-sm, 12px);
    font-weight: 600;
}

.ws-badge::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

.ws-connected {
    background: color-mix(in srgb, var(--success) 12%, transparent);
    color: var(--success);
    border: 1px solid color-mix(in srgb, var(--success) 25%, transparent);
}

.ws-connected::before {
    background: var(--success, #2E7D32);
}

.ws-disconnected {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
}

.ws-disconnected::before {
    background: var(--danger, #C62828);
}

/* ── Conversations Layout ── */
.conversations-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    height: calc(100vh - 220px);
    min-height: 400px;
    border: 1px solid var(--border-s);
    border-radius: var(--radius, 10px);
    overflow: hidden;
    background: var(--surface, #fff);
    box-shadow: none;
}

.conv-list-panel {
    border-left: 1px solid var(--border-s);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface-2, #f5f5f5);
}

.conv-list-header {
    padding: 10px 12px;
    border-bottom: none;
    background: var(--surface, #fff);
    position: relative;
}

.conv-list-header::after {
    content: '';
    position: absolute;
    right: 0;
    left: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(
        to left,
        transparent 0%,
        var(--border) 12%,
        var(--border) 88%,
        transparent 100%
    );
    opacity: 0.65;
}

.conv-list-header select {
    width: 100%;
}

#conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 6px;
}

/* ── Conv Item ── */
.conv-item {
    padding: 10px 12px;
    border-bottom: none;
    border-radius: var(--radius-s);
    cursor: pointer;
    transition: background var(--transition, 0.18s);
}

.conv-item:hover {
    background: var(--surface-2);
}

.conv-item.active {
    background: var(--primary-t);
    border-right: 3px solid var(--primary);
}

.conv-item-name {
    font-weight: 600;
    font-size: var(--fs-base, 13px);
    color: var(--text-1, #1A1D23);
}

.conv-item-preview {
    font-size: var(--fs-sm, 12px);
    color: var(--text-3, #aaa);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.conv-item-time {
    font-size: var(--fs-xs, 11px);
    color: var(--text-3, #aaa);
}

/* ── Chat Panel ── */
.chat-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface, #fff);
}

.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-3, #aaa);
    gap: 10px;
}

.chat-empty .icon-xl {
    width: 48px;
    height: 48px;
    opacity: 0.4;
}

#chat-active {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-s);
    background: var(--surface, #fff);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg, #F0F2F5);
}

/* ── Message Bubbles ── */
.msg-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: var(--radius, 10px);
    font-size: var(--fs-base, 13px);
    line-height: 1.5;
    word-break: break-word;
}

.msg-bubble.outgoing {
    align-self: flex-start;
    background: var(--primary-t);
    border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
    color: var(--text-1, #1A1D23);
    border-bottom-right-radius: 4px;
}

.msg-bubble.incoming {
    align-self: flex-end;
    background: var(--surface, #fff);
    border: 1px solid var(--border-s);
    color: var(--text-1, #1A1D23);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-s);
}

.msg-meta {
    font-size: var(--fs-xs, 11px);
    color: var(--text-3, #aaa);
    margin-top: 4px;
}

.typing-indicator {
    padding: 4px 16px;
    font-size: var(--fs-xs, 11px);
    color: var(--text-3, #aaa);
    min-height: 20px;
    flex-shrink: 0;
}

.chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border-s);
    background: var(--surface, #fff);
    flex-shrink: 0;
}

.chat-input-bar textarea {
    flex: 1;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    border-radius: var(--radius-s, 6px);
    font-size: var(--fs-base, 13px);
    padding: 8px 12px;
}

.chat-input-bar .btn {
    flex-shrink: 0;
    align-self: flex-end;
    white-space: nowrap;
}

/* ── FAQ ── */
.faq-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-s);
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.faq-item {
    border: 1px solid var(--border-s);
    border-radius: var(--radius, 10px);
    background: var(--surface, #fff);
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    box-shadow: none;
    transition: border-color var(--transition), background var(--transition);
}

.faq-item:hover {
    border-color: var(--border);
    background: var(--surface-2);
}

.faq-item-body {
    flex: 1;
}

.faq-item-q {
    font-weight: 600;
    font-size: var(--fs-base, 13px);
    color: var(--text-1, #1A1D23);
    margin-bottom: 4px;
}

.faq-item-a {
    font-size: var(--fs-sm, 12px);
    color: var(--text-2, #555);
}

.faq-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ── WS Status Bar ── */
.ws-status-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    flex-wrap: nowrap;
}

.sys-status-box {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border-s);
    border-radius: var(--radius-s);
    padding: 4px 10px;
    background: var(--surface-2, #f5f5f5);
    height: 32px;
    width: 200px;
}

.sys-status-live {
    flex: 1;
    font-size: 11px;
    color: var(--text-2, #666);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Courier New', monospace;
}

.sys-status-live.ok {
    color: var(--success);
}

.sys-status-live.error {
    color: var(--danger);
}

.sys-status-live.info {
    color: var(--info);
}

.sys-info-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid var(--border-s);
    background: var(--surface, #fff);
    color: var(--text-2, #666);
    font-size: 11px;
    cursor: pointer;
    line-height: 18px;
    text-align: center;
    padding: 0;
    flex-shrink: 0;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.sys-info-btn:hover {
    background: color-mix(in srgb, var(--info) 12%, transparent);
    border-color: var(--info);
    color: var(--info);
}

.ws-info-popup {
    position: fixed;
    z-index: 9999;
    width: 420px;
    max-width: calc(100vw - 20px);
    background: var(--surface, #fff);
    border: 1px solid var(--border-s);
    border-radius: var(--radius);
    box-shadow: var(--shadow-l);
    font-size: 12px;
    direction: rtl;
    overflow: hidden;
}

.ws-popup-hidden {
    display: none;
}

.ws-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-s);
    font-weight: 600;
    font-size: 13px;
    background: var(--surface-2, #f5f5f5);
    color: var(--text-1, #222);
}

.ws-popup-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.ws-copy-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid var(--border-s);
    border-radius: var(--radius-s);
    background: var(--surface, #fff);
    cursor: pointer;
    font-size: 11px;
    color: var(--text-2, #666);
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.ws-copy-btn:hover {
    background: color-mix(in srgb, var(--success) 12%, transparent);
    border-color: var(--success);
    color: var(--success);
}

.ws-close-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-2, #666);
    border-radius: 4px;
}

.ws-close-btn:hover {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    color: var(--danger);
}

.ws-popup-body {
    max-height: 320px;
    overflow-y: auto;
    padding: 4px 6px;
}

.ws-log-row {
    display: grid;
    grid-template-columns: 58px 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 5px 10px;
    border-bottom: none;
    border-radius: var(--radius-s);
    font-family: 'Courier New', monospace;
    font-size: 11px;
    transition: background var(--transition);
}

.ws-log-row:last-child {
    border-bottom: none;
}

.ws-log-row:hover {
    background: var(--surface-2);
}

.ws-log-code {
    font-weight: 700;
    color: var(--info);
}

.ws-log-code.error {
    color: var(--danger);
}

.ws-log-code.ok {
    color: var(--success);
}

.ws-log-msg {
    color: var(--text-1, #222);
}

.ws-log-msg.error {
    color: var(--danger);
}

.ws-log-time {
    color: var(--text-2, #666);
    font-size: 10px;
    white-space: nowrap;
}

.ws-popup-footer {
    padding: 6px 14px;
    font-size: 10px;
    color: var(--text-2, #666);
    border-top: 1px solid var(--border-s);
    background: var(--surface-2, #f5f5f5);
    text-align: center;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .conversations-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .conv-list-panel {
        height: 260px;
        border-left: none;
        border-bottom: 1px solid var(--border-s);
    }

    .chat-panel {
        height: 400px;
    }
}