/* core_app/static/css/chat/chatbot.css
 * Lila Chat Base Styles — 2026 Sidebar ile uyumlu
 * Variables, mesaj balonları, input, typing indicator, vb.
 */

/* Variables - Lila Branding (Master Strategy v5.0) */
:root {
    /* Map to Global Lila Variables if available, else fallback */
    --ai-primary: var(--lila-primary, #a78bfa);
    /* Lila (Soft Purple) */
    --ai-primary-hover: var(--lila-primary-hover, #8b5cf6);
    --ai-accent: var(--lila-secondary, #38bdf8);
    /* Neon Blue-ish */

    --ai-bg: var(--lila-glass-bg, rgba(255, 255, 255, 0.90));
    /* Glass */
    --ai-border: var(--lila-glass-border, rgba(255, 255, 255, 0.6));
    --ai-text: var(--lila-text-primary, #334155);
    --ai-text-light: var(--lila-text-secondary, #64748b);
    --ai-shadow: var(--lila-glass-shadow, 0 10px 40px -10px rgba(139, 92, 246, 0.15));
    /* Purple shadow */

    --ai-radius: var(--lila-radius-lg, 24px);

    --ai-msg-user-bg: var(--lila-primary, #8b5cf6);
    /* Lila Dark */
    --ai-msg-user-text: #ffffff;
    --ai-msg-model-bg: var(--lila-bg-secondary, #f8fafc);
    --ai-msg-model-text: var(--lila-text-primary, #334155);
}

/* [2026] Eski popup/dock stilleri kaldırıldı — lila_widget_2026 sidebar kullanıyor.
   Orb sphere/core: lila_orb.css tanımlıyor. */

/* Body */
.ai-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Messages */
.ai-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message-user {
    align-self: flex-end;
    background: var(--ai-msg-user-bg);
    color: var(--ai-msg-user-text);
    border-bottom-right-radius: 4px;
}

.ai-message-model {
    align-self: flex-start;
    background: var(--ai-msg-model-bg);
    color: var(--ai-msg-model-text);
    border-bottom-left-radius: 4px;
}

/* Chips */
.ai-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.ai-chip {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-2026, 20px);
    padding: 6px 12px;
    font-size: 0.8rem;
    color: var(--ai-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.ai-chip:hover {
    background: #eef2ff;
    border-color: var(--ai-primary);
}

/* Footer */
.ai-footer {
    padding: 16px;
    background: rgba(255, 255, 255, 0.8);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.ai-input-wrapper {
    display: flex;
    gap: 10px;
    background: #ffffff;
    padding: 8px 12px;
    border-radius: var(--radius-2026-btn, 14px);
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-soft, 0 12px 36px rgba(15, 23, 42, 0.03));
    transition: border 0.2s;
}

.ai-input-wrapper:focus-within {
    /* Tıklayınca mor çizgi gösterme - kullanıcı isteği */
    border-color: #e2e8f0;
    box-shadow: var(--shadow-soft, 0 12px 36px rgba(15, 23, 42, 0.03));
}

#chat-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.95rem;
    background: transparent;
}

/* Fix Send Button (Specific Fixes) */
.ai-send-btn {
    background: var(--ai-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;

    /* FIXES */
    opacity: 1 !important;
    pointer-events: auto !important;
}

.ai-send-btn svg {
    pointer-events: none;
    /* Crucial: Let click pass to button */
}

.ai-send-btn:hover {
    transform: scale(1.1);
    background: var(--ai-primary-hover);
}

.ai-footer-note {
    text-align: center;
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 8px;
}

/* ==========================================================================
   [2026-01] TYPING INDICATOR - Lila is thinking...
   ========================================================================== */

.lila-typing-indicator {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lila-typing-indicator .typing-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-soft, 0 12px 36px rgba(15, 23, 42, 0.03));
}

.lila-typing-indicator .typing-avatar img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.lila-typing-indicator .typing-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--ai-msg-model-bg, #f8fafc);
    padding: 12px 20px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-soft, 0 12px 36px rgba(15, 23, 42, 0.03));
}

.lila-typing-indicator .typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.lila-typing-indicator .typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ai-primary, #a78bfa);
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.lila-typing-indicator .typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.lila-typing-indicator .typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.lila-typing-indicator .typing-dots span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.lila-typing-indicator .typing-text {
    font-size: 0.85rem;
    color: var(--ai-text-light, #64748b);
    font-style: italic;
}

/* Pulse glow effect on avatar */
.lila-typing-indicator .typing-avatar::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    animation: pulseGlow 2s infinite;
    z-index: -1;
}

@keyframes pulseGlow {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) and (min-width: 99999px) {
    .lila-typing-indicator .typing-content {
        background: rgba(30, 41, 59, 0.8);
    }

    .lila-typing-indicator .typing-text {
        color: rgba(255, 255, 255, 0.7);
    }
}

/* ============================================
   [2026-01] REGENERATE BUTTON & ANIMATION
   ============================================ */

/* Regenerate button specific styles */
.lila-regenerate-btn {
    transition: all 0.2s ease !important;
}

.lila-regenerate-btn:hover {
    color: #f59e0b !important;
    background: rgba(245, 158, 11, 0.1) !important;
    transform: rotate(15deg);
}

.lila-regenerate-btn:active {
    transform: rotate(180deg);
}

/* Spin animation for loading state */
@keyframes lila-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.lila-spin {
    animation: lila-spin 1s linear infinite;
}

/* Regenerating message state */
.lila-regenerating {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    color: var(--ai-text-light, #64748b);
    font-style: italic;
    font-size: 14px;
}

.lila-regenerating::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid #f59e0b;
    border-top-color: transparent;
    border-radius: 50%;
    animation: lila-spin 0.8s linear infinite;
}

/* Regeneration count badge */
.lila-regeneration-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: #94a3b8;
    margin-top: 6px;
    padding: 2px 8px;
    background: rgba(245, 158, 11, 0.08);
    border-radius: var(--radius-2026, 20px);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Action button container enhancements */
/* [FIX 2026-01] Feedback butonları her zaman görünür olmalı */
.ai-msg-actions {
    opacity: 0.6;
    /* Varsayılan: yarı görünür */
    transition: opacity 0.2s ease;
}

.ai-message-model:hover .ai-msg-actions {
    opacity: 1;
    /* Hover'da tam görünür */
}

/* Feedback buttons should always be fully visible */
.ai-msg-actions .lila-feedback-container {
    opacity: 1 !important;
}

/* [2026-03] Lila Bilgilendirme notu kaldırıldı — artık gösterilmiyor */
.lila-transparency-note {
    display: none !important;
}

/* Always show on touch devices */
@media (hover: none) {
    .ai-msg-actions {
        opacity: 1;
    }
}

/* Dark mode for regenerate */
@media (prefers-color-scheme: dark) and (min-width: 99999px) {
    .lila-regenerating {
        color: rgba(255, 255, 255, 0.6);
    }

    .lila-regeneration-badge {
        background: rgba(245, 158, 11, 0.15);
        border-color: rgba(245, 158, 11, 0.3);
        color: #fbbf24;
    }
}

/* ==========================================================================
   [2026-02-26] P0 — SCROLL-TO-BOTTOM FAB
   ========================================================================== */

.lila-scroll-fab {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ai-primary, #8b5cf6);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft, 0 12px 36px rgba(15, 23, 42, 0.03));
    opacity: 0;
    transform: scale(0.8) translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.lila-scroll-fab.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

.lila-scroll-fab:hover {
    background: var(--ai-primary-hover, #285d77);
    transform: scale(1.08) translateY(0);
}

/* Unread badge */
.lila-scroll-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.lila-scroll-fab-badge.visible {
    display: flex;
}

/* ==========================================================================
   [2026-02-26] P0 — SUGGESTION CHIP TRAY (rendered by renderSuggestedQuestions)
   ========================================================================== */

.lila-suggestion-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(139, 92, 246, 0.3);
    background: rgba(139, 92, 246, 0.06);
    color: var(--ai-primary, #8b5cf6);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.lila-suggestion-chip:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--ai-primary, #8b5cf6);
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft, 0 12px 36px rgba(15, 23, 42, 0.03));
}

/* ==========================================================================
   [2026-02-26] P1 — DARK MODE (data-lila-theme="dark" kapsamı)
   ========================================================================== */

#lila-sidebar[data-lila-theme="dark"] {
    --ai-bg: rgba(15, 23, 42, 0.97);
    --ai-border: rgba(255, 255, 255, 0.08);
    --ai-text: #e2e8f0;
    --ai-text-light: #94a3b8;
    --ai-msg-model-bg: rgba(30, 41, 59, 0.9);
    --ai-msg-model-text: #e2e8f0;
    --ai-msg-user-bg: #6d28d9;
    background: rgba(15, 23, 42, 0.97) !important;
    color: #e2e8f0 !important;
}

#lila-sidebar[data-lila-theme="dark"] .lila-bento-container,
#lila-sidebar[data-lila-theme="dark"] .lila-header,
#lila-sidebar[data-lila-theme="dark"] .lila-footer,
#lila-sidebar[data-lila-theme="dark"] .lila-status-bar {
    background: rgba(15, 23, 42, 0.95) !important;
    border-color: rgba(255, 255, 255, 0.07) !important;
    color: #e2e8f0 !important;
}

#lila-sidebar[data-lila-theme="dark"] .lila-dialogue {
    background: rgba(15, 23, 42, 0.9) !important;
}

#lila-sidebar[data-lila-theme="dark"] .ai-message-model {
    background: rgba(30, 41, 59, 0.9) !important;
    color: #e2e8f0 !important;
}

#lila-sidebar[data-lila-theme="dark"] .ai-input-wrapper {
    background: rgba(30, 41, 59, 0.95) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #e2e8f0;
}

#lila-sidebar[data-lila-theme="dark"] #ai-input {
    color: #e2e8f0 !important;
    background: transparent !important;
}

#lila-sidebar[data-lila-theme="dark"] #ai-input::placeholder {
    color: #64748b;
}

