/* surfaces/support.css — Customer support chat (Phase 2 / Session 5).
   Extracted from inline <style> in templates/customer/support.html.
   Token-driven via [data-theme]. */

*, *::before, *::after { box-sizing: border-box; }

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
}

/* ── Nav Bar ── */
.nav-bar {
    background-color: var(--bg-base);
    padding: 14px 0;
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-container {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav-brand {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.01em;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 16px;
}
.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    transition: color 0.15s;
}
.nav-link:hover { color: var(--text-primary); }
.nav-link.active { color: var(--text-primary); }
.nav-email-inline {
    color: var(--text-faint);
    font-size: 13px;
}

/* ── Page Container ── */
.support-container {
    max-width: 860px;
    margin: 0 auto;
    padding: 28px 20px;
}
.page-header {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    background-clip: unset;
    letter-spacing: -0.02em;
}
.page-lede {
    color: var(--text-muted);
    margin-bottom: 16px;
    font-size: 13px;
}

/* ── View Transitions ── */
.view { display: none; }
.view.active { display: block; animation: fadeUp 0.18s ease; }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Category List ── */
.category-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid var(--border-faint);
}
.category-card {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-faint);
    border-radius: 0;
    padding: 13px 14px;
    cursor: pointer;
    transition: background 0.12s;
    position: relative;
    overflow: hidden;
}
.category-card::before { display: none; }
.category-card:hover {
    background: var(--bg-panel);
}
.category-card:hover::before { opacity: 0; }
.category-card.selected {
    background: var(--accent-glow);
    border-left: 3px solid var(--accent);
    padding-left: 11px;
}
.category-card.selected .category-name {
    color: var(--text-primary);
}
.category-card.selected .category-name::before {
    color: var(--accent-on-light);
}
.category-card.selected .category-desc {
    color: var(--text-muted);
}
.category-icon {
    display: none;
}
.category-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-body);
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 8px;
}
.category-name::before {
    content: '›';
    color: var(--text-faint);
    font-size: 16px;
    font-weight: 400;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.12s;
}
.category-card:hover .category-name::before {
    color: var(--text-muted);
}
.category-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.3;
    padding-left: 18px;
}

/* ── Conversation List ── */
.conv-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.btn-new-conv {
    padding: 7px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 5px;
    color: var(--text-body);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.btn-new-conv:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}
.conv-item {
    background: var(--bg-panel);
    border: 1px solid var(--border-faint);
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
    display: flex;
    align-items: center;
    gap: 12px;
}
.conv-item:hover {
    border-color: var(--border-subtle);
    background: var(--bg-card);
}
.conv-item.has-unread {
    border-left: 2px solid var(--accent);
}
.conv-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.conv-status-dot.open { background: var(--success); }
.conv-status-dot.waiting_customer { background: var(--warning); }
.conv-status-dot.waiting_team { background: var(--info); }
.conv-status-dot.closed { background: var(--text-faint); }
.conv-body {
    flex: 1;
    min-width: 0;
}
.conv-top-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}
.conv-category {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}
.conv-time {
    font-size: 11px;
    color: var(--text-faint);
    margin-left: auto;
    flex-shrink: 0;
}
.conv-preview {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-unread-badge {
    background: var(--accent-glow);
    color: var(--accent-on-light);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 8px;
    flex-shrink: 0;
}
.conv-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-faint);
}
.conv-empty i {
    font-size: 32px;
    margin-bottom: 12px;
    display: block;
    color: var(--border-subtle);
}

/* ── Chat View ── */
.chat-header {
    background: var(--bg-panel);
    border: 1px solid var(--border-faint);
    border-radius: 6px 6px 0 0;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-back-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.12s;
}
.chat-back-btn:hover { color: var(--text-primary); background: var(--bg-elevated); }
.chat-header-info { flex: 1; }
.chat-header-category {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.chat-header-status {
    font-size: 11px;
    color: var(--text-muted);
}
.chat-header-status .status-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 4px;
    letter-spacing: 0.03em;
}
.status-badge.open { background: var(--success-bg); color: var(--success); }
.status-badge.waiting_customer { background: var(--warning-bg); color: var(--warning); }
.status-badge.waiting_team { background: var(--info-bg); color: var(--info); }
.status-badge.closed { background: var(--bg-elevated); color: var(--text-muted); }

/* ── Persistent Notice Banner ── */
.chat-notice {
    background: var(--bg-panel);
    border-left: 1px solid var(--border-faint);
    border-right: 1px solid var(--border-faint);
    border-bottom: 1px solid var(--border-faint);
    padding: 10px 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: noticeIn 0.2s ease;
}
@keyframes noticeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.chat-notice-content {
    flex: 1;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
}
.chat-notice-content strong {
    color: var(--text-body);
    font-weight: 600;
}
.chat-notice-content .notice-tips {
    margin-top: 6px;
    padding-left: 0;
    color: var(--text-muted);
    font-size: 11px;
}
.chat-notice-content .notice-tips span {
    display: block;
    padding: 1px 0;
}
.chat-notice-toggle {
    background: none;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 3px;
    transition: color 0.12s;
    flex-shrink: 0;
}
.chat-notice-toggle:hover { color: var(--text-muted); }

