/* ===================================
   POPUP MANAGER - 3 Tip için CSS
   Modal | Bar | Window
   =================================== */

/* Backdrop (sadece modal için) */
.popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9997;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* ========== MODAL ========== */
.popup-modal {
    position: relative;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.popup-modal-body {
    overflow-y: auto;
    flex: 1;
}

.popup-modal .popup-image {
    width: 100%;
    display: block;
}

.popup-modal .popup-content {
    padding: 24px;
}

/* ========== BAR ========== */
.popup-bar {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 9997;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 24px;
    min-height: 48px;
}

.popup-bar-top {
    top: 0;
}

.popup-bar-bottom {
    bottom: 0;
}

.popup-bar .popup-image {
    height: 36px;
    width: auto;
    border-radius: 4px;
    flex-shrink: 0;
}

.popup-bar .popup-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    justify-content: center;
}

.popup-bar .popup-title {
    margin: 0;
    white-space: nowrap;
}

.popup-bar .popup-body-text {
    margin: 0;
    white-space: nowrap;
}

/* ========== WINDOW ========== */
.popup-window {
    position: fixed;
    z-index: 9997;
    width: 360px;
    max-height: 480px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.popup-window-top-left {
    top: 20px;
    left: 20px;
}

.popup-window-top-right {
    top: 20px;
    right: 20px;
}

.popup-window-bottom-left {
    bottom: 20px;
    left: 20px;
}

.popup-window-bottom-right {
    bottom: 20px;
    right: 20px;
}

.popup-window .popup-image {
    width: 100%;
    display: block;
}

.popup-window .popup-content {
    padding: 16px;
}

/* ========== ORTAK ========== */
.popup-title {
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.popup-body-text {
    margin: 0 0 16px 0;
    line-height: 1.6;
}

.popup-btn {
    display: inline-block;
    padding: 10px 24px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s, transform 0.2s;
}

.popup-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Kapatma butonu */
.popup-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    z-index: 10;
    transition: background 0.2s;
}

.popup-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.popup-bar .popup-close {
    position: relative;
    top: auto;
    right: auto;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    font-size: 14px;
}

/* ========== BUTON ANİMASYONLARI ========== */
@keyframes popupBtnPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
@keyframes popupBtnBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}
@keyframes popupBtnShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}
@keyframes popupBtnGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(224, 20, 138, 0.4); }
    50% { box-shadow: 0 0 20px rgba(224, 20, 138, 0.8); }
}
.popup-btn-pulse { animation: popupBtnPulse 2s ease-in-out infinite; }
.popup-btn-bounce { animation: popupBtnBounce 1s ease-in-out infinite; }
.popup-btn-shake { animation: popupBtnShake 0.5s ease-in-out infinite; }
.popup-btn-glow { animation: popupBtnGlow 2s ease-in-out infinite; }

/* ========== ANİMASYONLAR ========== */