/* Dark toggle button */
.lila-dark-toggle {
    font-size: 1rem;
    line-height: 1;
    border: none;
    background: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
    transition: background 0.2s;
}

.lila-dark-toggle:hover {
    background: rgba(139, 92, 246, 0.1);
}

/* ==========================================================================
   [2026-02-26] P1 — CONTEXT CHIPS BAR
   ========================================================================== */

.lila-context-bar {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 14px;
    border-top: 1px solid rgba(139, 92, 246, 0.1);
    background: rgba(139, 92, 246, 0.03);
    min-height: 0;
    overflow: hidden;
    transition: all 0.25s ease;
}

.lila-context-bar.has-context {
    display: flex;
}

.lila-context-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-2026, 20px);
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    color: #285d77;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}

.lila-context-chip-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.lila-context-chip-close:hover {
    color: #ef4444;
}

/* ==========================================================================
   [2026-02-26] P1 — EDIT MESSAGE (user message inline edit)
   ========================================================================== */

.lila-edit-input {
    width: 100%;
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: var(--radius-2026, 20px);
    padding: 8px 10px;
    font-size: 0.88rem;
    resize: vertical;
    outline: none;
    background: #fff;
    color: #334155;
    min-height: 60px;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.08);
    transition: border-color 0.2s;
}

