/* ─────────────────────────────────────────
   Support widget (bottom-right)
   Live chat inline component
───────────────────────────────────────── */

/* HTML [hidden] attribute must win over display: flex/grid/block below.
   Scoped to our own components so we don't step on anything else. */
.support-widget [hidden],
.support-widget[hidden],
.live-chat-inline [hidden],
.live-chat-inline[hidden] {
    display: none !important;
}

/* =========== Support widget =========== */

.support-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 10000;
    font-family: 'Inter', system-ui, sans-serif;
}

.support-launcher {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: 1px solid rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    border-radius: 100px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.support-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.45);
}

.support-launcher svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 560px) {
    .support-launcher-label { display: none; }
    .support-launcher { padding: 12px; border-radius: 50%; }
}

.support-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    width: 360px;
    max-width: calc(100vw - 40px);
    max-height: min(640px, calc(100vh - 80px));
    background: var(--bg-card, #1f2937);
    border: 1px solid var(--border, #374151);
    border-radius: var(--radius, 10px);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: support-pop 0.2s ease-out;
}

@keyframes support-pop {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.support-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
}
.support-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.support-close {
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.8;
}
.support-close:hover { opacity: 1; }

.support-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.support-muted { color: var(--text-muted, #9ca3af); font-size: 13px; margin: 0 0 12px; }

.support-category-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 16px;
}
.support-category {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border, #374151);
    border-radius: 8px;
    color: var(--text-primary, #f3f4f6);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: border-color 0.2s, background 0.2s;
}
.support-category:hover {
    border-color: rgba(96, 165, 250, 0.5);
    background: rgba(59, 130, 246, 0.08);
}
.support-category svg { width: 18px; height: 18px; color: #60a5fa; flex-shrink: 0; }

.support-link-btn {
    background: transparent;
    border: 0;
    color: #60a5fa;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
}
.support-link-btn:hover { text-decoration: underline; }

.support-back {
    background: transparent;
    border: 0;
    color: var(--text-muted, #9ca3af);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 8px;
}
.support-back:hover { color: var(--text-primary, #f3f4f6); }

.support-screen-title {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #f3f4f6);
}

.support-field { margin-bottom: 12px; }
.support-field label {
    display: block;
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
    margin-bottom: 4px;
    font-weight: 500;
}
.support-field input,
.support-field textarea,
.support-form textarea {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-body, #111827);
    border: 1px solid var(--border, #374151);
    border-radius: 6px;
    color: var(--text-primary, #f3f4f6);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}
.support-field input:focus,
.support-field textarea:focus,
.support-form textarea:focus {
    outline: none;
    border-color: rgba(96, 165, 250, 0.6);
}
.support-hint { color: var(--text-muted, #6b7280); font-size: 11px; margin-top: 4px; display: block; }

.support-submit {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.2s;
}
.support-submit:hover { transform: translateY(-1px); }
.support-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.support-error {
    margin-top: 10px;
    padding: 8px 10px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    color: #fca5a5;
    font-size: 12px;
}

.support-ticket-list { list-style: none; padding: 0; margin: 0; }
.support-ticket-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 12px;
    padding: 10px 12px;
    border: 1px solid var(--border, #374151);
    border-radius: 6px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.02);
}
.support-ticket-title {
    grid-column: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #f3f4f6);
    word-break: break-word;
}
.support-ticket-meta {
    grid-column: 1;
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
}
.support-ticket-open {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    background: transparent;
    border: 1px solid var(--border, #374151);
    border-radius: 4px;
    color: #60a5fa;
    font-size: 12px;
    padding: 5px 10px;
    cursor: pointer;
}
.support-ticket-open:hover { border-color: #60a5fa; }

.support-empty {
    color: var(--text-muted, #9ca3af);
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
}

.support-thread {
    max-height: 280px;
    overflow-y: auto;
    padding: 4px 2px 12px;
    margin-bottom: 12px;
}
.support-msg {
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    max-width: 85%;
    word-wrap: break-word;
}
.support-msg-user {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.25);
    margin-left: auto;
}
.support-msg-staff {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.25);
}
.support-msg-who {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #9ca3af);
    margin-bottom: 2px;
}
.support-msg-staff .support-msg-who { color: #86efac; }
.support-msg-user .support-msg-who { color: #93c5fd; }
.support-msg-body { font-size: 13px; color: var(--text-primary, #f3f4f6); white-space: pre-wrap; }
.support-msg-when { font-size: 10px; color: var(--text-muted, #6b7280); margin-top: 3px; }

.support-reply-form { display: flex; flex-direction: column; gap: 8px; }
.support-reply-form textarea { min-height: 60px; }

.support-success {
    text-align: center;
    padding: 20px 0;
}
.support-success-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #22c55e;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
}
.support-success h4 { margin: 0 0 6px; color: var(--text-primary, #f3f4f6); }

/* =========== Live Chat inline (under upload section) =========== */

.live-chat-inline {
    max-width: 720px;
    margin: 32px auto 0;
    background: var(--bg-card, #1f2937);
    border: 1px solid var(--border, #374151);
    border-radius: var(--radius, 10px);
    padding: 20px 24px;
    font-family: 'Inter', system-ui, sans-serif;
    position: relative;
    overflow: hidden;
}

.live-chat-inline::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #34d399, transparent);
}

.live-chat-inline-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.live-chat-inline-header h2 {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary, #f3f4f6);
}
.live-chat-inline-sub {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
}

.live-chat-inline-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #34d399;
    padding: 4px 10px;
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.3);
    border-radius: 100px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    flex-shrink: 0;
}
.live-chat-inline-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #34d399;
    animation: live-chat-pulse 1.8s ease-in-out infinite;
}
@keyframes live-chat-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

.live-chat-name-prompt {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.live-chat-name-prompt label {
    color: var(--text-muted, #9ca3af);
    font-size: 12px;
    font-weight: 500;
}
.live-chat-name-row {
    display: flex;
    gap: 8px;
}
.live-chat-name-prompt input {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-body, #111827);
    border: 1px solid var(--border, #374151);
    border-radius: 6px;
    color: var(--text-primary, #f3f4f6);
    font-size: 14px;
}
.live-chat-name-prompt input:focus { outline: none; border-color: rgba(52, 211, 153, 0.6); }
.live-chat-name-prompt button {
    background: linear-gradient(135deg, #10b981, #047857);
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 10px 20px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.live-chat-name-prompt button:hover { transform: translateY(-1px); }
.live-chat-hint { color: var(--text-muted, #9ca3af); font-size: 11px; margin: 0; }
.live-chat-hint a { color: #34d399; }

.live-chat-room {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.live-chat-messages {
    height: 280px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-body, #111827);
    border: 1px solid var(--border, #374151);
    border-radius: 6px;
}

.live-chat-msg {
    display: block;
    padding: 4px 8px;
    margin-bottom: 2px;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 13px;
}
.live-chat-msg-name {
    color: #34d399;
    font-weight: 600;
    margin-right: 6px;
}
.live-chat-msg-body {
    color: var(--text-primary, #f3f4f6);
    white-space: pre-wrap;
}
.live-chat-msg-time {
    color: var(--text-muted, #6b7280);
    font-size: 10px;
    margin-left: 6px;
}

.live-chat-form {
    display: flex;
    gap: 8px;
}
.live-chat-form input {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-body, #111827);
    border: 1px solid var(--border, #374151);
    border-radius: 6px;
    color: var(--text-primary, #f3f4f6);
    font-size: 14px;
}
.live-chat-form input:focus { outline: none; border-color: rgba(52, 211, 153, 0.6); }
.live-chat-form button {
    width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #10b981, #047857);
    color: #fff;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}
.live-chat-form button svg { width: 18px; height: 18px; }
.live-chat-form button:disabled { opacity: 0.5; cursor: not-allowed; }

.live-chat-error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    padding: 6px 10px;
    color: #fca5a5;
    font-size: 12px;
}

@media (max-width: 560px) {
    .live-chat-inline { padding: 16px; margin: 24px 16px 0; }
    .live-chat-inline-header { flex-direction: column; align-items: flex-start; }
    .live-chat-name-row { flex-direction: column; }
    .live-chat-name-prompt button { width: 100%; }
}