/* Minimized state */
.chat-notice-mini {
    border-left: 1px solid var(--border-faint);
    border-right: 1px solid var(--border-faint);
    border-bottom: 1px solid var(--border-faint);
    padding: 5px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-faint);
    background: var(--bg-panel);
}

/* Messages Area */
.chat-messages {
    background: var(--bg-panel);
    border-left: 1px solid var(--border-faint);
    border-right: 1px solid var(--border-faint);
    height: 55vh;
    min-height: 350px;
    max-height: 600px;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }

.chat-empty {
    text-align: center;
    color: var(--text-faint);
    padding: 40px;
}
.chat-error {
    text-align: center;
    color: var(--danger);
}

.msg-row {
    display: flex;
    flex-direction: column;
    max-width: 72%;
    animation: msgIn 0.15s ease;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}
.msg-row.customer { align-self: flex-end; align-items: flex-end; }
.msg-row.team     { align-self: flex-start; align-items: flex-start; }

.msg-sender {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 2px;
    padding: 0 2px;
}
.msg-bubble {
    padding: 9px 13px;
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}
.msg-row.customer .msg-bubble {
    background: var(--info-bg);
    color: var(--text-primary);
    border-bottom-right-radius: 3px;
}
.msg-row.team .msg-bubble {
    background: var(--bg-elevated);
    color: var(--text-body);
    border-bottom-left-radius: 3px;
}
.msg-time {
    font-size: 10px;
    color: var(--text-faint);
    margin-top: 2px;
    padding: 0 2px;
}
.msg-edited-label {
    font-size: 10px;
    color: var(--text-faint);
    font-style: italic;
    padding: 0 4px;
}
.msg-edited-static {
    font-size: 9px;
    color: var(--text-faint);
    padding: 0 4px;
    letter-spacing: 0.02em;
}
.msg-attachments {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.msg-attachment-link {
    font-size: 12px;
    color: var(--accent-on-light);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.msg-attachment-link:hover { text-decoration: underline; }
.msg-img-preview {
    max-width: 240px;
    max-height: 180px;
    border-radius: 6px;
    margin-top: 4px;
    cursor: pointer;
}

/* Date separator */
.date-separator {
    text-align: center;
    padding: 8px 0;
    position: relative;
}
.date-separator span {
    background: var(--bg-panel);
    padding: 0 10px;
    font-size: 10px;
    color: var(--text-faint);
    font-weight: 600;
    position: relative;
    z-index: 1;
    letter-spacing: 0.02em;
}
.date-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0; right: 0;
    height: 1px;
    background: var(--border-faint);
}

/* Chat Input */
.chat-input-area {
    background: var(--bg-panel);
    border: 1px solid var(--border-faint);
    border-radius: 0 0 6px 6px;
    padding: 12px 14px;
}
.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.chat-input-field {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 12px 14px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13.5px;
    resize: none;
    min-height: 52px;
    max-height: 160px;
    outline: none;
    transition: border-color 0.15s;
}
.chat-input-field:focus { border-color: var(--accent); }
.chat-input-field::placeholder { color: var(--text-faint); }
.btn-attach {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
    flex-shrink: 0;
}
.btn-attach:hover { color: var(--text-primary); border-color: var(--border-strong); }
.btn-send {
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: var(--text-on-accent);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}
.btn-send:hover { background: var(--accent-bright); border-color: var(--accent-bright); color: var(--text-on-accent); }
.btn-send:disabled { opacity: 0.3; cursor: default; }

/* FilePond overrides */
.filepond-area { margin-top: 6px; display: none; }
.filepond-area.show { display: block; }
.filepond--root { font-family: var(--font-sans); }
.filepond--panel-root { background: var(--bg-card) !important; }
.filepond--drop-label { color: var(--text-muted) !important; }

/* Pending attachments list */
.pending-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.pending-file {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}
.pending-file .remove-file {
    color: var(--danger);
    cursor: pointer;
    font-size: 9px;
}

/* First message input (category selected) */
.first-msg-area {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 20px;
    margin-top: 16px;
    animation: fadeUp 0.18s ease;
}
.first-msg-label {
    font-size: 13px;
    color: var(--text-body);
    margin-bottom: 10px;
}
.first-msg-category {
    font-weight: 700;
    color: var(--text-primary);
}
.first-msg-area .chat-input-field {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}
.first-msg-area .chat-input-field::placeholder {
    color: var(--text-muted);
}
.first-msg-area .btn-send {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: var(--text-on-accent);
    width: 52px;
    height: 52px;
    border-radius: 6px;
    align-self: stretch;
}
.first-msg-area .btn-send:hover {
    background: var(--accent-bright);
    border-color: var(--accent-bright);
    color: var(--text-on-accent);
}
.first-msg-area .btn-send:disabled {
    opacity: 0.25;
}

.first-msg-hint {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-faint);
}
.first-msg-hint kbd {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: var(--font-sans);
    font-size: 10px;
    color: var(--text-muted);
}

.btn-new-conv-icon {
    margin-right: 6px;
}

