/* =========================================================================
   AI Assistant for Adventure Editor
   Sidebar panel + collapsible sections + chat log.
   ========================================================================= */

/* Widen sidebar so both nav and AI panel fit comfortably */
.editor-layout {
    grid-template-columns: 350px 1fr;
}

/* Sidebar sections (nav + AI) are collapsible */
.editor-sidebar-section {
    background: #1e212800;
    border: 0px solid var(--border-default);
    border-radius: 3px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

p.relation-view-subtitle {
    font-family: 'Crimson Pro';
}

.editor-sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.5rem;
    cursor: pointer;
    user-select: none;
    background: none;
    border-bottom: 1px solid var(--border-default);
    transition: background 0.2s;
}

.editor-sidebar-section-header:hover {
    background: rgba(212, 175, 55, 0.12);
}

.editor-sidebar-section-title {
    font-family: 'Cinzel', serif;
    color: var(--accent-gold);
    font-weight: 600;
    font-size: 0.9375rem;
}

.editor-sidebar-section-chevron {
    color: var(--accent-gold);
    transition: transform 0.2s;
    font-size: 0.875rem;
}

.editor-sidebar-section[data-collapsed="true"] .editor-sidebar-section-chevron {
    transform: rotate(-90deg);
}

.editor-sidebar-section[data-collapsed="true"] .editor-sidebar-section-body {
    display: none;
}

.editor-sidebar-section-body {
    padding: 0.75rem;
}

/* The outer .editor-sidebar wrapper no longer needs its own card styling,
   since each inner section is now its own card. Override the base rule. */
.editor-sidebar {
    background: transparent;
    border: none;
    padding: 0;
}

/* =========================================================================
   AI panel internals
   ========================================================================= */

.ai-sidebar-section {
    position: relative;
}

.ai-panel-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-unconfigured-hint {
    background: rgba(255, 193, 7, 0.08);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    line-height: 1.4;
}
.ai-unconfigured-hint a { color: var(--accent-gold); }

.ai-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.8125rem;
}

.ai-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.ai-model-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
}

.ai-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.ai-preset-btn {
    background: rgba(212, 175, 55, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.ai-preset-btn:hover {
    background: rgba(212, 175, 55, 0.18);
    border-color: var(--accent-gold);
}

.ai-chat-log {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    max-height: 420px;
    /*min-height: 120px;*/
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.45;
}

.ai-chat-empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8125rem;
    padding: 0.5rem 0;
    text-align: center;
}

.ai-msg {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
}

.ai-msg-user {
    background: rgba(100, 149, 237, 0.08);
    border-left: 2px solid rgba(100, 149, 237, 0.5);
}

.ai-msg-assistant {
    background: rgba(212, 175, 55, 0.06);
    border-left: 2px solid rgba(212, 175, 55, 0.5);
}

.ai-msg-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.ai-msg-content p {
    margin: 0 0 0.4rem 0;
}

.ai-msg-content p:last-child {
    margin-bottom: 0;
}

.ai-msg-content ul {
    margin: 0.25rem 0 0.5rem 1.2rem;
    padding: 0;
}

.ai-msg-content li {
    margin-bottom: 0.2rem;
}

.ai-msg-content code {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    font-size: 0.85em;
}

.ai-input-row {
    display: flex;
    gap: 0.4rem;
    align-items: stretch;
}

.ai-user-input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
    resize: vertical;
    font-family: 'Crimson Pro';
}

.ai-user-input:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.ai-send-btn {
    background: var(--accent-gold);
    color: #1a1a1a;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: opacity 0.15s;
}

.ai-send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ai-usage-bar {
    color: var(--text-muted);
    font-size: 0.7rem;
    text-align: right;
    padding-top: 0.2rem;
    min-height: 1em;
}

/* Typing indicator */
.ai-typing-dots {
    display: inline-flex;
    gap: 3px;
    vertical-align: middle;
}
.ai-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--accent-gold);
    border-radius: 50%;
    display: inline-block;
    animation: ai-bounce 1.2s infinite;
}
.ai-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ai-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* Mobile: stack editor sidebar above content; already handled by existing
   @media (max-width: 768px), but narrow the AI panel's chat log so it doesn't
   dominate the screen. */
@media (max-width: 768px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
    .ai-chat-log {
        max-height: 260px;
    }
}