.lila-edit-input:focus {
    border-color: var(--ai-primary, #8b5cf6);
}

.lila-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    justify-content: flex-end;
}

.lila-edit-save-btn,
.lila-edit-cancel-btn {
    padding: 4px 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
}

.lila-edit-save-btn {
    background: var(--ai-primary, #8b5cf6);
    color: #fff;
}

.lila-edit-save-btn:hover {
    background: var(--ai-primary-hover, #285d77);
}

.lila-edit-cancel-btn {
    background: #f1f5f9;
    color: #64748b;
}

.lila-edit-cancel-btn:hover {
    background: #e2e8f0;
}

/* ==========================================================================
   [2026-02-26] P2 — STREAMING CURSOR CARET
   ========================================================================== */

@keyframes lila-caret-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.lila-stream-caret {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--ai-primary, #8b5cf6);
    margin-left: 2px;
    vertical-align: text-bottom;
    border-radius: 1px;
    animation: lila-caret-blink 0.8s ease-in-out infinite;
}

/* ==========================================================================
   [2026-02-26] P2 — CITATION HOVER POPUP
   ========================================================================== */

.lila-citation-popup {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: var(--radius-2026, 20px);
    padding: 10px 14px;
    box-shadow: var(--shadow-soft, 0 12px 36px rgba(15, 23, 42, 0.03));
    max-width: 280px;
    font-size: 0.78rem;
    line-height: 1.5;
    color: #334155;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.lila-citation-popup.visible {
    opacity: 1;
    transform: translateY(0);
}

.lila-citation-popup-title {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 3px;
    font-size: 0.8rem;
}

.lila-citation-popup-source {
    color: #285d77;
    font-size: 0.75rem;
}

/* Citation link hover zone */
.lila-citations a[data-citation-idx]:hover {
    text-decoration: underline;
    color: #6d28d9;
}

/* ==========================================================================
   [2026-02-26] P2 — EMPTY STATE CARDS
   ========================================================================== */

.lila-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
    gap: 12px;
    text-align: center;
    animation: fadeIn 0.4s ease;
}

.lila-empty-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ai-text, #334155);
}

