/* ==============================
   Canlı destek penceresi
   - Sayfa düzenine dokunmaz: kök boyutsuz, düğme ve pencere position: fixed.
   - Panelde (#moonPhaseBox varken, ≥768px) JS konumu ay fazı kartına göre verir:
     sağ kenar sağ panelin hemen solu, pencere sola doğru açılır ve karttan uzundur.
   ============================== */
.ab-support {
    --abs-primary: #136f63;
    --abs-primary-dark: #0e554c;
    --abs-accent: #e09f3e;
    --abs-bg: #ffffff;
    --abs-surface: #f4f7f6;
    --abs-border: #dde6e3;
    --abs-text: #1f2a28;
    --abs-muted: #6b7a76;
    --abs-radius: 16px;
    position: fixed;
    width: 0;
    height: 0;
    right: 0;
    bottom: 0;
    z-index: 1035;
    font-family: inherit;
}

/* --- Açma düğmesi --- */
.ab-support-launcher {
    position: fixed;
    right: 96px;
    bottom: 24px;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: var(--abs-primary);
    color: #fff;
    box-shadow: 0 6px 18px rgba(19, 111, 99, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease, opacity 0.15s ease;
}

.ab-support-launcher:hover {
    background: var(--abs-primary-dark);
    transform: translateY(-1px);
}

.ab-support-launcher:focus-visible,
.ab-support-icon-btn:focus-visible,
.ab-support-send:focus-visible,
.ab-support-chip:focus-visible,
.ab-support-handoff:focus-visible {
    outline: 3px solid rgba(224, 159, 62, 0.65);
    outline-offset: 2px;
}

.ab-support-launcher svg {
    width: 24px;
    height: 24px;
}

.ab-support-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #d63c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
}

.ab-support-badge[hidden] {
    display: none;
}

.ab-support.is-open .ab-support-launcher {
    opacity: 0;
    pointer-events: none;
}

/* Panelde ay fazı kartının köşesinde daha küçük */
.ab-support--anchored .ab-support-launcher {
    width: 40px;
    height: 40px;
}

.ab-support--anchored .ab-support-launcher svg {
    width: 20px;
    height: 20px;
}

/* --- Profil menüsü: avatar köşesindeki sayı ve "7/24 Canlı Destek" satırı --- */
.user-avatar-container {
    position: relative;
}

.ab-support-avatar-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: #d63c3c;
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
    pointer-events: none;
}

.ab-support-menu-item {
    display: flex;
    align-items: center;
    width: 100%;
}

.ab-support-menu-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #d63c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.ab-support-avatar-badge[hidden],
.ab-support-menu-badge[hidden] {
    display: none;
}

/* --- Pencere --- */
.ab-support-window {
    box-sizing: border-box;
    position: fixed;
    right: 20px;
    bottom: 84px;
    width: 380px;
    height: 540px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    background: var(--abs-bg);
    color: var(--abs-text);
    border: 1px solid var(--abs-border);
    border-radius: var(--abs-radius);
    box-shadow: 0 18px 48px rgba(16, 38, 34, 0.22);
    overflow: hidden;
    transform-origin: bottom right;
    animation: abSupportIn 0.16s ease-out;
}

.ab-support-window[hidden] {
    display: none;
}

@keyframes abSupportIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.ab-support-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 10px 10px 14px;
    background: var(--abs-primary);
    color: #fff;
    flex-shrink: 0;
}

.ab-support-head-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ab-support-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #9be3c9;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18);
    flex-shrink: 0;
}

.ab-support-dot.is-offline {
    background: #f1c27d;
}

.ab-support-head-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.ab-support-head-text strong {
    font-size: 15px;
    font-weight: 700;
}

