/**
 * Kardeu Popups & Modals Engine
 * Scoped, ultra-lightweight, Zero-CLS modal runtime.
 *
 * @package Kardeu\Popups
 */

/* Container wrapper */
.kd-popups-container {
    position: relative;
    z-index: 999999;
}

/* Modal wrapper */
.kd-popup-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.24s ease;
}

.kd-popup-wrapper.kd-popup-active {
    display: flex;
    opacity: 1;
    visibility: visible;
}

/* Backdrop Overlay */
.kd-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    cursor: pointer;
}

/* Modal Dialog Box */
.kd-popup-dialog {
    position: relative;
    background: #ffffff;
    width: 100%;
    max-height: calc(100vh - 40px);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 2;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.kd-popup-wrapper.kd-popup-active .kd-popup-dialog {
    transform: scale(1) translateY(0);
}

/* Close Button */
.kd-popup-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(241, 245, 249, 0.85);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    z-index: 10;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.kd-popup-close:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: scale(1.05);
}

.kd-popup-close:focus-visible {
    outline: 2px solid #00a7ef;
    outline-offset: 2px;
}

/* Modal Content Inner */
.kd-popup-inner {
    padding: 24px 28px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

/* Header */
.kd-popup-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}

.kd-popup-header-media {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 12px;
}

.kd-popup-header-media img {
    max-height: 48px;
    width: auto;
    object-fit: contain;
    display: block;
}

.kd-popup-title {
    margin: 0 0 4px 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.kd-popup-subtitle {
    margin: 0;
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.4;
}

/* Body */
.kd-popup-body {
    font-size: 0.95rem;
    color: #334155;
    line-height: 1.6;
}

/* Scroll Lock on Body */
body.kd-popup-scroll-locked {
    overflow: hidden !important;
}

/* Reviews List Component Styles */
.kd-reviews-popup-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kd-review-link-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-decoration: none !important;
    color: #0f172a !important;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    font-size: 0.92rem;
    line-height: 1.4;
}

.kd-review-link-item:hover {
    background: #f0f9ff;
    border-color: #bae6fd;
}

.kd-review-arrow {
    color: #00a7ef;
    font-weight: 700;
    font-size: 1.15rem;
    margin-right: 8px;
    line-height: 1;
    flex-shrink: 0;
}

.kd-review-text {
    flex: 1;
    font-weight: 500;
    color: #1e293b;
}

.kd-review-link-item:hover .kd-review-text {
    color: #0284c7;
}

.kd-review-source {
    margin-left: 12px;
    padding: 3px 8px;
    background: #e2e8f0;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.kd-review-link-item:hover .kd-review-source {
    background: #0284c7;
    color: #ffffff;
}

/* Responsive Breakpoints */
@media (max-width: 640px) {
    .kd-popup-wrapper {
        padding: 12px;
    }

    .kd-popup-dialog {
        border-radius: 10px;
        max-height: calc(100vh - 24px);
    }

    .kd-popup-inner {
        padding: 18px 16px;
    }

    .kd-popup-close {
        top: 10px;
        right: 10px;
        width: 32px;
        height: 32px;
    }

    .kd-popup-header-media img {
        max-height: 38px;
    }

    .kd-popup-title {
        font-size: 1.1rem;
    }

    .kd-review-link-item {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        column-gap: 8px;
        row-gap: 4px;
        align-items: baseline;
        padding: 9px 12px;
    }

    .kd-review-arrow {
        grid-column: 1;
        grid-row: 1;
        margin-right: 0;
        font-size: 1.15rem;
        line-height: 1.25;
        align-self: start;
    }

    .kd-review-text {
        grid-column: 2;
        grid-row: 1;
        font-size: 0.88rem;
        line-height: 1.35;
    }

    .kd-review-source {
        grid-column: 2;
        grid-row: 2;
        margin-left: 0;
        margin-top: 2px;
        align-self: start;
        justify-self: start;
        font-size: 0.72rem;
        padding: 2px 6px;
    }
}
