/**
 * Neslin WhatsApp Sticky Button - Frontend Stilleri
 * Tasarım: WhatsApp resmi renk paleti, modern panel deneyimi
 */

/* ============ DEĞIŞKENLER ============ */
:root {
    --neslin-wa-yesil: #25d366;
    --neslin-wa-yesil-koyu: #128c7e;
    --neslin-wa-yesil-acik: #dcf8c6;
    --neslin-wa-teal: #075e54;
    --neslin-wa-arka-plan: #efeae2;
    --neslin-wa-mesaj-bg: #ffffff;
    --neslin-wa-metin: #303030;
    --neslin-wa-metin-acik: #667781;
    --neslin-wa-mavi-tik: #53bdeb;
    --neslin-wa-golge: 0 6px 24px rgba(0, 0, 0, 0.18);
    --neslin-wa-golge-buton: 0 4px 12px rgba(37, 211, 102, 0.4);
}

/* ============ ANA SARMALAYICI ============ */
#neslin-wa-wrapper {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    box-sizing: border-box;
}

#neslin-wa-wrapper *,
#neslin-wa-wrapper *::before,
#neslin-wa-wrapper *::after {
    box-sizing: border-box;
}

/* Pozisyon: sağ ve sol seçenekleri */
#neslin-wa-wrapper.neslin-wa-sag {
    right: 24px;
}

#neslin-wa-wrapper.neslin-wa-sol {
    left: 24px;
}

/* ============ ANA BUTON ============ */
.neslin-wa-ana-buton {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--neslin-wa-yesil);
    border: none;
    cursor: pointer;
    box-shadow: var(--neslin-wa-golge-buton);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s ease,
                background 0.25s ease;
    padding: 0;
    outline: none;
}

.neslin-wa-ana-buton:hover {
    transform: scale(1.08);
    background: #20bd5a;
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.55);
}

.neslin-wa-ana-buton:active {
    transform: scale(0.95);
}

.neslin-wa-ana-buton:focus-visible {
    outline: 3px solid rgba(37, 211, 102, 0.5);
    outline-offset: 4px;
}

/* WhatsApp ikon — varsayılan görünür */
.neslin-wa-ikon-wa {
    width: 32px;
    height: 32px;
    transition: opacity 0.2s ease, transform 0.3s ease;
}

/* Kapat ikon — varsayılan gizli */
.neslin-wa-ikon-kapat {
    position: absolute;
    width: 24px;
    height: 24px;
    opacity: 0;
    transform: rotate(-90deg);
    transition: opacity 0.2s ease, transform 0.3s ease;
}

/* Panel açıkken ikonlar yer değiştirir */
#neslin-wa-wrapper[data-acik="true"] .neslin-wa-ikon-wa {
    opacity: 0;
    transform: rotate(90deg);
}

#neslin-wa-wrapper[data-acik="true"] .neslin-wa-ikon-kapat {
    opacity: 1;
    transform: rotate(0);
}

/* ============ PULS ANIMASYONU ============ */
.neslin-wa-puls {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--neslin-wa-yesil);
    opacity: 0.5;
    z-index: -1;
    animation: neslinWaPuls 2.4s infinite ease-out;
}

.neslin-wa-puls-2 {
    animation-delay: 1.2s;
}

@keyframes neslinWaPuls {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

/* Panel açıkken puls dursun */
#neslin-wa-wrapper[data-acik="true"] .neslin-wa-puls {
    animation-play-state: paused;
    opacity: 0;
}

/* ============ ROZET ============ */
.neslin-wa-rozet {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff3b30;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#neslin-wa-wrapper[data-acik="true"] .neslin-wa-rozet,
#neslin-wa-wrapper.neslin-wa-okundu .neslin-wa-rozet {
    opacity: 0;
    transform: scale(0);
}

/* ============ AÇILIR PANEL ============ */
.neslin-wa-panel {
    position: absolute;
    bottom: 80px;
    width: 340px;
    background: white;
    border-radius: 16px;
    box-shadow: var(--neslin-wa-golge);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.3s;
}

#neslin-wa-wrapper.neslin-wa-sol .neslin-wa-panel {
    transform-origin: bottom left;
    left: 0;
}

#neslin-wa-wrapper.neslin-wa-sag .neslin-wa-panel {
    right: 0;
}