.ab-support-sub {
    font-size: 12px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ab-support-head-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.ab-support-icon-btn {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ab-support-icon-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.ab-support-icon-btn svg {
    width: 18px;
    height: 18px;
}

.ab-support-icon-btn[hidden] {
    display: none;
}

/* --- Mesajlar --- */
.ab-support-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px 12px 6px;
    background: var(--abs-surface);
}

.ab-support-msg {
    display: flex;
    margin-bottom: 10px;
}

.ab-support-msg--user {
    justify-content: flex-end;
}

.ab-support-bubble {
    max-width: 84%;
    padding: 8px 11px 6px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--abs-border);
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.ab-support-msg--user .ab-support-bubble {
    background: var(--abs-primary);
    border-color: var(--abs-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ab-support-msg--bot .ab-support-bubble,
.ab-support-msg--admin .ab-support-bubble {
    border-bottom-left-radius: 4px;
}

.ab-support-msg--admin .ab-support-bubble {
    border-color: rgba(224, 159, 62, 0.55);
    background: #fffaf2;
}

.ab-support-author {
    font-size: 11px;
    font-weight: 700;
    color: var(--abs-primary);
    margin-bottom: 2px;
}

.ab-support-msg--admin .ab-support-author {
    color: #a86b14;
}

.ab-support-text {
    white-space: pre-wrap;
}

.ab-support-text a {
    color: inherit;
    text-decoration: underline;
}

.ab-support-time {
    font-size: 10.5px;
    opacity: 0.6;
    text-align: right;
    margin-top: 2px;
}

.ab-support-msg.is-pending .ab-support-bubble {
    opacity: 0.65;
}

.ab-support-msg.is-failed .ab-support-bubble {
    background: #fdecec;
    border-color: #e5a3a3;
    color: #8a1f1f;
}

.ab-support-msg--system {
    justify-content: center;
}

.ab-support-system {
    max-width: 92%;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(19, 111, 99, 0.08);
    color: var(--abs-muted);
    font-size: 12.5px;
    line-height: 1.4;
    text-align: center;
    white-space: pre-wrap;
}

/* --- Yazıyor göstergesi --- */
.ab-support-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0 10px;
    color: var(--abs-muted);
    font-size: 12.5px;
}

.ab-support-typing[hidden] {
    display: none;
}

.ab-support-typing-dots {
    display: inline-flex;
    gap: 3px;
}

.ab-support-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--abs-primary);
    opacity: 0.35;
    animation: abSupportDot 1.1s infinite ease-in-out;
}

.ab-support-typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.ab-support-typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes abSupportDot {
    0%,
    80%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }

    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

/* --- Hızlı konular ve temsilci düğmesi --- */
.ab-support-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px 0;
    background: var(--abs-surface);
    flex-shrink: 0;
}

.ab-support-chips[hidden] {
    display: none;
}

.ab-support-chip {
    border: 1px solid rgba(19, 111, 99, 0.35);
    background: #fff;
    color: var(--abs-primary);
    border-radius: 999px;
    padding: 5px 11px;
    font-size: 12.5px;
    cursor: pointer;
}

.ab-support-chip:hover {
    background: rgba(19, 111, 99, 0.08);
}

.ab-support-actions {
    display: flex;
    justify-content: center;
    padding: 6px 12px 0;
    background: var(--abs-surface);
    flex-shrink: 0;
}

.ab-support-actions[hidden] {
    display: none;
}

.ab-support-handoff {
    border: 0;
    background: transparent;
    color: var(--abs-primary);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    padding: 2px 6px;
}

/* --- Yazma alanı --- */
.ab-support-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 12px;
    background: var(--abs-surface);
    border-top: 1px solid var(--abs-border);
    flex-shrink: 0;
}

.ab-support-input {
    flex: 1 1 auto;
    min-height: 40px;
    max-height: 120px;
    resize: none;
    border: 1px solid var(--abs-border);
    border-radius: 12px;
    padding: 9px 12px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--abs-text);
    background: #fff;
    outline: none;
}

.ab-support-input:focus {
    border-color: var(--abs-primary);
    box-shadow: 0 0 0 3px rgba(19, 111, 99, 0.12);
}

.ab-support-send {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: 0;
    border-radius: 12px;
    background: var(--abs-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ab-support-send:disabled {
    opacity: 0.5;
    cursor: default;
}

.ab-support-send svg {
    width: 18px;
    height: 18px;
}

.ab-support-error {
    padding: 0 12px 8px;
    background: var(--abs-surface);
    color: #b42318;
    font-size: 12.5px;
}

.ab-support-error[hidden] {
    display: none;
}

/* --- Üye olmayan --- */
.ab-support-guest {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 100%;
    padding: 24px 20px;
    text-align: center;
}

.ab-support-guest strong {
    font-size: 15px;
}

.ab-support-guest p {
    margin: 0;
    color: var(--abs-muted);
    font-size: 13.5px;
}

.ab-support-guest-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.ab-support-guest-actions a {
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
}

.ab-support-guest-actions a.is-primary {
    background: var(--abs-primary);
    color: #fff;
}

.ab-support-guest-actions a.is-secondary {
    border: 1px solid var(--abs-primary);
    color: var(--abs-primary);
}

/* --- Telefon: alttan açılan sayfa; AI düğmesinin üstünde --- */
@media (max-width: 767.98px) {
    .ab-support-launcher {
        right: 16px;
        bottom: 84px;
        width: 46px;
        height: 46px;
    }

    .ab-support-window {
        left: 8px;
        right: 8px;
        bottom: 8px;
        width: auto;
        height: min(75vh, 560px);
        max-width: none;
        max-height: calc(100vh - 16px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ab-support-window,
    .ab-support-typing-dots span,
    .ab-support-launcher {
        animation: none;
        transition: none;
    }
}