.lila-empty-subtitle {
    font-size: 0.8rem;
    color: var(--ai-text-light, #64748b);
    max-width: 260px;
    line-height: 1.5;
}

.lila-starter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    max-width: 320px;
    margin-top: 4px;
}

.lila-starter-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 10px 12px;
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: var(--radius-2026, 20px);
    background: rgba(139, 92, 246, 0.04);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    font-size: 0.78rem;
}

.lila-starter-card:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.4);
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft, 0 12px 36px rgba(15, 23, 42, 0.03));
}

.lila-starter-icon {
    font-size: 1.2rem;
}

.lila-starter-label {
    font-weight: 600;
    color: var(--ai-text, #334155);
}

.lila-starter-hint {
    color: var(--ai-text-light, #64748b);
    font-size: 0.72rem;
}

/* ==========================================================================
   [2026-02-26] P2 — INTENT / BAĞLAM BADGE
   ========================================================================== */

.lila-intent-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    margin-bottom: 4px;
    border: 1px solid transparent;
    opacity: 0.85;
}

.lila-intent-badge--legal {
    background: rgba(109, 40, 217, 0.08);
    color: #6d28d9;
    border-color: rgba(109, 40, 217, 0.2);
}

.lila-intent-badge--financial {
    background: rgba(16, 185, 129, 0.08);
    color: #059669;
    border-color: rgba(16, 185, 129, 0.2);
}

.lila-intent-badge--technical {
    background: rgba(59, 130, 246, 0.08);
    color: #285d77;
    border-color: rgba(59, 130, 246, 0.2);
}

.lila-intent-badge--general {
    background: rgba(100, 116, 139, 0.08);
    color: #475569;
    border-color: rgba(100, 116, 139, 0.2);
}

/* ==========================================================================
   [2026-02-26] P3 — MESSAGE TIMESTAMP HOVER
   ========================================================================== */

.lila-msg-timestamp {
    position: absolute;
    bottom: -18px;
    right: 6px;
    font-size: 0.65rem;
    color: #94a3b8;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.9);
    padding: 1px 5px;
    border-radius: 4px;
    z-index: 2;
}

.ai-message {
    position: relative;
    /* Timestamp için gerekli */
}

.ai-message:hover .lila-msg-timestamp {
    opacity: 1;
}

/* ==========================================================================
   [2026-02-26] P3 — KARAKTER SAYACI
   ========================================================================== */

.lila-char-counter {
    position: absolute;
    bottom: 20px;
    right: 16px;
    font-size: 0.68rem;
    color: #94a3b8;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s;
    z-index: 5;
    background: rgba(255, 255, 255, 0.85);
    padding: 1px 5px;
    border-radius: 4px;
}

.lila-char-counter.visible {
    opacity: 1;
}

.lila-char-counter.warn {
    color: #f59e0b;
}

.lila-char-counter.danger {
    color: #ef4444;
    font-weight: 600;
}

/* ==========================================================================
   [2026-02-26] P3 — DRAG-TO-RESIZE PANEL HANDLE
   ========================================================================== */

.lila-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    z-index: 100;
    transition: background 0.2s;
    border-radius: 6px 0 0 6px;
}

.lila-resize-handle:hover,
.lila-resize-handle.dragging {
    background: rgba(139, 92, 246, 0.25);
}

