/* =====================================================================
 * Move AI Widget — sağ alt köşe sohbet asistanı
 * Bootstrap 5.3 + moc theme uyumlu (var(--moc-primary) kullanır)
 * ===================================================================== */

:root {
    --mai-primary: var(--moc-primary, #1B2B44);
    --mai-accent:  var(--moc-accent, #F37A24);
    --mai-bg:      #ffffff;
    --mai-user:    var(--moc-primary, #1B2B44);
    --mai-bot:     #f1f3f7;
    --mai-text:    #1f2937;
    --mai-muted:   #6b7280;
}

/* Toggle button (sağ alt köşe — büyük, dikkat çekici, nabız efektli) */
.mai-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 100px;
    height: 100px;
    background: var(--mai-primary);
    background-image: linear-gradient(135deg, var(--mai-primary), var(--moc-primary-2, #2A4A8D));
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 10px 32px rgba(27, 43, 68, 0.35);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .25s ease;
    font-size: 2.2rem;
}
.mai-toggle:hover { transform: scale(1.06); box-shadow: 0 14px 38px rgba(27,43,68,0.45); }
.mai-toggle .mai-toggle-close { display: none; }
.mai-toggle.open .mai-toggle-open  { display: none; }
.mai-toggle.open .mai-toggle-close { display: inline-block; font-size: 1.7rem; }
/* Dikkat çekme nabızı — sürekli yavaş halka çıkar */
.mai-toggle::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 3px solid var(--mai-primary);
    opacity: .55;
    animation: maiPulseRing 2.2s ease-out infinite;
    pointer-events: none;
}
.mai-toggle.open::before { display: none; }
@keyframes maiPulseRing {
    0%   { transform: scale(0.85); opacity: .7; }
    80%  { transform: scale(1.25); opacity: 0; }
    100% { transform: scale(1.25); opacity: 0; }
}

/* Hoşgeldin balonu (toggle'ın solunda kalsın ki sağdaki ekran kenarına dayanmasın) */
.mai-bubble {
    position: fixed;
    bottom: 140px;
    right: 24px;
    max-width: 240px;
    background: #fff;
    color: var(--mai-text);
    padding: 12px 16px;
    border-radius: 14px;
    box-shadow: 0 6px 22px rgba(0,0,0,0.12);
    font-size: .9rem;
    line-height: 1.4;
    z-index: 9997;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .3s ease, transform .3s ease;
    pointer-events: none;
}
.mai-bubble.show { opacity: 1; transform: translateY(0); pointer-events: auto; cursor: pointer; }
.mai-bubble:after {
    content: '';
    position: absolute;
    bottom: -6px; right: 22px;
    width: 14px; height: 14px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: 4px 4px 6px -2px rgba(0,0,0,0.06);
}
.mai-bubble .mai-bubble-close {
    position: absolute; top: 4px; right: 6px;
    background: transparent; border: 0; cursor: pointer; color: #999; font-size: 1rem; line-height: 1;
}

/* Chat penceresi */
.mai-window {
    position: fixed;
    bottom: 140px;
    right: 24px;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 130px);
    background: var(--mai-bg);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    border: 1px solid rgba(0,0,0,0.06);
}
.mai-window.open { display: flex; animation: maiFadeIn .25s ease; }

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

/* Header */
.mai-header {
    background: linear-gradient(135deg, var(--mai-primary), var(--moc-primary-2, #2A4A8D));
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.mai-avatar {
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}
.mai-header h6 { margin: 0; font-weight: 600; font-size: .95rem; }
.mai-header .mai-status { font-size: .75rem; opacity: .85; display: flex; align-items: center; gap: 6px; }
.mai-header .mai-status:before { content: ''; width: 8px; height: 8px; background: #4ade80; border-radius: 50%; box-shadow: 0 0 6px #4ade80; }
.mai-header .mai-action,
.mai-header .mai-close {
    background: transparent; border: 0; color: #fff; cursor: pointer; font-size: 1rem; opacity: .75;
    width: 28px; height: 28px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    transition: opacity .15s, background .15s;
    padding: 0;
}
.mai-header .mai-action { margin-left: auto; }
.mai-header .mai-action + .mai-action,
.mai-header .mai-action + .mai-close,
.mai-header .mai-close { margin-left: 4px; }
.mai-header .mai-close { font-size: 1.2rem; }
.mai-header .mai-action:hover,
.mai-header .mai-close:hover { opacity: 1; background: rgba(255,255,255,0.15); }

/* Mesaj alanı */
.mai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #fafbfd;
    scroll-behavior: smooth;
}
.mai-messages::-webkit-scrollbar { width: 6px; }
.mai-messages::-webkit-scrollbar-thumb { background: #d4d8df; border-radius: 3px; }

.mai-msg {
    margin-bottom: 12px;
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: .9rem;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.mai-msg-bot {
    background: var(--mai-bot);
    color: var(--mai-text);
    border-bottom-left-radius: 4px;
    margin-right: auto;
}
.mai-msg-user {
    background: var(--mai-user);
    color: #fff;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}
.mai-msg a { color: inherit; text-decoration: underline; font-weight: 600; }
.mai-msg-bot a { color: var(--mai-primary); }

/* WhatsApp CTA */
.mai-cta {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff !important;
    padding: 10px 16px;
    border-radius: 22px;
    text-decoration: none !important;
    font-weight: 600;
    font-size: .9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    transition: transform .15s ease;
    border: 0;
}
.mai-cta:hover { transform: translateY(-1px); }
.mai-cta-wrap { text-align: center; margin: 12px 0; }

/* Typing göstergesi */
.mai-typing {
    display: inline-flex;
    gap: 4px;
    padding: 12px 14px;
    background: var(--mai-bot);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.mai-typing span {
    width: 7px; height: 7px;
    background: var(--mai-muted);
    border-radius: 50%;
    animation: maiBlink 1.2s infinite;
}
.mai-typing span:nth-child(2) { animation-delay: .2s; }
.mai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes maiBlink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

/* Input alanı */
.mai-input-wrap {
    padding: 12px;
    background: #fff;
    border-top: 1px solid #eaecf0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.mai-input {
    flex: 1;
    border: 1px solid #d4d8df;
    border-radius: 22px;
    padding: 10px 14px;
    font-size: .9rem;
    outline: none;
    resize: none;
    max-height: 90px;
    line-height: 1.4;
    font-family: inherit;
    transition: border-color .15s;
}
.mai-input:focus { border-color: var(--mai-primary); }
.mai-send {
    background: var(--mai-primary);
    color: #fff;
    border: 0;
    width: 40px; height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
    font-size: 1rem;
}
.mai-send:hover { background: var(--moc-primary-dark, #0F1A2E); }
.mai-send:disabled { opacity: .5; cursor: not-allowed; }

.mai-footer-note {
    text-align: center;
    font-size: .7rem;
    color: var(--mai-muted);
    padding: 6px 12px;
    background: #fff;
}
.mai-footer-note a { color: var(--mai-muted); text-decoration: underline; }

/* Mobile */
@media (max-width: 640px) {
    .mai-toggle { bottom: 18px; right: 18px; width: 76px; height: 76px; font-size: 1.8rem; }
    .mai-toggle.open .mai-toggle-close { font-size: 1.4rem; }
    .mai-bubble { right: 18px; bottom: 106px; }
    .mai-window {
        left: 0; right: 0; bottom: 0; top: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh; /* dynamic viewport - klavye varken küçülür */
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }
    .mai-header { padding: 12px 14px; }
    .mai-input-wrap { padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    .mai-messages { padding: 12px; }
}

/* iOS Safari için input zoom önle (16px+ font size) */
.mai-input { font-size: 16px; }
@media (min-width: 641px) { .mai-input { font-size: .9rem; } }

/* =====================================================================
 * Quick action chips (cold start için)
 * ===================================================================== */
.mai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 12px;
}
.mai-chip {
    background: #fff;
    border: 1px solid #d4d8df;
    color: var(--mai-primary);
    padding: 7px 12px;
    border-radius: 18px;
    font-size: .82rem;
    cursor: pointer;
    transition: all .15s;
    line-height: 1.2;
}
.mai-chip:hover {
    background: var(--mai-primary);
    color: #fff;
    border-color: var(--mai-primary);
    transform: translateY(-1px);
}

/* =====================================================================
 * Lead capture form
 * ===================================================================== */
.mai-lead-form {
    background: linear-gradient(135deg, #fff8e6, #fff);
    border: 1px solid #fde68a;
    border-left: 4px solid #f59e0b;
    border-radius: 12px;
    padding: 14px;
    margin: 8px 0;
    animation: maiSlideIn .3s ease;
}
@keyframes maiSlideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.mai-lead-title {
    font-size: .88rem;
    font-weight: 600;
    color: var(--mai-text);
    margin-bottom: 10px;
}
.mai-lead-input {
    width: 100%;
    border: 1px solid #d4d8df;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 6px;
    font-size: .88rem;
    outline: none;
    box-sizing: border-box;
}
.mai-lead-input:focus { border-color: #f59e0b; }
.mai-lead-btn {
    flex: 1;
    border: 0;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: .85rem;
    cursor: pointer;
    font-weight: 600;
    transition: opacity .15s;
}
.mai-lead-submit {
    background: var(--mai-primary);
    color: #fff;
}
.mai-lead-skip {
    background: #f1f3f7;
    color: var(--mai-muted);
}
.mai-lead-btn:hover { opacity: .9; }

/* =====================================================================
 * Rating (thumbs up/down)
 * ===================================================================== */
.mai-rating {
    text-align: center;
    padding: 10px;
    background: #f8fafc;
    border-radius: 10px;
    margin: 10px 0;
}
.mai-rating small { display: block; color: var(--mai-muted); margin-bottom: 8px; font-size: .82rem; }
.mai-rating-btns {
    display: inline-flex;
    gap: 12px;
}
.mai-rating-btn {
    background: #fff;
    border: 1px solid #d4d8df;
    width: 38px; height: 38px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--mai-muted);
    transition: all .15s;
    font-size: 1.1rem;
}
.mai-rating-btn:hover {
    background: var(--mai-primary);
    color: #fff;
    border-color: var(--mai-primary);
    transform: scale(1.1);
}

/* =====================================================================
 * SEO Doktoru kartı (Mod 2)
 * ===================================================================== */
.mai-doktor-card {
    background: linear-gradient(135deg, #f8fafc, #fff);
    border: 1px solid #e2e8f0;
    border-left: 5px solid var(--mai-primary);
    border-radius: 12px;
    padding: 24px 28px;
    margin: 20px 0;
    box-shadow: 0 4px 16px rgba(27,43,68,0.06);
}
.mai-doktor-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px dashed #cbd5e0;
}
.mai-doktor-header .mai-doktor-icon {
    width: 44px; height: 44px;
    background: var(--mai-primary); color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}
.mai-doktor-header h3 { margin: 0; font-size: 1.1rem; font-weight: 700; color: var(--mai-primary); }
.mai-doktor-header small { color: var(--mai-muted); }
.mai-doktor-body { font-size: .94rem; line-height: 1.65; color: var(--mai-text); }
.mai-doktor-body h2, .mai-doktor-body h3 { color: var(--mai-primary); margin-top: 18px; }
.mai-doktor-body h2 { font-size: 1.1rem; }
.mai-doktor-body h3 { font-size: .98rem; }
.mai-doktor-loading { text-align: center; padding: 30px; color: var(--mai-muted); }

/* =====================================================================
 * Akademi (Blog AI) — Mod 3
 * ===================================================================== */
.mai-akademi-box {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin: 30px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}
.mai-akademi-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px;
}
.mai-akademi-header .icon {
    width: 36px; height: 36px;
    background: var(--mai-primary); color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.mai-akademi-header strong { color: var(--mai-primary); font-size: 1rem; }
.mai-akademi-header small { color: var(--mai-muted); display: block; font-size: .8rem; }
.mai-akademi-messages {
    max-height: 360px;
    overflow-y: auto;
    margin-bottom: 12px;
    padding: 6px 2px;
}
.mai-akademi-messages:empty:before {
    content: "Bu yazı hakkında sorun var mı? Veya kendi siten için nasıl uygulanır, sor 👇";
    display: block; color: var(--mai-muted); font-size: .9rem; padding: 12px 4px;
}
.mai-akademi-input-wrap { display: flex; gap: 8px; }
.mai-akademi-input-wrap .mai-input { flex: 1; border-radius: 10px; }
.mai-akademi-input-wrap .mai-send { border-radius: 10px; width: 44px; height: 44px; }
