/*
 * Sağ alttaki dönüşüm bloğu + teklif penceresi.
 * Markup: resources/views/components/site/floating-cta.blade.php
 *
 * Animasyon kuralları (önceki sürümde ikisi de bozuktu, tekrar edilmemeli):
 *
 * 1. GENİŞLİK ANİMATE EDİLMEZ. `width: 54px -> auto` ara değer üretmez;
 *    tarayıcı geçişi atlar ve buton zıplar. Etiketler bu yüzden her zaman
 *    açık; animasyon yalnızca opacity/transform üzerinden yürür — ikisi de
 *    kompozit katmanda çalışır, yeniden düzen (reflow) tetiklemez.
 *
 * 2. DİKKAT HALKASI ELEMANIN KENDİSİNDE. Halka ::after üzerindeyken
 *    `overflow: hidden` onu kırpıyordu, yani animasyon hiç görünmüyordu.
 *    Elemanın kendi box-shadow'u kendi overflow'undan etkilenmez; halka
 *    artık orada ve overflow tamamen kaldırıldı.
 */

 .floating-cta {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 900;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: max-content;
    max-width: calc(100vw - 40px);

    /* Giriş: ziyaretçi biraz kaydırınca JS `is-visible` ekler. */
    opacity: 0;
    transform: translateY(18px);
    visibility: hidden;
    transition: opacity 0.32s ease, transform 0.32s ease, visibility 0s linear 0.32s;
}

.floating-cta.is-visible {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    transition: opacity 0.32s ease, transform 0.32s ease, visibility 0s;
}

.floating-cta__call-wrap {
    display: flex;
    justify-content: flex-end;
}

.floating-cta__call {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 8px 10px;
    border-radius: 999px;
    background-color: #1d4ed8e6;
    color: #fff;
    font-family: var(--f-ff-font-1);
    text-decoration: none;
    box-shadow: 0 8px 18px rgba(29, 78, 216, 0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.floating-cta__call:hover,
.floating-cta__call:focus-visible {
    background-color: #1e40af;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(29, 78, 216, 0.28);
}

.floating-cta__call:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.floating-cta__call-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    font-size: 12px;
}

.floating-cta__call-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.floating-cta__call-text small {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.85;
    white-space: nowrap;
}

.floating-cta__call-text strong {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

/* Hafif ahize sallanması — yalnızca ikon, üç kez değil sürekli ama seyrek. */
.floating-cta.is-visible .floating-cta__call-icon {
    animation: floating-cta-call-wiggle 5s ease-in-out 1.4s infinite;
}

@keyframes floating-cta-call-wiggle {
    0%,
    86%,
    100% {
        transform: rotate(0);
    }

    89% {
        transform: rotate(11deg);
    }

    92% {
        transform: rotate(-9deg);
    }

    95% {
        transform: rotate(6deg);
    }

    98% {
        transform: rotate(-3deg);
    }
}

.floating-cta__btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px 11px 12px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    font-family: var(--f-ff-font-1);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(5, 5, 28, 0.26);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.floating-cta__btn:hover,
.floating-cta__btn:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(5, 5, 28, 0.34);
    color: #fff;
}

.floating-cta__btn:active {
    transform: translateY(0);
}

.floating-cta__btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.floating-cta__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    font-size: 18px;
}

.floating-cta__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.floating-cta__text strong {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.15;
    white-space: nowrap;
}

/* Fayda satırı: butonun ne vaat ettiğini söyler, tıklama kararını o veriyor. */
.floating-cta__text small {
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.15;
    opacity: 0.78;
    white-space: nowrap;
}

/* --- WhatsApp: ikincil, marka yeşili --- */
.floating-cta__btn--whatsapp {
    background-color: #25d366;
}

.floating-cta__btn--whatsapp:hover {
    background-color: #1fb457;
}

.floating-cta__btn--whatsapp .floating-cta__icon {
    font-size: 21px;
}

