/* ==========================================================================
   ANTI-GRAVITY V3.2 — PLAYGROUND MODULE
   Live Chat Interface, Split View, Message Bubbles, Streaming Cursor
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. PLAYGROUND CONTAINER (Full Height Split)
   -------------------------------------------------------------------------- */
.playground-container {
    display: flex;
    height: calc(100vh - var(--topbar-height) - 48px);
    gap: 0;
    background: var(--canvas-bg);
    border-radius: var(--radius-box);
    overflow: hidden;
    box-shadow: var(--shadow-v3);
}

/* --------------------------------------------------------------------------
   2. PLAYGROUND SIDEBAR (Persona Config Panel)
   -------------------------------------------------------------------------- */
.playground-sidebar {
    width: 280px;
    background: var(--surface-bg);
    border-right: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

.playground-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--hairline);
}

.playground-sidebar-header h3 {
    font-family: var(--font-display);
    font-size: 15px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.playground-sidebar-header h3 i {
    color: var(--accent-cyan);
    font-size: 13px;
}

/* --- Persona List --- */
.persona-select-list {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
}

.persona-select-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    text-align: left;
    width: 100%;
}

.persona-select-item:hover {
    background: var(--surface-card);
    color: #fff;
}

.persona-select-item.selected {
    background: var(--surface-card);
    color: var(--accent-cyan);
    box-shadow: var(--shadow-v3);
}

.persona-select-item .persona-mini-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-btn);
    background: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}

.persona-select-item-info {
    flex: 1;
    min-width: 0;
}

.persona-select-item-info span {
    display: block;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.persona-select-item-info small {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

/* --- Config Panel --- */
.playground-config-panel {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border-top: 1px solid var(--hairline);
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.config-item-label {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.config-item-value {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent-cyan);
}



/* --------------------------------------------------------------------------
   3. CHAT AREA
/* --------------------------------------------------------------------------
   3. CHAT AREA & MESSAGES STREAM
   -------------------------------------------------------------------------- */
.playground-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--canvas-bg);
}

/* --- Chat Messages --- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-thread-wrapper {
    max-width: 920px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* --- Welcome State --- */
.chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    padding: 60px 20px;
}

.chat-welcome i {
    font-size: 44px;
    margin-bottom: 16px;
    color: var(--accent-cyan);
    opacity: 0.8;
}

.chat-welcome h3 {
    font-family: var(--font-display);
    font-size: 20px;
    color: #f1f5f9;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.chat-welcome p {
    font-size: 13px;
    max-width: 380px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* --- Architectural Chat Turns --- */
.chat-turn {
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: fadeIn 0.2s ease-out;
}

.chat-turn.user {
    align-self: flex-end;
    max-width: 75%;
    align-items: flex-end;
}

.chat-turn.assistant {
    align-self: flex-start;
    max-width: 100%;
    width: 100%;
}

.chat-turn-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    padding: 0 4px;
}

.persona-turn-avatar {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-btn);
    background: var(--accent-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-display);
    flex-shrink: 0;
}

.persona-turn-name {
    color: #f1f5f9;
    font-weight: 600;
    font-family: var(--font-main);
}

.model-turn-badge {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--surface-card);
    color: var(--accent-cyan);
}

/* --- Message Bubbles --- */
.chat-bubble {
    border-radius: var(--radius-box);
    font-size: 13.5px;
    line-height: 1.65;
    word-break: break-word;
    border: 0;
}

.chat-bubble.user {
    background: #0369a1;
    color: #f8fafc;
    padding: 12px 18px;
    border-bottom-right-radius: 2px;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.25);
    white-space: pre-wrap;
}

.chat-bubble.assistant {
    background: var(--surface-card);
    color: var(--text-primary);
    padding: 18px 22px;
    border-bottom-left-radius: 2px;
    box-shadow: var(--shadow-v3);
}

/* --- Rich Markdown Content inside Assistant Bubble --- */
.chat-markdown {
    line-height: 1.7;
    color: #cbd5e1;
}

.chat-markdown h1,
.chat-markdown h2,
.chat-markdown h3,
.chat-markdown h4 {
    font-family: var(--font-main);
    font-weight: 600;
    color: #f8fafc;
    margin: 16px 0 8px 0;
}

.chat-markdown h1:first-child,
.chat-markdown h2:first-child,
.chat-markdown h3:first-child,
.chat-markdown h4:first-child {
    margin-top: 0;
}

.chat-markdown h1 { font-size: 17px; border-bottom: 1px solid var(--hairline); padding-bottom: 6px; }
.chat-markdown h2 { font-size: 15px; border-bottom: 1px solid var(--hairline); padding-bottom: 4px; }
.chat-markdown h3 { font-size: 14px; }
.chat-markdown h4 { font-size: 13px; }