#neslin-wa-wrapper[data-acik="true"] .neslin-wa-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ============ PANEL HEADER ============ */
.neslin-wa-panel-header {
    background: var(--neslin-wa-teal);
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.neslin-wa-kapat {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.neslin-wa-kapat:hover {
    background: rgba(255, 255, 255, 0.25);
}

.neslin-wa-header-icerik {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 36px;
    width: 100%;
}

.neslin-wa-avatar-kucuk {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.85);
}

.neslin-wa-avatar-kucuk img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.neslin-wa-avatar-kucuk svg {
    width: 36px;
    height: 36px;
}

/* Aktif durum göstergesi (yeşil nokta) */
.neslin-wa-aktif-nokta {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #4caf50;
    border: 2px solid var(--neslin-wa-teal);
    border-radius: 50%;
    animation: neslinWaNokta 2s infinite;
}

@keyframes neslinWaNokta {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.neslin-wa-header-metin h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: white;
    line-height: 1.2;
}

.neslin-wa-unvan {
    margin: 2px 0 0 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 400;
}

/* ============ PANEL BODY: SOHBET ARKAPLANI ============ */
.neslin-wa-panel-body {
    background: var(--neslin-wa-arka-plan);
    /* WhatsApp tarzı doodle pattern (SVG data URI) */
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60' opacity='0.06'><path fill='%23000' d='M30 5 L35 20 L50 22 L40 33 L43 48 L30 41 L17 48 L20 33 L10 22 L25 20 Z'/></svg>");
    padding: 24px 18px;
    min-height: 180px;
    position: relative;
}

.neslin-wa-sohbet-arkaplan {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ============ MESAJ BALONU ============ */
.neslin-wa-mesaj-baloncuk {
    background: var(--neslin-wa-mesaj-bg);
    border-radius: 0 8px 8px 8px;
    padding: 10px 12px 6px;
    max-width: 85%;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
    position: relative;
    opacity: 0;
    transform: translateY(8px);
    animation: neslinWaMesajGirisi 0.4s 0.6s forwards ease-out;
}

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

/* Konuşma balonu kuyruğu (tail) */
.neslin-wa-mesaj-baloncuk::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 10px 0;
    border-color: transparent var(--neslin-wa-mesaj-bg) transparent transparent;
}

.neslin-wa-mesaj-isim {
    font-size: 13px;
    font-weight: 600;
    color: #d97706;
    margin-bottom: 2px;
}

.neslin-wa-mesaj-metin {
    font-size: 14px;
    line-height: 1.4;
    color: var(--neslin-wa-metin);
    word-wrap: break-word;
}

.neslin-wa-mesaj-zaman {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--neslin-wa-metin-acik);
}

.neslin-wa-tik {
    margin-left: 2px;
}

/* ============ YAZIYOR ANIMASYONU ============ */
.neslin-wa-yaziyor {
    background: var(--neslin-wa-mesaj-bg);
    border-radius: 16px;
    padding: 12px 16px;
    width: fit-content;
    display: flex;
    gap: 4px;
    align-items: center;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
    opacity: 0;
    animation: neslinWaMesajGirisi 0.3s 0.1s forwards ease-out,
               neslinWaYaziyorCikis 0.3s 0.55s forwards ease-out;
}

@keyframes neslinWaYaziyorCikis {
    to {
        opacity: 0;
        height: 0;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
}

.neslin-wa-yaziyor span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: neslinWaZipla 1s infinite;
}

.neslin-wa-yaziyor span:nth-child(2) { animation-delay: 0.15s; }
.neslin-wa-yaziyor span:nth-child(3) { animation-delay: 0.3s; }

@keyframes neslinWaZipla {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ============ PANEL FOOTER ============ */
.neslin-wa-panel-footer {
    background: #f0f2f5;
    padding: 14px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.neslin-wa-cevap-suresi {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 10px 0;
    font-size: 12px;
    color: var(--neslin-wa-metin-acik);
}

.neslin-wa-baslat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: var(--neslin-wa-yesil);
    color: white;
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 24px;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s ease, transform 0.2s ease;
    border: none;
    cursor: pointer;
}

.neslin-wa-baslat-btn:hover {
    background: #20bd5a;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
    text-decoration: none;
}

.neslin-wa-baslat-btn:active {
    transform: translateY(0);
}

/* ============ İLK GİRİŞ ANIMASYONU ============ */
#neslin-wa-wrapper {
    animation: neslinWaButonGiris 0.5s 1s both ease-out;
}

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

/* ============ MOBİL UYUMLULUK ============ */
@media (max-width: 480px) {
    #neslin-wa-wrapper {
        bottom: 16px;
    }

    #neslin-wa-wrapper.neslin-wa-sag {
        right: 16px;
    }

    #neslin-wa-wrapper.neslin-wa-sol {
        left: 16px;
    }

    .neslin-wa-ana-buton {
        width: 56px;
        height: 56px;
    }

    .neslin-wa-ikon-wa {
        width: 28px;
        height: 28px;
    }

    .neslin-wa-panel {
        width: calc(100vw - 32px);
        max-width: 340px;
        bottom: 72px;
    }

    /* Sol pozisyonda panel ekrandan taşmasın */
    #neslin-wa-wrapper.neslin-wa-sol .neslin-wa-panel {
        left: 0;
    }

    #neslin-wa-wrapper.neslin-wa-sag .neslin-wa-panel {
        right: 0;
    }
}

/* ============ ERİŞİLEBİLİRLİK ============ */
@media (prefers-reduced-motion: reduce) {
    .neslin-wa-puls,
    .neslin-wa-aktif-nokta,
    #neslin-wa-wrapper {
        animation: none !important;
    }

    .neslin-wa-mesaj-baloncuk,
    .neslin-wa-yaziyor {
        opacity: 1;
        animation: none !important;
    }

    .neslin-wa-ana-buton,
    .neslin-wa-panel,
    .neslin-wa-baslat-btn {
        transition: none !important;
    }
}

/* Yazdırma modunda gizle */
@media print {
    #neslin-wa-wrapper {
        display: none !important;
    }
}