/* ==========================================================================
   [2026-02-26] P3 — HATA KARTI (Error Card with Retry)
   ========================================================================== */

.lila-error-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-2026, 20px);
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.2);
    margin: 4px 0;
    font-size: 0.85rem;
    color: #b91c1c;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
}

.lila-error-card-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.lila-error-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lila-error-card-msg {
    color: #7f1d1d;
}

.lila-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    align-self: flex-start;
    padding: 4px 12px;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.9);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: background 0.2s, transform 0.15s;
}

.lila-retry-btn:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* ==========================================================================
   [2026-02-26] P1 — USER MESSAGE EDIT BUTTON
   ========================================================================== */

.user-msg-actions,
.lila-user-msg-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ai-message-user:hover .user-msg-actions,
.ai-message-user:hover .lila-user-msg-actions {
    opacity: 1;
}

.lila-edit-btn,
.lila-user-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.2s;
}

.lila-edit-btn:hover,
.lila-user-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.lila-action-btn-label {
    font-size: 0.7rem;
}

.lila-edited-label,
.lila-edited-label-inline {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.55);
    font-style: italic;
    align-self: center;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Lila Chatbot Cross-Platform
   iOS Safari · Android Chrome · Samsung · Tablet · Desktop
   ═══════════════════════════════════════════════════════════════ */

/* ── Mobil ≤768px ────────────────────────────────────────────── */
@media (max-width: 767.98px) {
    /* Mesaj balonları: daha geniş */
    .ai-message {
        max-width: 90%;
        font-size: 0.9rem;
        padding: 10px 14px;
    }

    /* Input alanı: mobilde daha yüksek */
    .ai-input-wrapper {
        min-height: 44px;
        padding: 6px 10px;
    }

    /* Gönder butonu: daha büyük */
    .ai-send-btn {
        width: 40px;
        height: 40px;
    }

    /* Footer: kompakt */
    .ai-footer {
        padding: 10px 12px;
    }

    /* Body: daha az padding */
    .ai-body {
        padding: 12px;
        gap: 12px;
    }

    /* Starter grid: tek sütun */
    .lila-starter-grid {
        grid-template-columns: 1fr;
        max-width: 100%;
    }

    /* Starter card: okunabilir */
    .lila-starter-card {
        padding: 12px 14px;
        font-size: 0.82rem;
    }

    /* Edit input: mobilde rahat */
    .lila-edit-input {
        font-size: 0.9rem;
        min-height: 50px;
    }

    /* Citation popup: mobilde daha geniş */
    .lila-citation-popup {
        max-width: min(280px, calc(100vw - 32px));
    }

    /* Error card: kompakt */
    .lila-error-card {
        padding: 10px 12px;
        font-size: 0.82rem;
    }

    /* Scroll FAB: daha büyük */
    .lila-scroll-fab {
        width: 44px;
        height: 44px;
    }

    /* Context bar: yatay scroll */
    .lila-context-bar {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .lila-context-bar::-webkit-scrollbar {
        display: none;
    }

    .lila-context-chip {
        flex-shrink: 0;
    }

    /* Suggestion chip: yatay scroll */
    .ai-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }

    .ai-chips::-webkit-scrollbar {
        display: none;
    }

    .ai-chip {
        flex-shrink: 0;
    }
}

/* ── Küçük Telefon ≤480px ────────────────────────────────────── */
@media (max-width: 480px) {
    .ai-message {
        max-width: 94%;
        font-size: 0.88rem;
        padding: 10px 12px;
        border-radius: 14px;
    }

    .ai-message-model {
        border-bottom-left-radius: 4px;
    }

    .ai-message-user {
        border-bottom-right-radius: 4px;
    }

    .lila-empty-state {
        padding: 16px 12px;
    }

    .lila-empty-title {
        font-size: 0.9rem;
    }

    .lila-empty-subtitle {
        font-size: 0.75rem;
    }

    .lila-starter-card {
        font-size: 0.78rem;
    }

    .ai-footer-note {
        font-size: 0.62rem;
    }
}

