/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   LOST iN Chat — City Guide Styles
   Modern conversational UI inspired by Claude.
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* ── Reset & base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f0f0f0;
    --surface: #ffffff;
    --text: #0d0d0d;
    --text-muted: #6b6b6b;
    --text-light: #999;
    --border: #e5e5e5;
    --accent: #1a1a1a;
    --accent-light: #f5f5f5;
    --user-bg: #1a1a1a;
    --user-text: #ffffff;
    --bot-bg: transparent;
    --bot-text: #0d0d0d;
    --success: #2d8a4e;
    --warning: #c47900;
    --error: #c44536;
    --panel-bg: #fafafa;
    --code-bg: #f5f5f5;
    --radius: 12px;
    --radius-lg: 24px;
    --content-width: 720px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    font-size: 16px;
    line-height: 1.6;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.btn:hover { background: var(--accent-light); color: var(--text); }

/* Send button — large round circle */
.btn-send {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    font-size: 20px;
}

.btn-send:hover { opacity: 0.85; }
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-toggle-panel.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ── Main layout ───────────────────────────────────────── */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Chat column ───────────────────────────────────────── */
.chat-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Welcome state: center everything vertically */
    justify-content: center;
}

/* When chat is active, revert to normal top-aligned column */
body.chat-active .chat-column {
    justify-content: flex-start;
}

.chat-messages {
    overflow-y: auto;
    padding: 24px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* In chat mode, messages area takes remaining space (pushes input to bottom) */
body.chat-active .chat-messages {
    flex: 1;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   WELCOME STATE — centered landing like Claude
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 20px;
    max-width: var(--content-width);
    margin: auto;
    width: 100%;
    gap: 8px;
}

/* Large serif greeting — matches Claude's Styrene/serif style */
.welcome-greeting {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-size: 36px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.welcome-sub {
    font-size: 16px;
    color: var(--text-muted);
    font-weight: 400;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   INPUT AREA — always pinned to bottom, big like Claude
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.chat-input-area {
    padding: 16px 20px 28px;
    background: var(--bg);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: var(--content-width);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 12px 12px 24px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.input-row:focus-within {
    border-color: var(--text-light);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

#chat-input {
    flex: 1;
    padding: 8px 0;
    border: none;
    font-size: 16px;
    outline: none;
    background: transparent;
    color: var(--text);
    font-family: inherit;
}

#chat-input::placeholder {
    color: var(--text-light);
}

/* Controls row — Reset + Analysis under the input */
.input-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
    padding: 0 4px;
    max-width: var(--content-width);
    width: 100%;
}

.input-controls .session-info {
    font-size: 11px;
    color: var(--text-light);
    margin-right: auto;
}

.input-controls .latency-display {
    font-size: 11px;
    color: var(--text-light);
    margin-right: auto;
}

/* ── Message bubbles ───────────────────────────────────── */
.message {
    display: flex;
    flex-direction: column;
    max-width: var(--content-width);
    width: 100%;
    align-self: center;
}

.message.user { align-items: flex-end; }
.message.assistant { align-items: flex-start; }

.message-bubble {
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    font-size: 16px;
    line-height: 1.65;
    word-wrap: break-word;
    max-width: 85%;
}

.message.user .message-bubble {
    background: var(--user-bg);
    color: var(--user-text);
    border-bottom-right-radius: 6px;
}

.message.assistant .message-bubble {
    background: var(--bot-bg);
    color: var(--bot-text);
    padding-left: 0;
    padding-right: 0;
    max-width: 100%;
    border-radius: 0;
}

/* ── Message metadata row ─────────────────────────────── */
.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-light);
}

.meta-tag {
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--accent-light);
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.meta-tag.city { color: var(--accent); }
.meta-tag.intent { color: var(--text-muted); }
.meta-tag.off-guide { background: #fff3cd; color: var(--warning); }
.meta-tag.violation { background: #fde8e6; color: var(--error); }

/* Feedback buttons */
.feedback-btns {
    display: flex;
    gap: 2px;
    margin-left: 8px;
}

.btn-feedback {
    border: none;
    background: none;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.15s;
    padding: 2px 4px;
}

.btn-feedback:hover { opacity: 0.8; }
.btn-feedback.selected { opacity: 1; }

.btn-view-analysis {
    border: none;
    background: none;
    color: var(--text-light);
    font-size: 11px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}
.btn-view-analysis:hover { color: var(--text-muted); }

/* ── Typing indicator ──────────────────────────────────── */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 16px 0;
    align-self: center;
    max-width: var(--content-width);
    width: 100%;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light);
    animation: typing 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
    30% { opacity: 1; transform: scale(1.15); }
}