.chat-markdown p {
    margin: 0 0 12px 0;
    color: #cbd5e1;
}

.chat-markdown p:last-child {
    margin-bottom: 0;
}

.chat-markdown ul,
.chat-markdown ol {
    margin: 8px 0 14px 22px;
    padding: 0;
    color: #cbd5e1;
}

.chat-markdown li {
    margin-bottom: 5px;
}

.chat-markdown blockquote {
    margin: 12px 0;
    padding: 8px 14px;
    background: var(--surface-bg);
    border-left: 3px solid var(--accent-cyan);
    border-radius: 0 4px 4px 0;
    color: #94a3b8;
    font-style: italic;
}

.chat-markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 12px;
}

.chat-markdown th {
    background: var(--surface-bg);
    color: var(--accent-cyan);
    font-weight: 600;
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--hairline);
}

.chat-markdown td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--hairline);
    color: #cbd5e1;
}

.chat-markdown code {
    background: #090e1a;
    color: var(--accent-cyan);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    border: 0;
}

/* --- Code Block Wrapper & Toolbar --- */
.code-block-wrapper {
    margin: 14px 0;
    border-radius: var(--radius-box);
    overflow: hidden;
    background: #090e1a;
    box-shadow: var(--shadow-v3);
    border: 0;
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    background: #070b13;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.code-block-lang {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.5px;
}

.code-block-copy-btn {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--font-main);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: var(--radius-btn);
    transition: all var(--transition-fast);
}

.code-block-copy-btn:hover {
    background: var(--surface-hover);
    color: #fff;
}

.code-block-copy-btn:active {
    transform: translateY(1px);
}

.code-block-copy-btn.copied {
    color: var(--accent-green);
}

.code-block-wrapper pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
    color: #e2e8f0;
    background: transparent;
}

.code-block-wrapper pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* --- Action Footer for Assistant Bubble --- */
.chat-bubble-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-actions-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-action-btn {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    font-size: 11px;
    padding: 4px 8px;
    border-radius: var(--radius-btn);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all var(--transition-fast);
}

.chat-action-btn:hover {
    background: var(--surface-hover);
    color: #fff;
}

.chat-action-btn:active {
    transform: translateY(1px);
}

.chat-metrics-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.metric-tag {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--surface-bg);
}

/* --- Thinking Indicator Card --- */
.streaming-thinking-card {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--surface-bg);
    border-radius: var(--radius-btn);
    font-size: 12px;
    color: var(--text-muted);
    box-shadow: var(--shadow-v3);
}

.thinking-pulse-icon {
    color: var(--accent-cyan);
    font-size: 13px;
}

.thinking-timer {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent-cyan);
    margin-left: 4px;
}

/* --- Typing Cursor --- */
.typing-cursor {
    display: inline-block;
    width: 6px;
    height: 14px;
    background: var(--accent-cyan);
    margin-left: 4px;
    vertical-align: text-bottom;
    animation: blink-cursor 0.7s step-end infinite;
    border-radius: 1px;
}

/* --------------------------------------------------------------------------
   4. CHAT INPUT BAR
   -------------------------------------------------------------------------- */
.chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid var(--hairline);
    background: var(--surface-bg);
}

.chat-input {
    flex: 1;
    background: var(--surface-card);
    border: 0;
    padding: 12px 16px;
    border-radius: var(--radius-btn);
    color: #fff;
    font-family: var(--font-main);
    font-size: 13px;
    outline: none;
    resize: none;
    max-height: 120px;
    min-height: 42px;
    line-height: 1.5;
    transition: box-shadow var(--transition-base);
}

.chat-input:focus {
    box-shadow: var(--focus-ring);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-send-btn {
    background: var(--accent-blue);
    border: 0;
    color: #fff;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-btn);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: var(--accent-blue-hover);
}

.chat-send-btn:active {
    transform: translateY(1px);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* --------------------------------------------------------------------------
   5. RESPONSIVE (Mobile)
   -------------------------------------------------------------------------- */
@media (max-width: 960px) {
    .playground-container {
        flex-direction: column;
        height: calc(100vh - var(--topbar-height) - 70px);
    }

    .playground-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: 0;
        border-bottom: 1px solid var(--hairline);
    }

    .playground-config-panel {
        display: none;
    }

    .persona-select-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px;
        gap: 6px;
    }

    .persona-select-item {
        flex-shrink: 0;
        min-width: auto;
    }

    .chat-bubble {
        max-width: 90%;
    }
}
