/* Cohsar Popup Frontend Styles */

.cohsar-popup-hidden { 
    display: none !important; 
}

.cohsar-popup-overlay {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.7); 
    z-index: 99998; 
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cohsar-popup-popup {
    position: fixed;
    /* Default position (center) — overridden by .cohsar-popup-pos-* classes below */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: #ffffff;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 99999;
    width: 90%;
    max-width: 500px;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Visible state: fade in + remove the scale() portion of the transform.
   Each position class redefines its own transform so we don't hard-code translate(-50%,-50%) here. */
.cohsar-popup-overlay.cohsar-popup-visible {
    opacity: 1;
    display: block !important;
}
.cohsar-popup-popup.cohsar-popup-visible {
    opacity: 1;
    display: block !important;
}

/* ===== Position variants ===== */

/* Center (default) */
.cohsar-popup-pos-center {
    top: 50%; left: 50%; right: auto; bottom: auto;
    transform: translate(-50%, -50%) scale(0.95);
}
.cohsar-popup-pos-center.cohsar-popup-visible {
    transform: translate(-50%, -50%) scale(1);
}

/* Top (centered horizontally) */
.cohsar-popup-pos-top {
    top: 2rem; left: 50%; right: auto; bottom: auto;
    transform: translate(-50%, -10px) scale(0.95);
}
.cohsar-popup-pos-top.cohsar-popup-visible {
    transform: translate(-50%, 0) scale(1);
}

/* Bottom (centered horizontally) */
.cohsar-popup-pos-bottom {
    top: auto; left: 50%; right: auto; bottom: 2rem;
    transform: translate(-50%, 10px) scale(0.95);
}
.cohsar-popup-pos-bottom.cohsar-popup-visible {
    transform: translate(-50%, 0) scale(1);
}

/* Left (centered vertically) */
.cohsar-popup-pos-left {
    top: 50%; left: 2rem; right: auto; bottom: auto;
    transform: translate(-10px, -50%) scale(0.95);
}
.cohsar-popup-pos-left.cohsar-popup-visible {
    transform: translate(0, -50%) scale(1);
}

/* Right (centered vertically) */
.cohsar-popup-pos-right {
    top: 50%; left: auto; right: 2rem; bottom: auto;
    transform: translate(10px, -50%) scale(0.95);
}
.cohsar-popup-pos-right.cohsar-popup-visible {
    transform: translate(0, -50%) scale(1);
}

/* Top-left */
.cohsar-popup-pos-top-left {
    top: 2rem; left: 2rem; right: auto; bottom: auto;
    transform: translate(-10px, -10px) scale(0.95);
}
.cohsar-popup-pos-top-left.cohsar-popup-visible {
    transform: translate(0, 0) scale(1);
}

/* Top-right */
.cohsar-popup-pos-top-right {
    top: 2rem; left: auto; right: 2rem; bottom: auto;
    transform: translate(10px, -10px) scale(0.95);
}
.cohsar-popup-pos-top-right.cohsar-popup-visible {
    transform: translate(0, 0) scale(1);
}

/* Bottom-left */
.cohsar-popup-pos-bottom-left {
    top: auto; left: 2rem; right: auto; bottom: 2rem;
    transform: translate(-10px, 10px) scale(0.95);
}
.cohsar-popup-pos-bottom-left.cohsar-popup-visible {
    transform: translate(0, 0) scale(1);
}

/* Bottom-right */
.cohsar-popup-pos-bottom-right {
    top: auto; left: auto; right: 2rem; bottom: 2rem;
    transform: translate(10px, 10px) scale(0.95);
}
.cohsar-popup-pos-bottom-right.cohsar-popup-visible {
    transform: translate(0, 0) scale(1);
}

/* On small screens, corner/edge popups shrink their margin */
@media (max-width: 600px) {
    .cohsar-popup-pos-top,
    .cohsar-popup-pos-bottom,
    .cohsar-popup-pos-top-left,
    .cohsar-popup-pos-top-right,
    .cohsar-popup-pos-bottom-left,
    .cohsar-popup-pos-bottom-right,
    .cohsar-popup-pos-left,
    .cohsar-popup-pos-right {
        left: 1rem !important;
        right: 1rem !important;
        max-width: calc(100vw - 2rem) !important;
    }
    .cohsar-popup-pos-top,
    .cohsar-popup-pos-top-left,
    .cohsar-popup-pos-top-right {
        top: 1rem !important;
    }
    .cohsar-popup-pos-bottom,
    .cohsar-popup-pos-bottom-left,
    .cohsar-popup-pos-bottom-right {
        bottom: 1rem !important;
    }
}

.cohsar-popup-content { 
    color: #333; 
    margin-bottom: 0;
}

.cohsar-popup-content h2 {
    margin-top: 0; 
    margin-bottom: 1rem; 
    font-size: 1.5rem;
    font-weight: 600; 
    color: #111;
}

.cohsar-popup-content p {
    margin-bottom: 0; 
    font-size: 1rem; 
    line-height: 1.5;
}

/* Close button (X) */
.cohsar-popup-close-btn {
    position: absolute !important; 
    top: 0.5rem !important; 
    right: 0.5rem !important;
    background: #f0f0f0 !important; 
    border: none !important; 
    font-size: 1.5rem !important;
    font-weight: 700 !important; 
    line-height: 1 !important; 
    color: #666 !important;
    cursor: pointer !important; 
    padding: 0.5rem !important; 
    z-index: 100001 !important;
    width: 32px !important; 
    height: 32px !important; 
    border-radius: 4px !important;
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important;
    pointer-events: auto !important;
    isolation: isolate !important;
}

/* Keep popup content below the close button so nothing inside can cover it */
.cohsar-popup-content {
    position: relative !important;
    z-index: 1 !important;
}

.cohsar-popup-close-btn:hover { 
    background: #e0e0e0 !important; 
    color: #333 !important; 
}

.cohsar-popup-close-btn:focus {
    outline: 2px solid #2271b1 !important;
    outline-offset: 2px !important;
}

/* Configurable layouts and animation presets (v3.4.0). */
.cohsar-popup-popup {
    --cohsar-position-transform: translate(-50%, -50%);
    transform: var(--cohsar-position-transform) scale(0.95);
    transition: opacity 0.42s ease, transform 0.48s cubic-bezier(.22, 1, .36, 1);
}
.cohsar-popup-pos-center {
    --cohsar-position-transform: translate(-50%, -50%);
}
.cohsar-popup-pos-top,
.cohsar-popup-pos-bottom {
    --cohsar-position-transform: translate(-50%, 0);
}
.cohsar-popup-pos-left,
.cohsar-popup-pos-right {
    --cohsar-position-transform: translate(0, -50%);
}
.cohsar-popup-pos-top-left,
.cohsar-popup-pos-top-right,
.cohsar-popup-pos-bottom-left,
.cohsar-popup-pos-bottom-right {
    --cohsar-position-transform: translate(0, 0);
}

.cohsar-popup-mode-drawer-right,
.cohsar-popup-mode-drawer-left {
    --cohsar-position-transform: translate(0, 0);
    top: 0;
    bottom: 0;
    width: min(390px, 100vw);
    max-width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    overflow: auto;
}
.cohsar-popup-mode-drawer-right {
    left: auto;
    right: 0;
}
.cohsar-popup-mode-drawer-left {
    left: 0;
    right: auto;
}
.cohsar-popup-mode-bottom-sheet {
    --cohsar-position-transform: translate(0, 0);
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    max-height: min(88vh, 720px);
    border-radius: 1.4rem 1.4rem 0 0;
    overflow: auto;
}
.cohsar-popup-mode-bottom-sheet::before {
    content: "";
    display: block;
    width: 52px;
    height: 5px;
    border-radius: 999px;
    margin: -0.65rem auto 1rem;
    background: #d1d5db;
}

.cohsar-popup-popup.cohsar-popup-anim-fade {
    transform: var(--cohsar-position-transform);
}
.cohsar-popup-popup.cohsar-popup-anim-spring {
    transform: var(--cohsar-position-transform) scale(0.72);
    transition: opacity 0.34s ease, transform 0.58s cubic-bezier(.34, 1.56, .64, 1);
}
.cohsar-popup-popup.cohsar-popup-anim-slide-left {
    transform: var(--cohsar-position-transform) translateX(-110vw) scale(0.96);
}
.cohsar-popup-popup.cohsar-popup-anim-slide-right {
    transform: var(--cohsar-position-transform) translateX(110vw) scale(0.96);
}
.cohsar-popup-popup.cohsar-popup-anim-slide-top {
    transform: var(--cohsar-position-transform) translateY(-110vh) scale(0.96);
}
.cohsar-popup-popup.cohsar-popup-anim-slide-bottom {
    transform: var(--cohsar-position-transform) translateY(110vh) scale(0.96);
}
.cohsar-popup-popup.cohsar-popup-visible {
    transform: var(--cohsar-position-transform) scale(1);
}

.cohsar-popup-launcher {
    position: fixed;
    top: var(--cohsar-launcher-top, 50%);
    z-index: 99997;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.8rem 0.7rem;
    border: 1px solid rgba(99, 102, 241, 0.18);
    background: var(--cohsar-launcher-bg, #ffffff);
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.13);
    color: var(--cohsar-launcher-text, #312e81);
    cursor: pointer;
    transform: translateY(-50%);
    transition: transform 0.28s ease, box-shadow 0.28s ease, background 0.28s ease;
}
.cohsar-popup-launcher-right.cohsar-popup-launcher-layout-vertical {
    right: 0;
    flex-direction: column;
    border-radius: var(--cohsar-launcher-radius, 14px) 0 0 var(--cohsar-launcher-radius, 14px);
}
.cohsar-popup-launcher-left.cohsar-popup-launcher-layout-vertical {
    left: 0;
    flex-direction: column-reverse;
    border-radius: 0 var(--cohsar-launcher-radius, 14px) var(--cohsar-launcher-radius, 14px) 0;
}
.cohsar-popup-launcher-layout-vertical .cohsar-popup-launcher-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0;
}
.cohsar-popup-launcher-layout-horizontal {
    flex-direction: row;
}
.cohsar-popup-launcher-right.cohsar-popup-launcher-layout-horizontal {
    right: 0;
    border-radius: var(--cohsar-launcher-radius, 14px) 0 0 var(--cohsar-launcher-radius, 14px);
}
.cohsar-popup-launcher-left.cohsar-popup-launcher-layout-horizontal {
    left: 0;
    border-radius: 0 var(--cohsar-launcher-radius, 14px) var(--cohsar-launcher-radius, 14px) 0;
}
.cohsar-popup-launcher-layout-horizontal .cohsar-popup-launcher-label {
    writing-mode: horizontal-tb;
    transform: none;
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: 0;
}
.cohsar-popup-launcher-icon {
    display: inline-grid;
    place-items: center;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    color: #fff;
    background: var(--cohsar-launcher-accent, #6366f1);
}
.cohsar-popup-launcher-has-pulse .cohsar-popup-launcher-icon {
    animation: cohsar-launcher-pulse 2.8s ease-in-out infinite;
}
.cohsar-popup-launcher-size-compact {
    gap: 0.4rem;
    padding: 0.6rem 0.52rem;
}
.cohsar-popup-launcher-size-compact .cohsar-popup-launcher-icon {
    width: 1.45rem;
    height: 1.45rem;
    font-size: 0.72rem;
}
.cohsar-popup-launcher-size-compact .cohsar-popup-launcher-label {
    font-size: 0.72rem;
}
.cohsar-popup-launcher-size-large {
    gap: 0.7rem;
    padding: 1rem 0.88rem;
}
.cohsar-popup-launcher-size-large .cohsar-popup-launcher-icon {
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1.05rem;
}
.cohsar-popup-launcher-size-large .cohsar-popup-launcher-label {
    font-size: 0.92rem;
}
.cohsar-popup-launcher:hover,
.cohsar-popup-launcher:focus-visible,
.cohsar-popup-launcher[aria-expanded="true"] {
    background: var(--cohsar-launcher-bg, #ffffff);
    box-shadow: 0 18px 44px rgba(99, 102, 241, 0.22);
}
.cohsar-popup-launcher-right:hover,
.cohsar-popup-launcher-right:focus-visible {
    transform: translate(-4px, -50%);
}
.cohsar-popup-launcher-left:hover,
.cohsar-popup-launcher-left:focus-visible {
    transform: translate(4px, -50%);
}
@keyframes cohsar-launcher-pulse {
    0%, 100% { transform: scale(0.94); box-shadow: 0 0 0 0 var(--cohsar-launcher-accent, #6366f1); }
    45% { transform: scale(1.08); box-shadow: 0 0 0 11px transparent; }
}

.cohsar-popup-screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 600px) {
    .cohsar-popup-mode-drawer-right,
    .cohsar-popup-mode-drawer-left {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: none !important;
    }
    .cohsar-popup-mode-bottom-sheet {
        left: 0 !important;
        right: 0 !important;
        max-width: none !important;
    }
    .cohsar-popup-launcher {
        top: auto;
        bottom: 1rem;
        transform: none;
        flex-direction: row;
        border-radius: var(--cohsar-launcher-radius, 14px);
    }
    .cohsar-popup-launcher-label {
        writing-mode: horizontal-tb;
        transform: none;
    }
    .cohsar-popup-launcher-right {
        right: 1rem;
    }
    .cohsar-popup-launcher-left {
        left: 1rem;
    }
    .cohsar-popup-launcher:hover,
    .cohsar-popup-launcher:focus-visible {
        transform: translateY(-3px);
    }
    .cohsar-popup-launcher-mobile-edge {
        bottom: calc(var(--cohsar-launcher-mobile-bottom, 92px) + env(safe-area-inset-bottom, 0px));
        width: 42px;
        height: 62px;
        overflow: hidden;
        gap: 10px;
        padding: 0 9px;
        border: 0;
        background: var(--cohsar-launcher-accent, #6366f1);
        color: #fff;
        box-shadow: 0 10px 28px rgba(45, 48, 142, 0.3);
        transition: width 0.26s ease, transform 0.18s ease, background 0.18s ease;
    }
    .cohsar-popup-launcher-mobile-edge.cohsar-popup-launcher-right {
        right: 0;
        left: auto;
        border-radius: var(--cohsar-launcher-radius, 14px) 0 0 var(--cohsar-launcher-radius, 14px);
    }
    .cohsar-popup-launcher-mobile-edge.cohsar-popup-launcher-left {
        right: auto;
        left: 0;
        border-radius: 0 var(--cohsar-launcher-radius, 14px) var(--cohsar-launcher-radius, 14px) 0;
    }
    .cohsar-popup-launcher-mobile-edge .cohsar-popup-launcher-icon {
        flex: 0 0 24px;
        width: 24px;
        height: 24px;
        border: 1px solid rgba(255, 255, 255, 0.35);
        background: rgba(255, 255, 255, 0.14);
        color: #fff;
        animation: none;
    }
    .cohsar-popup-launcher-mobile-edge .cohsar-popup-launcher-label {
        width: 0;
        overflow: hidden;
        white-space: nowrap;
        color: #fff;
        font-size: 0.86rem;
        font-weight: 600;
        opacity: 0;
        transition: width 0.2s ease, opacity 0.16s ease;
    }
    .cohsar-popup-launcher-mobile-edge.is-intro-expanded {
        width: 142px;
    }
    .cohsar-popup-launcher-mobile-edge.is-intro-expanded .cohsar-popup-launcher-label {
        width: auto;
        opacity: 1;
    }
    .cohsar-popup-launcher-mobile-edge:hover,
    .cohsar-popup-launcher-mobile-edge:focus-visible,
    .cohsar-popup-launcher-mobile-edge[aria-expanded="true"] {
        background: var(--cohsar-launcher-accent, #6366f1);
    }
}