/* ── iPhone SE ≤390px ────────────────────────────────────────── */
@media (max-width: 390px) {
    .ai-message {
        max-width: 96%;
        font-size: 0.85rem;
        padding: 8px 10px;
    }

    .ai-body {
        padding: 8px 10px;
        gap: 10px;
    }

    .ai-footer {
        padding: 8px 10px;
    }

    .lila-typing-indicator {
        padding: 10px 12px;
        gap: 8px;
    }

    .lila-typing-indicator .typing-avatar {
        width: 30px;
        height: 30px;
    }

    .lila-typing-indicator .typing-content {
        padding: 8px 14px;
    }

    .lila-intent-badge {
        font-size: 0.62rem;
    }

    .ai-chip {
        font-size: 0.72rem;
        padding: 5px 10px;
    }
}

/* ── Touch Cihazlar ──────────────────────────────────────────── */
@media (pointer: coarse) {
    /* Minimum touch target: 44px */
    .ai-send-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .lila-scroll-fab {
        min-width: 44px;
        min-height: 44px;
    }

    .lila-retry-btn {
        min-height: 40px;
        padding: 8px 16px;
    }

    .lila-edit-save-btn,
    .lila-edit-cancel-btn {
        min-height: 40px;
        padding: 8px 16px;
    }

    .lila-context-chip-close {
        min-width: 28px;
        min-height: 28px;
    }

    .lila-regenerate-btn {
        min-width: 36px;
        min-height: 36px;
    }

    .lila-dark-toggle {
        min-width: 40px;
        min-height: 40px;
    }

    /* Hover efektleri devre dışı */
    .ai-chip:hover {
        transform: none;
    }

    .lila-starter-card:hover {
        transform: none;
        box-shadow: none;
    }

    .ai-send-btn:hover {
        transform: none;
    }

    .lila-scroll-fab:hover {
        transform: scale(1) translateY(0);
    }

    .lila-regenerate-btn:hover {
        transform: none;
    }

    .lila-retry-btn:hover {
        transform: none;
    }

    /* Feedback ve message actions: her zaman görünür */
    .ai-msg-actions {
        opacity: 1;
    }

    .user-msg-actions,
    .lila-user-msg-actions {
        opacity: 0.7;
    }

    /* Touch scroll optimizasyonu */
    .ai-body {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Scrollbar gizle */
    .ai-body::-webkit-scrollbar,
    .ai-chips::-webkit-scrollbar {
        display: none;
    }

    .ai-body {
        scrollbar-width: none;
    }
}

/* ── iOS Safe Area ───────────────────────────────────────────── */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 767.98px) {
        .ai-footer {
            padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        }

        /* iOS form zoom engelleme */
        #chat-input,
        #ai-input,
        .ai-input,
        .lila-edit-input {
            font-size: 16px !important;
        }
    }
}

/* ── Landscape Modu ──────────────────────────────────────────── */
@media (max-width: 900px) and (orientation: landscape) {
    .ai-body {
        padding: 8px 12px;
        gap: 8px;
    }

    .ai-message {
        max-width: 80%;
        padding: 8px 12px;
    }

    .ai-footer {
        padding: 6px 10px;
    }

    /* Starter grid: yatay */
    .lila-starter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .lila-empty-state {
        padding: 12px;
    }
}

/* ── Reduced Motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ai-message {
        animation: none !important;
    }

    .lila-typing-indicator {
        animation: none !important;
    }

    .lila-typing-indicator .typing-dots span {
        animation: none !important;
    }

    .lila-typing-indicator .typing-avatar::before {
        animation: none !important;
    }

    .lila-stream-caret {
        animation: none !important;
    }

    .lila-scroll-fab {
        transition: opacity 0.1s !important;
    }

    .lila-regenerating::before {
        animation: none !important;
    }

    .lila-spin {
        animation: none !important;
    }

    .lila-empty-state {
        animation: none !important;
    }

    .ai-chip,
    .lila-starter-card,
    .lila-edit-save-btn,
    .lila-edit-cancel-btn,
    .lila-retry-btn,
    .ai-send-btn,
    .lila-dark-toggle,
    .lila-context-chip-close {
        transition: none !important;
    }
}

/* ── Retina / HiDPI ──────────────────────────────────────────── */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .ai-message-model {
        border-width: 0.5px;
    }

    .ai-input-wrapper {
        border-width: 0.5px;
    }
}