/* =====================================================
   HONESTLY, E — Chat (portal lightbox)
   Sophie-style hero-alongside shell: the companion's photo runs
   full-height down the LEFT, the conversation (sessions list +
   thread + input) on the RIGHT. The sessions list is kept — this
   is the subscriber's ongoing relationship with their companion,
   not a business storefront. Layout reskin only; chat.js drives
   the same element IDs as before.
   ===================================================== */

.chat-modal {
    max-width: 780px;
    width: 95vw;
    height: 80vh;
    max-height: 680px;
    display: flex;
    flex-direction: row;
    padding: 0;
    overflow: hidden;
}

/* ─── Hero column (the companion, present) ─────────────── */
.chat-hero {
    position: relative;
    flex: 0 0 38%;
    background: #2b2622;
    overflow: hidden;
}

#chat-companion-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
}

.chat-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0) 45%, rgba(0,0,0,0.6) 100%);
    pointer-events: none;
}

.chat-hero-id {
    position: absolute;
    left: 1.1rem;
    right: 0.9rem;
    bottom: 1.05rem;
    z-index: 1;
    color: #fff;
}

.chat-hero-id .chat-modal-name {
    font-family: var(--font-serif, 'EB Garamond', serif);
    font-size: 1.55rem;
    font-weight: 600;
    line-height: 1.05;
}

.chat-hero-id .chat-modal-tagline {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: 2px;
}

/* ─── Main column (the conversation) ───────────────────── */
.chat-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1rem 0.75rem 1.1rem;
    border-bottom: 1px solid var(--border-light, rgba(0,0,0,0.08));
    flex-shrink: 0;
}

.chat-header-spacer { flex: 1; }

.chat-back-btn {
    background: none;
    border: 1px solid var(--border-light, rgba(0,0,0,0.12));
    border-radius: 4px;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    color: var(--text-secondary, #5C534A);
    cursor: pointer;
    font-family: var(--font-sans, sans-serif);
}

.chat-back-btn:hover {
    background: var(--bg-hover, rgba(0,0,0,0.04));
}

.chat-modal-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.chat-view {
    flex: 1;
    overflow: hidden;
}

/* ─── Sessions list view (KEPT — the relationship history) ─ */
#chat-view-sessions {
    display: block;
    overflow-y: auto;
    padding: 1rem 1.1rem;
}

.chat-new-btn {
    display: block;
    width: 100%;
    padding: 0.7rem 1rem;
    margin-bottom: 0.85rem;
    background: var(--bg-secondary, #F5F1EB);
    border: 1px dashed var(--border-light, rgba(0,0,0,0.18));
    border-radius: 6px;
    font-family: var(--font-sans, sans-serif);
    font-size: 0.9rem;
    color: var(--text-secondary, #5C534A);
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-new-btn:hover {
    border-color: var(--text-secondary, #5C534A);
    background: var(--bg-card, #fff);
}

.chat-session-row {
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border-light, rgba(0,0,0,0.08));
    border-radius: 6px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--bg-card, #fff);
}

.chat-session-row:hover {
    border-color: var(--text-secondary, #5C534A);
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.chat-session-row.open {
    border-left: 3px solid var(--gold, #C5A572);
}

.chat-session-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.3rem;
    font-size: 0.72rem;
    color: var(--text-muted, #8B8279);
    font-family: var(--font-sans, sans-serif);
}

.chat-session-date { font-weight: 500; }
.chat-session-count { opacity: 0.8; }

.chat-session-badge {
    margin-left: auto;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.12rem 0.4rem;
    border-radius: 3px;
    background: rgba(27, 54, 93, 0.06);
    color: var(--navy, #1B365D);
}

.chat-session-badge.open {
    background: rgba(197, 165, 114, 0.18);
    color: #8B6F2A;
}

.chat-session-preview {
    font-family: var(--font-serif, 'EB Garamond', serif);
    font-size: 0.95rem;
    color: var(--text-primary, #2C2420);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#chat-sessions-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted, #8B8279);
    font-style: italic;
    font-family: var(--font-serif, serif);
}

/* ─── Thread view ──────────────────────────────────────── */
#chat-view-thread {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem 1.1rem 0.5rem;
}

.chat-empty-thread {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted, #8B8279);
    font-style: italic;
    font-family: var(--font-serif, serif);
}

.chat-msg { margin-bottom: 1.1rem; max-width: 88%; }
.chat-msg-user { margin-left: auto; text-align: right; }
.chat-msg-assistant { margin-right: auto; }

.chat-msg-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted, #8B8279);
    margin-bottom: 0.25rem;
    font-family: var(--font-sans, sans-serif);
}

.chat-msg-content {
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    font-family: var(--font-serif, 'EB Garamond', serif);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text-primary, #2C2420);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.chat-msg-user .chat-msg-content {
    background: rgba(27, 54, 93, 0.06);
    border: 1px solid rgba(27, 54, 93, 0.08);
    border-bottom-right-radius: 5px;
}

.chat-msg-assistant .chat-msg-content {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-light, rgba(0,0,0,0.08));
    border-bottom-left-radius: 5px;
}

.chat-input-row {
    border-top: 1px solid var(--border-light, rgba(0,0,0,0.08));
    padding: 0.7rem 1rem 0.9rem;
    flex-shrink: 0;
    background: var(--bg-secondary, #F5F1EB);
}

#chat-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-light, rgba(0,0,0,0.15));
    border-radius: 8px;
    font-family: var(--font-serif, serif);
    font-size: 0.98rem;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #2C2420);
    box-sizing: border-box;
    resize: vertical;
    min-height: 50px;
}

#chat-input:focus { outline: none; border-color: var(--navy, #1B365D); }
#chat-input:disabled { opacity: 0.6; cursor: not-allowed; }

.chat-input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    gap: 0.6rem;
}

.chat-send-btn,
.chat-end-btn {
    font-family: var(--font-sans, sans-serif);
    font-size: 0.85rem;
    padding: 0.45rem 1.1rem;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-send-btn {
    background: var(--navy, #1B365D);
    color: white;
    border: 1px solid var(--navy, #1B365D);
}

.chat-send-btn:hover:not(:disabled) { background: #2A4570; }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-end-btn {
    background: transparent;
    color: var(--text-muted, #8B8279);
    border: 1px solid var(--border-light, rgba(0,0,0,0.15));
}

.chat-end-btn:hover:not(:disabled) {
    border-color: var(--text-muted, #8B8279);
    color: var(--text-secondary, #5C534A);
}

.chat-end-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-loading,
.chat-error {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted, #8B8279);
    font-style: italic;
    font-family: var(--font-serif, serif);
}

.chat-error { color: #991b1b; font-style: normal; }

/* ─── Mobile: hero becomes a top strip, content below ──── */
@media (max-width: 720px) {
    .chat-modal {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        flex-direction: column;
    }
    .chat-hero { flex: 0 0 92px; }
    .chat-hero-id { bottom: 0.6rem; }
    .chat-hero-id .chat-modal-name { font-size: 1.25rem; }
    #chat-companion-img { object-position: center 30%; }
}
