/* Customer Support & Tickets addon - chat sidebar Support tab */

/* Tab switcher states (Live Chat | Support) */
.csm-mode-tab-btn.active-support {
    background: rgba(var(--color-primary-rgb, 99, 102, 241), 0.16);
    color: #ffffff;
    border-color: rgba(var(--color-primary-rgb, 99, 102, 241), 0.38);
}
.csm-mode-tab-btn { position: relative; }
#csm-ticket-badge.csm-tab-badge {
    align-items: center;
    justify-content: center;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    margin-left: 4px;
    border-radius: 999px;
    background: #ef4444;
    color: #ffffff;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
}

/* Container */
#csm-help-Container {
    display: none;
    flex-direction: column;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    color: #dfdfe9;
    font-size: 11px;
}
#csm-help-Container.active { display: flex; }

.csm-help-scroll-view {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    scrollbar-width: thin;
    scrollbar-color: #233144 transparent;
}
.csm-help-scroll-view::-webkit-scrollbar { width: 4px; }
.csm-help-scroll-view::-webkit-scrollbar-thumb { background: #233144; border-radius: 4px; }
#csm-screen-ticket-list.csm-help-scroll-view,
#csm-screen-ticket-create.csm-help-scroll-view { height: 100%; }
#csm-screen-ticket-list.csm-help-scroll-view { display: flex; flex-direction: column; flex: 1 1 auto; height: auto; min-height: 0; }
#csm-screen-ticket-list > * { flex-shrink: 0; }

/* Header */
.csm-help-header-wrap { margin-bottom: 10px; }
.csm-help-header-title { margin: 0 0 2px; font-size: 12.5px; font-weight: 700; color: #ffffff; line-height: 1.2; }
.csm-help-header-sub { margin: 0; font-size: 9px; color: #8ea0b8; line-height: 1.3; }

/* Cards */
.csm-support-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 7px;
    background: #1f2a39;
    border: 1px solid #233144;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.csm-support-card:hover { background: #253346; border-color: rgba(var(--color-primary-rgb, 16, 185, 129), 0.35); }
.csm-support-card:active { transform: scale(.99); }
.csm-support-card.no-hover { cursor: default; }
.csm-support-card.no-hover:hover { background: #1f2a39; border-color: #233144; }
.csm-empty-card {
    border: 1px dashed #233144 !important;
    justify-content: center;
    padding: 10px;
    color: #8ea0b8;
    font-size: 9px;
    text-align: center;
}
.csm-guest-card { justify-content: flex-start; }

.csm-card-icon-box {
    position: relative;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin-right: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: #263345;
    color: #93acd3;
    font-size: 11px;
    transition: color .15s ease, background-color .15s ease;
}
.csm-support-card:hover .csm-card-icon-box { color: var(--color-primary, #10b981); background: rgba(var(--color-primary-rgb, 16, 185, 129), 0.15); }
.csm-card-body-wrap { min-width: 0; flex: 1; }
.csm-card-body-title {
    font-size: 12px;
    font-weight: 600;
    color: #dfdfe9;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.csm-card-body-desc {
    margin-top: 2px;
    font-size: 9.5px;
    color: #8ea0b8;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.csm-ticket-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; -webkit-line-clamp: unset; }
.csm-card-arrow { flex-shrink: 0; color: #4b5d75; font-size: 9px; transition: color .15s ease, transform .15s ease; }
.csm-card-arrow { margin-left: 6px; }
.csm-support-card:hover .csm-card-arrow { color: var(--color-primary, #10b981); transform: translateX(2px); }
/* Past chat card: time + status on the right */
.csm-ticket-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; margin-left: 6px; }
.csm-ticket-time { font-size: 9px; color: #8ea0b8; white-space: nowrap; }
.csm-ticket-card .csm-badge { text-transform: capitalize; border-radius: 999px; font-size: 8.5px; padding: 1.5px 7px; }
.csm-badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; display: inline-block; margin-right: 3px; }

.csm-unread-dot {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #1a2532;
}
.csm-unread-count {
    flex-shrink: 0;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ef4444;
    color: #ffffff;
    font-size: 9px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Section divider */
.csm-section-divider-wrap { display: flex; align-items: center; gap: 6px; margin: 14px 0 8px; }
.csm-section-divider-title { font-size: 9px; font-weight: 700; letter-spacing: .08em; color: #8ea0b8; }
.csm-section-divider-count {
    font-size: 8.5px;
    font-weight: 700;
    color: #ffffff;
    background: #233144;
    border-radius: 999px;
    padding: 1px 6px;
}
.csm-section-divider-line { flex: 1; height: 1px; background: #233144; }

.csm-portal-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-top: auto;
    position: sticky;
    bottom: -12px;
    padding: 14px 0 4px;
    background: linear-gradient(to bottom, transparent, #18212d 40%);
    font-size: 9px;
    color: #8ea0b8;
    text-decoration: none;
}
.csm-portal-link:hover { color: #ffffff; }

/* Status badges */
.csm-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    border: 1px solid transparent;
    white-space: nowrap;
}
.csm-badge-open { background: #3b82f620; color: #60a5fa; border-color: #3b82f640; }
.csm-badge-in_progress { background: #f59e0b20; color: #fbbf24; border-color: #f59e0b40; }
.csm-badge-waiting_user { background: #a855f720; color: #c084fc; border-color: #a855f740; }
.csm-badge-resolved { background: #10b98120; color: #34d399; border-color: #10b98140; }
.csm-badge-closed { background: #64748b20; color: #94a3b8; border-color: #64748b40; }

/* Thread */
.csm-thread-header-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-bottom: 1px solid #233144;
    flex-shrink: 0;
}
#csm-screen-ticket-create .csm-thread-header-bar { padding: 0 0 9px; }
.csm-thread-back-btn {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: #1f2a39;
    border: 1px solid #28374a;
    color: #8ea0b8;
    font-size: 9px;
    cursor: pointer;
    text-decoration: none;
    transition: color .15s ease, border-color .15s ease;
}
.csm-thread-back-btn:hover { color: #ffffff; border-color: rgba(var(--color-primary-rgb, 99, 102, 241), 0.5); }
.csm-thread-title {
    margin: 0;
    font-size: 11.5px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.csm-thread-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 2px; font-size: 8.5px; color: #8ea0b8; }
.csm-icon-close { color: #64748b; background: none; border: none; cursor: pointer; font-size: 11px; padding: 2px; }
.csm-icon-close:hover { color: #ffffff; }

#csm-widget-messages-container { display: flex; flex-direction: column; gap: 10px; }
.csm-msg-row { display: flex; align-items: flex-start; gap: 7px; max-width: 100%; }
.csm-msg-row.csm-msg-user { flex-direction: row-reverse; }
.csm-msg-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; border: 1px solid #233144; flex-shrink: 0; }
.csm-msg-body { min-width: 0; max-width: 82%; display: flex; flex-direction: column; }
.csm-msg-user .csm-msg-body { align-items: flex-end; }
.csm-msg-meta { display: flex; align-items: center; gap: 4px; margin-bottom: 3px; font-size: 8.5px; color: #8ea0b8; }
.csm-msg-author { font-weight: 600; color: #dfdfe9; }
.csm-msg-tag {
    font-size: 7.5px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0 4px;
    border-radius: 3px;
    background: rgba(var(--color-primary-rgb, 99, 102, 241), 0.2);
    color: var(--color-primary, #818cf8);
}
.csm-msg-bubble {
    padding: 7px 9px;
    border-radius: 9px;
    font-size: 10.5px;
    line-height: 1.45;
    color: #e5e9f0;
    background: #1f2a39;
    border: 1px solid #233144;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.csm-msg-staff .csm-msg-bubble { border-top-left-radius: 3px; }
.csm-msg-user .csm-msg-bubble {
    border-top-right-radius: 3px;
    background: rgba(var(--color-primary-rgb, 99, 102, 241), 0.2);
    border-color: rgba(var(--color-primary-rgb, 99, 102, 241), 0.35);
    color: #ffffff;
}
.csm-msg-files { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.csm-msg-img img { display: block; max-width: 120px; max-height: 90px; border-radius: 6px; border: 1px solid #233144; object-fit: cover; }
.csm-msg-file {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 160px;
    padding: 3px 7px;
    border-radius: 5px;
    background: #161f2b;
    border: 1px solid #233144;
    color: #dfdfe9;
    font-size: 9px;
    text-decoration: none;
}
.csm-msg-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csm-msg-file:hover { color: #ffffff; border-color: rgba(var(--color-primary-rgb, 99, 102, 241), 0.5); }

/* Bottom bars */
.csm-bottom-panel-bar { flex-shrink: 0; padding: 9px 12px 12px; border-top: 1px solid #233144; }
.csm-bottom-notice-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: #1f2a39;
    border: 1px solid #233144;
    border-radius: 7px;
}
.csm-reply-box { background: #1f2a39; border: 1px solid #233144; border-radius: 7px; padding: 8px 10px; }
.csm-reply-box:focus-within { border-color: rgba(var(--color-primary-rgb, 99, 102, 241), 0.55); }
.csm-reply-textarea {
    width: 100%;
    resize: none;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 10.5px;
    line-height: 1.4;
    padding: 0;
    box-shadow: none !important;
}
.csm-reply-textarea::placeholder { color: #64748b; }
.csm-reply-actions-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px; }
.csm-attach-label { cursor: pointer; color: #8ea0b8; display: flex; align-items: center; gap: 4px; font-size: 8.5px; min-width: 0; }
.csm-attach-label span { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csm-attach-label:hover { color: #ffffff; }

/* Buttons */
.csm-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: none;
    border-radius: 6px;
    background: var(--color-primary, #6366f1);
    color: #ffffff;
    font-size: 9.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: filter .15s ease, opacity .15s ease;
}
.csm-btn-primary:hover { filter: brightness(1.1); }
.csm-btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.csm-btn-block { width: 100%; justify-content: center; height: 32px; font-size: 11px; margin-top: 4px; }
.csm-btn-ghost {
    padding: 3px 7px;
    border-radius: 5px;
    border: 1px solid #28374a;
    background: transparent;
    color: #8ea0b8;
    font-size: 8.5px;
    cursor: pointer;
}
.csm-btn-ghost:hover { color: #ffffff; border-color: #ef444480; }

/* Create form */
.csm-create-form-wrap { display: flex; flex-direction: column; gap: 9px; }
.csm-form-group { display: flex; flex-direction: column; gap: 4px; }
.csm-form-label { font-size: 9.5px; font-weight: 600; color: #c7d0dc; }
.csm-form-control {
    width: 100%;
    padding: 7px 9px;
    border-radius: 6px;
    background: #1f2a39 !important;
    border: 1px solid #233144 !important;
    color: #ffffff !important;
    font-size: 10.5px;
    outline: none;
    box-shadow: none !important;
}
.csm-form-control:focus { border-color: rgba(var(--color-primary-rgb, 99, 102, 241), 0.6) !important; }
.csm-form-control::placeholder { color: #64748b; }
select.csm-form-control option { background: #1f2a39; color: #ffffff; }
.csm-urgency-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.csm-urgency-opt {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 2px;
    border-radius: 6px;
    background: #1f2a39;
    border: 1px solid #233144;
    color: #8ea0b8;
    font-size: 9.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
}
.csm-urgency-opt:hover { color: #ffffff; }
.csm-urgency-opt.active {
    color: #ffffff;
    background: rgba(var(--color-primary-rgb, 99, 102, 241), 0.2);
    border-color: rgba(var(--color-primary-rgb, 99, 102, 241), 0.55);
}
#urgency-label-urgent.active { background: #ef444426; border-color: #ef444480; }
#urgency-label-high.active { background: #f59e0b26; border-color: #f59e0b80; }

/* v8: compact past chat card + clean empty/guest card */
.csm-ticket-card { align-items: center !important; min-height: 0 !important; height: auto !important; }
.csm-ticket-card .csm-ticket-side { gap: 4px !important; justify-content: center; }
.csm-ticket-card .csm-ticket-time { font-size: 9px !important; line-height: 1.2 !important; }
.csm-ticket-card .csm-badge { font-size: 8.5px !important; line-height: 1.3 !important; padding: 1px 7px !important; height: auto !important; min-height: 0 !important; border-radius: 999px !important; margin: 0 !important; }
.csm-ticket-card .csm-badge i, .csm-ticket-card .csm-badge-dot { font-size: 5px !important; width: 5px; height: 5px; }
.csm-empty-card { display: block !important; padding: 11px 10px !important; font-size: 10px !important; line-height: 1.5 !important; }
.csm-empty-card a, .csm-empty-card button { display: inline !important; margin: 0 3px !important; padding: 0 !important; font-size: inherit !important; }

/* v10: polished thread view */
#csm-screen-ticket-thread { background: transparent; }
.csm-thread-header-bar { padding: 10px 12px; gap: 9px; }
.csm-thread-back-btn { width: 26px; height: 26px; border-radius: 7px; background: #1f2a39; }
.csm-thread-title { font-size: 12px; }
.csm-thread-sub { font-size: 8.5px; gap: 5px; }
#csm-thread-status-badge { border-radius: 999px; padding: 1px 7px; }
#csm-widget-messages-container { gap: 8px; padding: 12px; }
.csm-msg-card {
    background: #1f2a39;
    border: 1px solid #28374a;
    border-radius: 8px;
    padding: 9px 11px;
    transition: border-color .15s ease;
}
.csm-msg-card:hover { border-color: #33465e; }
.csm-msg-card.csm-msg-staff { border-left: 2px solid var(--color-primary, #10b981); }
.csm-msg-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 8.5px; color: #8ea0b8; }
.csm-msg-card-icon { color: #c7d0dc; font-size: 10px; width: 14px; text-align: center; }
.csm-msg-card .csm-msg-author { font-size: 10.5px; font-weight: 700; color: #ffffff; }
.csm-msg-card .csm-msg-time { margin-left: auto; }
.csm-msg-reply-icon { font-size: 8.5px; color: #64748b; }
.csm-msg-card-text { font-size: 10.5px; line-height: 1.5; color: #c7d0dc; word-break: break-word; overflow-wrap: anywhere; }
.csm-bottom-panel-bar { padding: 10px 12px 12px; }
.csm-reply-box { border-radius: 8px; padding: 9px 11px; }
.csm-reply-textarea { padding-bottom: 8px; border-bottom: 1px solid #28374a !important; border-radius: 0; }
.csm-reply-actions-row { margin-top: 8px; }
#csm_reply_submit_btn { padding: 5px 12px !important; font-size: 9.5px !important; border-radius: 6px; }

/* v11: panel always fills full height */
#csm-help-Container.active > #csm-screen-ticket-list,
#csm-help-Container.active > #csm-screen-ticket-thread,
#csm-help-Container.active > #csm-screen-ticket-create { flex: 1 1 auto; min-height: 0; height: 100%; }
#csm-screen-ticket-thread #csm-widget-messages-container { flex: 1 1 auto; min-height: 0; }