/* --- Teklif: birincil eylem --- */
.floating-cta__btn--quote {
    background-color: #011b53;
    padding-top: 13px;
    padding-bottom: 13px;
}

.floating-cta__btn--quote:hover {
    background-color: #001a51;
}

.floating-cta__btn--quote .floating-cta__text strong {
    font-size: 16px;
}

/*
 * Dikkat halkası: blok göründükten sonra üç kez atar, sonra susar.
 * Sonsuz animasyon bir süre sonra görmezden gelinir ve rahatsız eder.
 */
.floating-cta.is-visible .floating-cta__btn--quote {
    animation: floating-cta-ring 2.6s ease-out 0.6s 3;
}

.floating-cta.is-visible .floating-cta__btn--quote:hover {
    animation: none;
}

@keyframes floating-cta-ring {
    0% {
        box-shadow: 0 10px 26px rgba(5, 5, 28, 0.26), 0 0 0 0 rgba(5, 5, 28, 0.42);
    }
    60% {
        box-shadow: 0 10px 26px rgba(5, 5, 28, 0.26), 0 0 0 16px rgba(5, 5, 28, 0);
    }
    100% {
        box-shadow: 0 10px 26px rgba(5, 5, 28, 0.26), 0 0 0 0 rgba(5, 5, 28, 0);
    }
}

/* --- Mobil: alt kenarda yapışkan çubuk --- */
@media (max-width: 767px) {
    .floating-cta {
        right: 10px;
        left: 10px;
        bottom: 10px;
        width: auto;
        max-width: none;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .floating-cta__call-wrap {
        flex: 1 0 100%;
    }

    .floating-cta__btn {
        justify-content: center;
        gap: 9px;
        padding: 10px 12px;
        border-radius: 14px;
    }

    /* Teklif butonu daha geniş: birincil eylem olduğu görünsün. */
    .floating-cta__btn--quote {
        flex: 1.35 1 0;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .floating-cta__btn--whatsapp {
        flex: 1 1 0;
    }

    .floating-cta__icon {
        width: 33px;
        height: 33px;
        font-size: 16px;
        padding: 3px;
    }

    .floating-cta__btn--whatsapp .floating-cta__icon {
        font-size: 18px;
    }

    .floating-cta__text strong,
    .floating-cta__btn--quote .floating-cta__text strong {
        font-size: 13.5px;
    }

    .floating-cta__text small {
        font-size: 10.5px;
    }

    /* Tema "yukarı çık" düğmesi çubuğun altında kalmasın. */
    .progress-wrap {
        bottom: 126px;
    }
}

@media (max-width: 380px) {
    .floating-cta__text small {
        display: none;
    }
}

/* --- Açılır pencere --- */
.quote-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.quote-modal[hidden] {
    display: none;
}

.quote-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgb(0 19 49 / 74%);
    opacity: 0;
    transition: opacity 0.22s ease;
}

.quote-modal.is-open .quote-modal__backdrop {
    opacity: 1;
}

.quote-modal__dialog {
    position: relative;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 26px 24px 24px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 28px 70px rgba(5, 5, 28, 0.35);
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.quote-modal.is-open .quote-modal__dialog {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.quote-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(5, 5, 28, 0.06);
    color: #05051C;
    font-size: 15px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.quote-modal__close:hover {
    background: rgba(5, 5, 28, 0.12);
}

/* Pencere açıkken arka plan kaymasın. */
body.quote-modal-open {
    overflow: hidden;
}

@media (max-width: 575px) {
    .quote-modal {
        padding: 12px;
    }

    .quote-modal__dialog {
        padding: 0;
        max-height: calc(100vh - 24px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .floating-cta,
    .floating-cta__btn,
    .quote-modal__backdrop,
    .quote-modal__dialog,
    .quote-modal__close {
        transition: none;
    }

    .floating-cta.is-visible .floating-cta__btn--quote,
    .floating-cta.is-visible .floating-cta__call-icon {
        animation: none;
    }
}
