/* ==========================================================================
   Yapay Zeka Sohbet Widget'ı — Kastamonu Rehberi
   Renk paleti ve erişilebilirlik sitenin temasıyla uyumludur.
   ========================================================================== */

#ai-chat-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    font-family: var(--font-family, system-ui, sans-serif);
}

/* Yüzen buton */
.ai-chat-fab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--color-primary, #1b5e20);
    color: #fff;
    border: 0;
    padding: 12px 18px;
    border-radius: 999px;
    box-shadow: var(--shadow-md, 0 8px 24px rgba(0,0,0,.2));
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease;
}
.ai-chat-fab:hover { background: var(--color-primary-dark, #0d3f10); transform: translateY(-2px); }
.ai-chat-fab:focus-visible { outline: 3px solid var(--color-secondary, #e8a33d); outline-offset: 3px; }
.ai-chat-fab i { font-size: 18px; }

@media (max-width: 640px) {
    .ai-chat-fab-label { display: none; }
    .ai-chat-fab { padding: 14px; border-radius: 50%; }
}

/* Panel */
.ai-chat-panel {
    position: fixed;
    right: 20px;
    bottom: 84px;
    width: min(380px, calc(100vw - 40px));
    height: min(560px, calc(100vh - 120px));
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--color-border, #d9e2d9);
}
.ai-chat-panel[hidden] { display: none; }

.ai-chat-head {
    background: linear-gradient(135deg, var(--color-primary, #1b5e20), var(--color-primary-light, #4c8c4a));
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.ai-chat-head strong { font-size: 16px; display: block; }
.ai-chat-head small  { font-size: 12px; opacity: .9; }
.ai-chat-close {
    background: transparent; color: #fff; border: 0; cursor: pointer;
    width: 34px; height: 34px; border-radius: 50%;
}
.ai-chat-close:hover { background: rgba(255,255,255,.15); }
.ai-chat-close:focus-visible { outline: 2px solid var(--color-secondary, #e8a33d); outline-offset: 2px; }

/* Log */
.ai-chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: var(--color-cream, #faf7f0);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ai-msg { display: flex; }
.ai-msg-user { justify-content: flex-end; }
.ai-msg-assistant { justify-content: flex-start; }
.ai-msg-bubble {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14.5px;
    line-height: 1.45;
    word-wrap: break-word;
}
.ai-msg-user .ai-msg-bubble {
    background: var(--color-primary, #1b5e20);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-msg-assistant .ai-msg-bubble {
    background: #fff;
    color: var(--color-text, #263238);
    border: 1px solid var(--color-border, #d9e2d9);
    border-bottom-left-radius: 4px;
}
.ai-msg-assistant .ai-msg-bubble a { color: var(--color-accent, #0288d1); }

/* Yazıyor animasyonu */
.ai-typing .ai-msg-bubble { display: inline-flex; gap: 4px; padding: 12px 14px; }
.ai-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--color-muted, #5a6b5c);
    animation: ai-bounce 1.2s infinite ease-in-out;
}
.ai-dot:nth-child(2) { animation-delay: .15s; }
.ai-dot:nth-child(3) { animation-delay: .3s; }
@keyframes ai-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: .4; }
    40%           { transform: translateY(-6px); opacity: 1; }
}

/* Form */
.ai-chat-form {
    display: flex;
    gap: 6px;
    padding: 10px;
    border-top: 1px solid var(--color-border, #d9e2d9);
    background: #fff;
    align-items: center;
}
.ai-chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--color-border, #d9e2d9);
    border-radius: 10px;
    font-size: 14.5px;
    font-family: inherit;
    min-width: 0;
}
.ai-chat-input:focus { outline: 2px solid var(--color-primary, #1b5e20); outline-offset: 1px; }
.ai-chat-send {
    background: var(--color-primary, #1b5e20);
    color: #fff;
    border: 0;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    cursor: pointer;
}
.ai-chat-send:hover:not(:disabled) { background: var(--color-primary-dark, #0d3f10); }
.ai-chat-send:disabled,
.ai-chat-input:disabled { opacity: .6; cursor: not-allowed; }
.ai-chat-send:focus-visible { outline: 2px solid var(--color-secondary, #e8a33d); outline-offset: 2px; }

/* Honeypot — ekran okuyucudan & görünümden gizle */
.ai-chat-hp {
    position: absolute !important;
    left: -9999px !important;
    width: 1px; height: 1px;
    opacity: 0;
}

/* Flash mesajı */
.ai-flash {
    position: absolute;
    left: 12px; right: 12px;
    bottom: 64px;
    background: #b00020;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

/* Erişilebilirlik: yalnızca ekran okuyucu */
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* Yüksek kontrast modu uyumu */
body.contrast-high .ai-chat-fab,
body.contrast-high .ai-chat-send { background: #000; color: #ff0; border: 2px solid #ff0; }
body.contrast-high .ai-chat-panel { border: 2px solid #ff0; }
body.contrast-high .ai-msg-user .ai-msg-bubble { background: #000; color: #ff0; }
body.contrast-high .ai-msg-assistant .ai-msg-bubble { background: #ff0; color: #000; border-color: #000; }

/* Hareketi azaltılmış kullanıcılar için */
@media (prefers-reduced-motion: reduce) {
    .ai-chat-fab { transition: none; }
    .ai-dot { animation: none; }
}