/* Popup giriş animasyonları */
.popup-enter-modal {
    animation: popupScaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.popup-enter-bar-top {
    animation: popupSlideDown 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.popup-enter-bar-bottom {
    animation: popupSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.popup-enter-window {
    animation: popupScaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Metin animasyonları (tek sefer) */
.popup-anim-fade-in {
    animation: popupFadeIn 1.2s ease-out both;
}

.popup-anim-slide-left {
    animation: popupTextSlideLeft 1s ease-out both;
}

.popup-anim-slide-right {
    animation: popupTextSlideRight 1s ease-out both;
}

.popup-anim-slide-up {
    animation: popupTextSlideUp 1s ease-out both;
}

.popup-anim-bounce {
    animation: popupBounce 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.popup-anim-typing {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid currentColor;
    animation: popupTyping 3s steps(50, end) forwards, popupBlink 0.75s step-end infinite;
}

/* Metin animasyonları (sürekli tekrar - loop) */
.popup-anim-fade-in-loop {
    animation: popupFadeInLoop 3s ease-in-out infinite;
}

.popup-anim-slide-left-loop {
    animation: popupTextSlideLeftLoop 3s ease-in-out infinite;
}

.popup-anim-slide-right-loop {
    animation: popupTextSlideRightLoop 3s ease-in-out infinite;
}

.popup-anim-slide-up-loop {
    animation: popupTextSlideUpLoop 3s ease-in-out infinite;
}

.popup-anim-bounce-loop {
    animation: popupBounceLoop 3s ease-in-out infinite;
}

.popup-anim-typing-loop {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid currentColor;
    animation: popupTypingLoop 4s steps(50, end) infinite, popupBlink 0.75s step-end infinite;
}

@keyframes popupTyping {
    from { max-width: 0; }
    to { max-width: 100%; }
}

@keyframes popupBlink {
    0%, 100% { border-color: transparent; }
    50% { border-color: currentColor; }
}

/* Loop keyframes (geri dönüşlü) */
@keyframes popupFadeInLoop {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

@keyframes popupTextSlideLeftLoop {
    0% { opacity: 0; transform: translateX(-20px); }
    20%, 80% { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(20px); }
}

@keyframes popupTextSlideRightLoop {
    0% { opacity: 0; transform: translateX(20px); }
    20%, 80% { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(-20px); }
}

@keyframes popupTextSlideUpLoop {
    0% { opacity: 0; transform: translateY(15px); }
    20%, 80% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-15px); }
}

@keyframes popupBounceLoop {
    0%, 100% { transform: scale(0.95); }
    50% { transform: scale(1.05); }
}

@keyframes popupTypingLoop {
    0% { max-width: 0; }
    45%, 55% { max-width: 100%; }
    100% { max-width: 0; }
}

/* Keyframes */
@keyframes popupScaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes popupSlideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

@keyframes popupSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes popupFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popupTextSlideLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes popupTextSlideRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

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

@keyframes popupBounce {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

/* ========== MOBİL RESPONSIVE ========== */
@media (max-width: 767px) {
    .popup-modal {
        max-width: 100%;
        border-radius: 12px;
        max-height: 85vh;
    }

    .popup-modal .popup-content {
        padding: 16px;
    }

    .popup-window {
        width: calc(100% - 24px);
        max-width: 320px;
    }

    .popup-window-top-left,
    .popup-window-top-right {
        top: 12px;
    }

    .popup-window-bottom-left,
    .popup-window-bottom-right {
        bottom: 12px;
    }

    .popup-window-top-left,
    .popup-window-bottom-left {
        left: 12px;
        right: auto;
    }

    .popup-window-top-right,
    .popup-window-bottom-right {
        right: 12px;
        left: auto;
    }

    .popup-bar {
        padding: 10px 16px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .popup-bar .popup-image {
        height: 28px;
    }

    .popup-bar .popup-content {
        flex-wrap: wrap;
        gap: 6px;
    }

    .popup-bar .popup-title,
    .popup-bar .popup-body-text {
        white-space: normal;
        font-size: 12px !important;
    }

    .popup-desktop-only {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .popup-mobile-only {
        display: none !important;
    }
}

/* Başlık her zaman üstte — kendi padding'ini içerik alanından alır */
.popup-title-wrap {
    padding: 16px 24px 0;
}
.popup-title-wrap .popup-title {
    margin: 0;
}

/* ========== POPUP ÜRÜN KARTLARI ========== */
/* flex-wrap kullanıyoruz ki son satırda kalan tek ürün ortalansın */
.popup-products {
    display: flex !important;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
}

.popup-products .popup-product-card {
    flex: 0 0 calc((100% - 24px) / 3);
    max-width: calc((100% - 24px) / 3);
    min-width: 0;
}

/* 1 ürün: tek ortalı kart */
.popup-products.popup-products-count-1 .popup-product-card {
    flex: 0 0 60%;
    max-width: 60%;
}

/* 2 ürün: yan yana 2 kart */
.popup-products.popup-products-count-2 .popup-product-card {
    flex: 0 0 calc((100% - 12px) / 2);
    max-width: calc((100% - 12px) / 2);
}

.popup-product-card {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    cursor: pointer;
}

.popup-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.10);
    border-color: rgba(0, 0, 0, 0.16);
}

.popup-product-card:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.popup-product-image-wrap {
    aspect-ratio: 1 / 1;
    background: #f3f4f6;
    overflow: hidden;
}

.popup-product-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.popup-product-name {
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.3;
    font-weight: 500;
    color: #111827;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
}

/* Tablet (768-1023px): 3 sütun, gap küçük */
@media (max-width: 1023px) and (min-width: 768px) {
    .popup-products {
        gap: 10px;
        padding: 12px;
    }
    .popup-product-name {
        font-size: 12px;
        padding: 6px 8px;
    }
}

/* Mobile (<768px): max 2 sütun, son satır ortalı */
@media (max-width: 767px) {
    .popup-products {
        gap: 8px;
        padding: 10px;
    }
    .popup-products .popup-product-card {
        flex: 0 0 calc((100% - 8px) / 2) !important;
        max-width: calc((100% - 8px) / 2) !important;
    }
    .popup-products.popup-products-count-1 .popup-product-card {
        flex: 0 0 70% !important;
        max-width: 70% !important;
    }
    .popup-product-name {
        font-size: 11.5px;
        padding: 6px 6px;
        min-height: 2.4em;
    }
    .popup-product-card {
        border-radius: 10px;
    }
}

/* Window tipi için biraz daha kompakt */
.popup-window .popup-products {
    padding: 10px;
    gap: 8px;
}
.popup-window .popup-product-name {
    font-size: 11.5px;
    padding: 6px 6px;
}
