/* ==========================================================================
   Support (Help) — user + admin shared styles
   Prefix: .sup-* for user modals, .adm-sup-* for admin internals
   ========================================================================== */

/* --- Tab badge --- */
.tab-badge {
    display: inline-block;
    min-width: 18px;
    padding: 0 6px;
    height: 18px;
    line-height: 18px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: #e53935;
    border-radius: 9px;
    margin-left: 6px;
    text-align: center;
}

.support-hint {
    color: var(--text-secondary, #777);
    margin: 4px 0 16px;
    font-size: 0.95em;
}

/* --- Tickets list --- */
.support-tickets-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
.sup-ticket-card {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    color: var(--text-primary, #111);
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    transition: box-shadow .15s, transform .15s, border-color .15s;
}
.sup-ticket-card:hover {
    box-shadow: 0 4px 18px rgba(0,0,0,0.08);
    border-color: #3b82f6;
}
.sup-ticket-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.sup-ticket-subject {
    margin: 0;
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sup-ticket-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.85em;
    color: var(--text-secondary, #6b7280);
}
.sup-ticket-id { font-family: monospace; opacity: 0.7; }

.sup-ticket-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: #e5e7eb; color: #4b5563;
}
.sup-ticket-status.status-open         { background: #dbeafe; color: #1e40af; }
.sup-ticket-status.status-pending_user { background: #fef3c7; color: #92400e; }
.sup-ticket-status.status-answered     { background: #d1fae5; color: #065f46; }
.sup-ticket-status.status-closed       { background: #e5e7eb; color: #374151; }

.sup-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
    display: inline-block;
}

.sup-empty, .sup-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary, #6b7280);
}
.sup-empty-icon { font-size: 3rem; margin-bottom: 12px; }

/* --- Modal --- */
.sup-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.sup-modal {
    background: var(--card-bg, #fff);
    color: var(--text-primary, #111);
    width: 100%;
    max-width: 560px;
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.35);
    display: flex; flex-direction: column;
    max-height: 90vh;
}
.sup-modal-chat { max-width: 720px; }

.sup-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}
.sup-modal-head h3 { margin: 0; font-size: 1.1rem; }

.sup-close {
    background: transparent; border: 0; font-size: 28px;
    line-height: 1; cursor: pointer; color: inherit; opacity: 0.6;
}
.sup-close:hover { opacity: 1; }

.sup-modal-body {
    padding: 18px 22px;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 6px;
}
.sup-modal-body label {
    font-size: 0.85em; font-weight: 600;
    margin-top: 10px; color: var(--text-secondary, #6b7280);
}
.sup-modal-body input,
.sup-modal-body select,
.sup-modal-body textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 8px;
    background: var(--input-bg, #fff);
    color: var(--text-primary, inherit);
    font-size: 0.95rem;
    font-family: inherit;
}
.sup-modal-body textarea { resize: vertical; min-height: 120px; }

.sup-modal-foot {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.sup-detail-meta {
    padding: 10px 22px;
    display: flex; gap: 12px; flex-wrap: wrap;
    font-size: 0.85em; color: var(--text-secondary, #6b7280);
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

/* --- Chat area --- */
.sup-chat {
    flex: 1;
    overflow-y: auto;
    padding: 18px 22px;
    display: flex; flex-direction: column; gap: 10px;
    background: var(--bg-secondary, #f7f8fa);
    min-height: 300px;
}
.sup-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.45;
}
.sup-msg-head {
    display: flex; justify-content: space-between; gap: 10px;
    font-size: 0.75em; opacity: 0.8; margin-bottom: 4px;
}
.sup-msg.msg-user {
    align-self: flex-end;
    background: #3b82f6; color: #fff;
    border-bottom-right-radius: 4px;
}
.sup-msg.msg-admin {
    align-self: flex-start;
    background: var(--card-bg, #fff);
    color: var(--text-primary, #111);
    border: 1px solid var(--border-color, #e5e7eb);
    border-bottom-left-radius: 4px;
}
.sup-msg.msg-system {
    align-self: center;
    background: #fff7ed;
    border: 1px dashed #fdba74;
    color: #7c2d12;
    font-size: 0.9em;
    max-width: 90%;
}

.sup-reply {
    border-top: 1px solid var(--border-color, #e5e7eb);
    padding: 12px 22px;
    display: flex; flex-direction: column; gap: 10px;
}
.sup-reply textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 8px;
    font-family: inherit;
    resize: vertical;
    background: var(--input-bg, #fff);
    color: var(--text-primary, inherit);
}
.sup-reply-actions { display: flex; justify-content: space-between; gap: 10px; }

/* --- Mobile --- */
@media (max-width: 600px) {
    .sup-overlay { padding: 0; align-items: stretch; }
    .sup-modal {
        max-width: none; max-height: 100vh; height: 100vh;
        border-radius: 0;
    }
    .sup-msg { max-width: 92%; }
}

/* ==========================================================================
   Admin support panel
   ========================================================================== */

.adm-sup-wrap {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 16px;
    min-height: 500px;
}
.adm-sup-sidebar {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    padding: 12px;
    background: var(--card-bg, #fff);
    color: var(--text-primary, #111);
    display: flex; flex-direction: column; gap: 10px;
    max-height: 70vh;
}
.adm-sup-filters {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.adm-sup-filters select,
.adm-sup-filters input {
    flex: 1 1 auto;
    padding: 6px 10px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 6px;
    background: var(--input-bg, #fff);
    color: var(--text-primary, #111);
    font-size: 0.9rem;
}
.adm-sup-list {
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 6px;
}
.adm-sup-item {
    padding: 10px 12px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.adm-sup-item:hover { border-color: var(--primary-color, #3b82f6); }
.adm-sup-item.active {
    border-color: var(--primary-color, #3b82f6);
    background: var(--bg-hover, #eff6ff);
}
.adm-sup-item.unread { font-weight: 600; }
.adm-sup-item .subj { display: block; margin-bottom: 4px; }
.adm-sup-item .meta {
    display: flex; gap: 8px; flex-wrap: wrap;
    font-size: 0.75em; color: var(--text-secondary, #6b7280);
    font-weight: 400;
}

.adm-sup-detail {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    background: var(--card-bg, #fff);
    color: var(--text-primary, #111);
    display: flex; flex-direction: column;
    max-height: 70vh;
}
.adm-sup-detail-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-wrap: wrap;
}
.adm-sup-detail-head h3 { margin: 0; font-size: 1rem; }
.adm-sup-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.adm-sup-actions select, .adm-sup-actions button {
    padding: 6px 10px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 6px;
    background: var(--input-bg, #fff);
    color: var(--text-primary, #111);
    cursor: pointer;
    font-size: 0.85rem;
}

.adm-sup-stats {
    display: flex; gap: 10px; flex-wrap: wrap;
    margin-bottom: 12px;
}
.adm-sup-stat {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    color: var(--text-primary, #111);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.9em;
}
.adm-sup-stat strong { font-size: 1.1em; margin-right: 6px; }

@media (max-width: 800px) {
    .adm-sup-wrap { grid-template-columns: 1fr; }
    .adm-sup-sidebar, .adm-sup-detail { max-height: none; }
}

/* ==========================================================================
   Dark theme overrides
   theme.css globally sets div/span/p color to --text-secondary in dark mode,
   which makes hard-coded light bubbles unreadable. Force explicit colors.
   ========================================================================== */

[data-theme="dark"] .sup-msg.msg-user,
[data-theme="dark"] .sup-msg.msg-user * {
    color: #fff !important;
}

[data-theme="dark"] .sup-msg.msg-admin {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}
[data-theme="dark"] .sup-msg.msg-admin,
[data-theme="dark"] .sup-msg.msg-admin * {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .sup-msg.msg-system {
    background: rgba(251, 191, 36, 0.08);
    border: 1px dashed rgba(251, 191, 36, 0.4);
}
[data-theme="dark"] .sup-msg.msg-system,
[data-theme="dark"] .sup-msg.msg-system * {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .sup-msg-head {
    color: var(--text-secondary);
    opacity: 0.85;
}

[data-theme="dark"] .sup-modal-head h3,
[data-theme="dark"] .adm-sup-detail-head h3 {
    color: var(--text-primary);
}

/* Status badges keep light backgrounds; soften for dark mode */
[data-theme="dark"] .sup-ticket-status.status-open         { background: #1e3a8a; color: #bfdbfe; }
[data-theme="dark"] .sup-ticket-status.status-pending_user { background: #78350f; color: #fde68a; }
[data-theme="dark"] .sup-ticket-status.status-answered     { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .sup-ticket-status.status-closed       { background: #334155; color: #cbd5e1; }

[data-theme="dark"] .sup-ticket-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 18px rgba(0,0,0,0.4);
}

/* Sidebar list active item readability */
[data-theme="dark"] .adm-sup-item.active {
    background: var(--bg-tertiary);
}
