/* ==============================================================================
   AYAYDER AI - AKILLI BİLGİ VE MEVZUAT ASİSTANI STİLLERİ (AI CHAT CSS)
   ============================================================================== */

:root {
    --ai-primary: #0284c7;
    --ai-primary-hover: #0369a1;
    --ai-primary-glow: rgba(2, 132, 199, 0.35);
    --ai-bg-dark: #0b1329;
    --ai-bg-card: #152238;
    --ai-bg-bubble-bot: #1e293b;
    --ai-bg-bubble-user: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    --ai-border: rgba(255, 255, 255, 0.1);
    --ai-border-accent: rgba(56, 189, 248, 0.25);
    --ai-text-main: #f8fafc;
    --ai-text-muted: #94a3b8;
    --ai-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* 1. YÜZEN SOHBET BUTONU (TRIGGER) */
.ai-widget-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99990;
    display: flex;
    align-items: center;
}

.ai-floating-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    border: 1px solid var(--ai-border-accent);
    border-radius: 999px;
    box-shadow: 0 10px 25px -5px rgba(2, 132, 199, 0.4), 0 0 0 1px rgba(56, 189, 248, 0.2);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    outline: none;
}

.ai-floating-trigger:hover {
    transform: translateY(-3px) scale(1.02);
    border-color: #38bdf8;
    box-shadow: 0 14px 30px -4px rgba(2, 132, 199, 0.55), 0 0 20px rgba(56, 189, 248, 0.4);
}

.ai-floating-trigger:active {
    transform: translateY(-1px) scale(0.98);
}

.ai-trigger-pulse {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #10b981;
    border: 2px solid #0f172a;
    border-radius: 50%;
    animation: aiPulse 2s infinite;
}

@keyframes aiPulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.ai-trigger-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #38bdf8;
    filter: drop-shadow(0 2px 4px rgba(2, 132, 199, 0.4));
}

.ai-trigger-badge {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    background: rgba(2, 132, 199, 0.25);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 3px 8px;
    border-radius: 12px;
    letter-spacing: 0.04em;
}

/* 2. SOHBET PENCERESİ (CHAT WINDOW) */
.ai-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 420px;
    height: 620px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 120px);
    background: var(--ai-bg-card);
    border: 1px solid var(--ai-border-accent);
    border-radius: 20px;
    box-shadow: var(--ai-shadow);
    display: flex;
    flex-direction: column;
    z-index: 99995;
    overflow: hidden;
    animation: aiSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

@keyframes aiSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 3. PENCERE ÜST BAŞLIĞI (HEADER) */
.ai-chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #0b1329 0%, #111e38 100%);
    border-bottom: 1px solid var(--ai-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.ai-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ai-avatar-wrap {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ai-border-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-avatar-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.ai-online-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid #0b1329;
}

.ai-header-titles {
    min-width: 0;
}

.ai-header-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-header-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0;
    letter-spacing: -0.01em;
}

.ai-header-tag {
    font-size: 0.65rem;
    font-weight: 800;
    background: rgba(2, 132, 199, 0.2);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.25);
    padding: 2px 6px;
    border-radius: 6px;
    text-transform: uppercase;
}

.ai-header-status {
    font-size: 0.78rem;
    color: var(--ai-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.ai-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}

.ai-btn-icon:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border-color: var(--ai-border);
}

/* 4. MESAJ LİSTESİ VE GÖVDE (BODY) */
.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #0d1527;
    scroll-behavior: smooth;
}

.ai-messages-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-message-row {
    display: flex;
    gap: 12px;
    max-width: 90%;
    animation: aiMsgFade 0.25s ease-out;
}

@keyframes aiMsgFade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-msg-bot {
    align-self: flex-start;
}

.ai-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: #1e293b;
    border: 1px solid var(--ai-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.ai-msg-avatar img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.ai-msg-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.ai-msg-user .ai-msg-content-wrapper {
    align-items: flex-end;
}

.ai-msg-author {
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    padding-left: 2px;
}

.ai-msg-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.55;
    word-break: break-word;
    color: var(--ai-text-main);
}

.ai-msg-bot .ai-msg-bubble {
    background: var(--ai-bg-bubble-bot);
    border: 1px solid var(--ai-border);
    border-top-left-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ai-msg-user .ai-msg-bubble {
    background: var(--ai-bg-bubble-user);
    color: #ffffff;
    border-top-right-radius: 4px;
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.35);
}

.ai-msg-time {
    font-size: 0.68rem;
    color: #64748b;
    padding: 0 4px;
}