/* Loading state */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}
.loading-spinner::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-faint);
    border-top-color: var(--text-faint);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Typing indicator */
.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border-radius: 8px;
    border-bottom-left-radius: 3px;
}
.typing-indicator span {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-faint);
    margin: 0 1px;
    animation: typingDot 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-3px); opacity: 1; }
}

/* Responsive */
@media (max-width: 640px) {
    .category-desc { display: none; }
}
@media (max-width: 520px) {
    .category-grid { grid-template-columns: 1fr; }
    .msg-row { max-width: 85%; }
    .chat-messages { height: 50vh; }
    .support-container { padding: 16px 12px; }
}

/* Theme toggle inside support nav */
.nav-bar .cc-theme-toggle {
    margin-left: 8px;
}

/* ══════════════════════════════════════════════════════════════════════
   THE PUBLIC DOOR — "Help & Contact" (Oct 2026, ESTEBAN DESK lane door).
   templates/support/door.html · conversation.html · sent.html. The same
   surface as the logged-in chat above, so the same sheet: one place for
   the support look (Critical Pattern #27 — a separate sheet is for
   SHARING, never for dodging). Appended at the END on purpose: the
   thread page reuses .chat-* / .msg-* above and the few overrides here
   win on source order at equal specificity.
   ══════════════════════════════════════════════════════════════════════ */
.door-container { max-width: 720px; }
.door-lede { margin-bottom: 20px; }

.door-notice,
.door-errors {
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.5;
}
.door-notice {
    background: var(--info-bg);
    color: var(--text-body);
    border: 1px solid var(--border-faint);
}
.door-errors {
    background: var(--danger-bg);
    color: var(--text-primary);
    border: 1px solid var(--danger);
}
.door-errors ul { margin: 0; padding-left: 18px; }

.door-form { display: flex; flex-direction: column; gap: 20px; }

.door-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

/* The topics — the house's category rows, now real radio buttons so the
   form works without JavaScript. The chosen one takes the selected look
   the logged-in grid uses (.category-card.selected). */
.door-topics {
    border: none;
    margin: 0;
    padding: 0;
    min-width: 0;
}
.door-topics legend { padding: 0; float: none; width: auto; }
.door-topic {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-faint);
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background 0.12s;
}
.door-topic:first-of-type { border-top: 1px solid var(--border-faint); }
.door-topic:hover { background: var(--bg-panel); }
.door-topic input {
    margin: 3px 0 0;
    flex-shrink: 0;
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}
.door-topic-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.door-topic-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-body);
    line-height: 1.25;
}
.door-topic-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.35;
}
.door-topic:has(input:checked) {
    background: var(--accent-glow);
    border-left-color: var(--accent);
}
.door-topic input:checked + .door-topic-body .door-topic-name { color: var(--text-primary); }
.door-topic:focus-within { box-shadow: var(--shadow-focus); }

.door-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}
@media (min-width: 640px) {
    .door-row { grid-template-columns: 1fr 1fr; }
}
.door-field { display: block; margin: 0; }
.door-field input,
.door-field textarea {
    display: block;
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 11px 13px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.door-field textarea { resize: vertical; min-height: 150px; }
.door-field input:focus,
.door-field textarea:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
}
.door-field textarea::placeholder { color: var(--text-faint); }
.door-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

/* The honeypot: off-screen for people and screen readers (aria-hidden on
   the element), never display:none — some bots skip hidden inputs. */
.door-hp {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.door-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
}
.door-submit {
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: var(--text-on-accent);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    padding: 11px 22px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.door-submit:hover { background: var(--accent-bright); border-color: var(--accent-bright); }
.door-submit:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.door-fine {
    font-size: 12.5px;
    color: var(--text-muted);
}
.door-fine a,
.door-closed a {
    color: var(--accent-on-light);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* The thread page reuses the chat box above; these sit between its parts. */
.door-thread-header { margin-top: 4px; }
.door-thread-header .chat-header-status { display: flex; align-items: center; gap: 6px; }
.door-banner .chat-notice-content strong { word-break: break-all; }
.door-messages { height: auto; min-height: 260px; max-height: 60vh; }
.door-closed {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}
.door-reply-error {
    margin: 8px 0 0;
    font-size: 12.5px;
    color: var(--danger);
}
.door-sent { padding: 24px 0; }

/* The door's nav holds one line at phone width ("Cinematic Composing", one
   link, the theme toggle): the brand and the link never wrap, and the gaps
   tighten under 520px so the three still fit a 390px screen. */
.support-door .nav-brand,
.support-door .nav-link { white-space: nowrap; }

@media (max-width: 520px) {
    .door-messages { max-height: 55vh; }
    .door-submit { width: 100%; }
    .support-door .nav-container { padding: 0 12px; }
    .support-door .nav-brand { font-size: 14px; }
    .support-door .nav-links { gap: 10px; }
    .support-door .nav-bar .cc-theme-toggle { margin-left: 0; }
}

/* The logged-in list: an email-born ticket says so (Oct 2026, lane door). */
.conv-channel {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    padding: 1px 5px;
}
