/* ============================================================
   DataLimora — AIWorker.css
   Owns: #ai section — chat thread, input row, translate overlay
   Full-width / full-height Claude-style chat
   ============================================================ */

#ai {
    width: 100%;
    height: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ─── Panel container ────────────────────────────────────── */
.ai-panel {
    background: var(--app-bg);
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

/* ─── Header ─────────────────────────────────────────────── */
.ai-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-bg);
    flex-shrink: 0;
    height: 52px;
}

.ai-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.ai-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #cc785c 0%, #d4956a 50%, #c96a3e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
}

.ai-title {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.ai-subtitle {
    font-size: .75rem;
    color: var(--text-secondary);
    margin-top: 1px;
}

.ai-header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.ai-header-actions .btn-ghost {
    font-size: .75rem;
    padding: 4px 10px;
    border-radius: 6px;
}

/* ─── Chat thread ────────────────────────────────────────── */
.ai-chat {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
    scroll-behavior: smooth;
    background: var(--app-bg);
}

.ai-chat::-webkit-scrollbar { width: 5px; }
.ai-chat::-webkit-scrollbar-track { background: transparent; }
.ai-chat::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

/* ─── Message rows ───────────────────────────────────────── */
.ai-message-row {
    display: flex;
    gap: 12px;
    padding: 6px 24px;
    animation: msg-appear 0.18s ease;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.ai-message-row--user {
    flex-direction: row-reverse;
}

@keyframes msg-appear {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Avatars ────────────────────────────────────────────── */
.ai-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    margin-top: 2px;
}

.ai-avatar--assistant {
    background: linear-gradient(135deg, #cc785c 0%, #d4956a 50%, #c96a3e 100%);
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

.ai-avatar--user {
    background: var(--accent-color);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

/* ─── Bubble ─────────────────────────────────────────────── */
.ai-bubble {
    max-width: 78%;
    border-radius: 16px;
    padding: 10px 14px;
    font-size: .875rem;
    line-height: 1.65;
}

.ai-bubble--assistant {
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-top-left-radius: 4px;
}

.ai-bubble--user {
    background: var(--accent-color);
    color: #fff;
    border-top-right-radius: 4px;
}

.ai-bubble p { margin: 0; }
.ai-bubble p + p { margin-top: 6px; }

/* ─── File context badge ─────────────────────────────────── */
.ai-file-context {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .7rem;
    color: rgba(255,255,255,.85);
    background: rgba(0,0,0,.15);
    border-radius: 6px;
    padding: 3px 8px;
    margin-bottom: 6px;
    width: fit-content;
}

/* ─── Typing indicator ───────────────────────────────────── */
.ai-loading .ai-bubble--assistant {
    padding: 12px 14px;
}

.ai-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    height: 16px;
}
.ai-dots span {
    display: block;
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: dot-bounce 1.2s ease-in-out infinite;
}
.ai-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
    40%            { transform: translateY(-5px); opacity: 1; }
}

/* ─── Input area ─────────────────────────────────────────── */
.ai-input-area {
    border-top: 1px solid var(--border-color);
    background: var(--card-bg);
    flex-shrink: 0;
    padding: 12px 24px 16px;
}

.ai-input-area-inner {
    max-width: 900px;
    margin: 0 auto;
    background: var(--card-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 0;
    transition: border-color .15s;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.ai-input-area-inner:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(45,192,142,.12);
}

/* File context pill row */
.ai-attached-files {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px 0;
}
.ai-attached-files.has-files {
    display: flex;
}
.ai-file-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 3px 10px 3px 8px;
    font-size: .72rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.ai-file-pill-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    font-size: .8rem;
    line-height: 1;
    display: flex;
    align-items: center;
    opacity: .6;
}
.ai-file-pill-remove:hover { opacity: 1; color: #e74c3c; }

.ai-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 10px 8px 14px;
}

.ai-input-textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: .9rem;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    outline: none;
    padding: 4px 0;
    min-height: 28px;
    max-height: 140px;
    overflow-y: auto;
}

.ai-input-textarea::placeholder {
    color: var(--text-secondary);
    opacity: .7;
}

.ai-input-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Attach files button */
.ai-attach-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 15px;
    transition: background .15s, border-color .15s, color .15s;
}
.ai-attach-btn:hover {
    background: var(--hover-bg);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Send button */
.ai-send-btn {
    background: var(--accent-color);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    font-size: 16px;
    transition: background .15s, transform .1s;
    flex-shrink: 0;
}
.ai-send-btn:hover { background: var(--accent-hover, #27ae78); }
.ai-send-btn:active { transform: scale(.94); }
.ai-send-btn:disabled { opacity: .45; cursor: default; }

/* Hint text */
.ai-input-hint {
    text-align: center;
    font-size: .68rem;
    color: var(--text-secondary);
    opacity: .6;
    padding: 0 0 2px;
}

/* Error banner */
#ai-error {
    margin: 0 24px 8px;
    max-width: 812px;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
}

/* ─── Project file picker popover ────────────────────────── */
.ai-file-picker {
    position: fixed;
    z-index: 999;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    min-width: 260px;
    max-width: 340px;
    overflow: hidden;
    animation: picker-appear .15s ease;
}
@keyframes picker-appear {
    from { opacity: 0; transform: translateY(6px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-fp-header {
    padding: 12px 16px 8px;
    font-size: .8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--border-color);
}

.ai-fp-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    max-height: 240px;
    overflow-y: auto;
}

.ai-fp-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    cursor: pointer;
    font-size: .875rem;
    color: var(--text-primary);
    transition: background .12s;
}
.ai-fp-item:hover { background: var(--hover-bg); }

.ai-fp-item-icon { font-size: 1rem; flex-shrink: 0; }

.ai-fp-item-info { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.ai-fp-item-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-fp-item-meta { font-size: .68rem; color: var(--text-secondary); }

.ai-fp-empty {
    padding: 20px 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: .8125rem;
}

/* ─── Translate overlay ──────────────────────────────────── */
.ai-translate-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 900;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.ai-translate-inner {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl, 16px);
    width: min(520px, 92vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.ai-translate-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    gap: var(--space-md);
}
.ai-translate-header h3 {
    flex: 1;
    font-size: .9375rem;
    font-weight: 700;
    margin: 0;
}
.ai-translate-header .btn-ghost {
    padding: 4px 8px;
    font-size: .8rem;
}

.ai-translate-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    font-size: .875rem;
    line-height: 1.65;
}

.ai-translate-actions {
    display: flex;
    gap: var(--space-sm);
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    align-items: center;
}
.ai-translate-actions .select-wrap { flex: 1; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
    .ai-message-row { padding: 4px 12px; }
    .ai-input-area { padding: 10px 12px 14px; }
    #ai-error { margin: 0 12px 8px; }
}