/* 5. DOĞRULANMIŞ KAYNAK KARTLARI (VERIFIED SOURCES) */
.ai-sources-container {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-sources-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    font-weight: 800;
    color: #38bdf8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    user-select: none;
}

.ai-source-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--ai-border);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
}

.ai-source-card:hover {
    border-color: #38bdf8;
    background: rgba(2, 132, 199, 0.12);
    transform: translateX(2px);
}

.ai-source-title {
    font-weight: 700;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-source-meta {
    font-size: 0.72rem;
    color: #94a3b8;
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.ai-source-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    font-weight: 700;
    white-space: nowrap;
}

/* 6. GERİ BİLDİRİM (FEEDBACK LIKE/DISLIKE) */
.ai-msg-feedback-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.ai-feedback-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #64748b;
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 0.75rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.18s;
}

.ai-feedback-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
}

.ai-feedback-btn.active-like {
    color: #10b981;
    background: rgba(16, 185, 129, 0.15);
}

.ai-feedback-btn.active-dislike {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

/* 7. ÖRNEK SORULAR (SUGGESTIONS) */
.ai-suggestions-box {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-suggestions-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
}

.ai-suggestions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.ai-suggestion-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--ai-border);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #cbd5e1;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    outline: none;
}

.ai-suggestion-btn:hover {
    background: rgba(2, 132, 199, 0.15);
    border-color: #38bdf8;
    color: #ffffff;
    transform: translateY(-2px);
}

/* 8. YAZIYOR GÖSTERGESİ (TYPING INDICATOR) */
.ai-typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    animation: aiMsgFade 0.2s ease-out;
}

.ai-typing-bubble {
    background: var(--ai-bg-bubble-bot);
    border: 1px solid var(--ai-border);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #38bdf8;
    animation: aiDotBounce 1.4s infinite ease-in-out both;
}

.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes aiDotBounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.ai-typing-text {
    font-size: 0.76rem;
    color: #94a3b8;
    margin-left: 4px;
}

/* 9. HATA BANDI (ERROR BAR) */
.ai-chat-error-bar {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.8rem;
    color: #fca5a5;
}

.ai-retry-btn {
    background: #ef4444;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

/* 10. GİRİŞ ALANI (FOOTER) */
.ai-chat-footer {
    padding: 14px 16px;
    background: #090e1a;
    border-top: 1px solid var(--ai-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.ai-input-wrap {
    position: relative;
    display: flex;
    align-items: flex-end;
    background: #152238;
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    padding: 6px 10px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-input-wrap:focus-within {
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25);
}

.ai-chat-textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: #ffffff;
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
    max-height: 120px;
    padding: 6px 8px;
    outline: none;
    line-height: 1.45;
}

.ai-chat-textarea::placeholder {
    color: #64748b;
}

.ai-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--ai-primary);
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-bottom: 2px;
    outline: none;
}

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

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

.ai-footer-disclaimer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.68rem;
    color: #64748b;
    padding: 0 4px;
}

/* 11. KAYNAK DETAY MODALI */
.ai-source-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(8px);
}

.ai-source-modal {
    background: #111e38;
    border: 1px solid var(--ai-border-accent);
    border-radius: 16px;
    width: 600px;
    max-width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    animation: aiSlideUp 0.25s ease-out;
}

.ai-source-modal-header {
    padding: 16px 20px;
    background: #0b1329;
    border-bottom: 1px solid var(--ai-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-source-modal-title {
    font-size: 1rem;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-source-modal-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s;
}

.ai-source-modal-close:hover {
    color: #ffffff;
}

.ai-source-modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-source-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--ai-border);
    border-radius: 10px;
    padding: 14px;
}

.ai-source-meta-item {
    font-size: 0.8rem;
}

.ai-source-meta-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
}

.ai-source-meta-value {
    color: #ffffff;
    font-weight: 600;
    margin-top: 2px;
}

.ai-source-content-box {
    background: #0b1329;
    border: 1px solid var(--ai-border);
    border-radius: 10px;
    padding: 16px;
}

.ai-source-content-title {
    font-size: 0.78rem;
    font-weight: 800;
    color: #38bdf8;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.ai-source-content-text {
    font-size: 0.88rem;
    line-height: 1.65;
    color: #e2e8f0;
    white-space: pre-wrap;
}

/* 12. MOBİL UYUMLULUK */
@media (max-width: 640px) {
    .ai-chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .ai-floating-trigger {
        padding: 10px 16px;
    }

    .ai-trigger-badge {
        display: none;
    }

    .ai-suggestions-grid {
        grid-template-columns: 1fr;
    }
}