/* ── Analysis panel ────────────────────────────────────── */
.analysis-panel {
    width: 420px;
    background: var(--panel-bg);
    border-left: 1px solid var(--border);
    display: none;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.analysis-panel.open { display: flex; }

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.panel-header h2 { font-size: 14px; font-weight: 600; }

.btn-close-panel {
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 4px;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    font-size: 13px;
}

.panel-placeholder {
    color: var(--text-light);
    text-align: center;
    padding: 40px 20px;
}

/* ── Analysis sections ─────────────────────────────────── */
.analysis-section { margin-bottom: 20px; }

.analysis-section h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.analysis-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
}

.analysis-row .label { color: var(--text-muted); }
.analysis-row .value { font-weight: 500; text-align: right; max-width: 60%; word-break: break-word; }

.chunk-item {
    padding: 8px 10px;
    margin-bottom: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
}

.chunk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chunk-score {
    font-weight: 600;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--accent-light);
}

.chunk-venue { font-weight: 600; font-size: 12px; }
.chunk-meta { font-size: 11px; color: var(--text-light); }
.chunk-text {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    max-height: 60px;
    overflow: hidden;
}

.violation-item {
    padding: 6px 8px;
    margin-bottom: 4px;
    background: #fde8e6;
    border-radius: var(--radius);
    font-size: 11px;
    color: var(--error);
}

.latency-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 11px;
}

.latency-label { width: 70px; color: var(--text-muted); text-align: right; }

.latency-bar-container {
    flex: 1;
    height: 14px;
    background: var(--accent-light);
    border-radius: 3px;
    overflow: hidden;
}

.latency-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s;
}

.latency-value { width: 50px; font-size: 11px; color: var(--text-muted); }

/* ── Venue links in response text ─────────────────────── */
/* Venue names are bold + underlined. Clicking opens the inline map panel. */
.venue-link {
    font-weight: 700;
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: var(--text-light);
    text-underline-offset: 2px;
    cursor: pointer;
    transition: text-decoration-color 0.15s;
}
.venue-link:hover { text-decoration-color: var(--text); }

.explore-link {
    font-size: 14px;
    color: var(--text);
    text-decoration: none;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: all 0.15s;
    white-space: nowrap;
}
.explore-link:hover {
    color: var(--text);
    border-color: var(--text-muted);
    background: var(--accent-light);
}
/* Bold city name inside explore link */
.explore-link strong { font-weight: 700; }

/* ── Top Five card ────────────────────────────────────── */
/* Shown below the chat response when query matches a Top Five category */
.top-five-card {
    margin: 8px 0 4px 0;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--accent-light);
    max-width: 420px;
}
.top-five-header {
    margin-bottom: 8px;
    font-size: 12px;
    letter-spacing: 0.5px;
}
.top-five-label {
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
}
.top-five-category {
    font-weight: 600;
    color: var(--text);
}
.top-five-list {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
    line-height: 1.6;
}
.top-five-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.top-five-map-btn {
    border: none;
    background: none;
    color: var(--text-light);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 6px;
    white-space: nowrap;
}
.top-five-map-btn:hover { color: var(--text); }
.top-five-pick strong {
    font-weight: 600;
}
.top-five-detail {
    color: var(--text-muted);
    font-style: italic;
}
.top-five-page {
    color: var(--text-light);
    font-size: 11px;
    margin-left: 4px;
}
.top-five-map-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.top-five-map-panel.open {
    max-height: 300px;
    margin-top: 10px;
}
.top-five-map {
    height: 250px;
    border-radius: 6px;
    background: var(--bg);
}

/* ── Map panel ────────────────────────────────────────── */
.map-toggle-btn {
    border: none;
    background: none;
    color: var(--text-light);
    font-size: 11px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}
.map-toggle-btn:hover { color: var(--text-muted); }

.map-panel {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    width: 100%;
    display: none;
}
.map-panel.open { display: block; }

.map-container { width: 100%; height: 280px; }

.venue-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.venue-list {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.venue-list-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    line-height: 1.4;
}

.venue-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.venue-info { flex: 1; min-width: 0; }
.venue-info-name { font-weight: 600; color: var(--text); }
.venue-info-neighborhood { font-size: 11px; color: var(--text-muted); }

.venue-links { display: flex; gap: 8px; margin-top: 2px; }

.venue-links a {
    font-size: 11px;
    color: var(--text-light);
    text-decoration: none;
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: all 0.15s;
}
.venue-links a:hover {
    color: var(--text);
    border-color: var(--text-muted);
    background: var(--accent-light);
}

.map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 280px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 900px) {
    .analysis-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        max-width: 400px;
        z-index: 100;
        box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    }
}

@media (max-width: 640px) {
    .chat-messages { padding: 16px 12px; }
    .chat-input-area { padding: 12px 12px 20px; }
    .welcome-greeting { font-size: 26px; }
    .welcome-sub { font-size: 14px; }
    .message-bubble { font-size: 15px; padding: 12px 16px; }
}

/* ── Embed mode (loaded in iframe on WP site) ──────────── */
body.embed-mode .session-info { display: none; }
body.embed-mode .btn-reset { display: none; }
