/* Corner Popup Base Styles */
.corner-popup {
    position: fixed;
    max-width: 390px;
    background-color: #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
    min-height: 325px;
}

.corner-popup.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Position Variants */
.corner-popup-top-left {
    top: 20px;
    left: 20px;
    transform: translateY(-20px);
}

.corner-popup-top-right {
    top: 20px;
    right: 20px;
    transform: translateY(-20px);
}

.corner-popup-bottom-left {
    bottom: 45px;
    left: 20px;
    transform: translateY(20px);
}

.corner-popup-bottom-right {
    bottom: 45px;
    right: 20px;
    transform: translateY(20px);
}

.corner-popup.show.corner-popup-top-left,
.corner-popup.show.corner-popup-top-right,
.corner-popup.show.corner-popup-bottom-left,
.corner-popup.show.corner-popup-bottom-right {
    transform: translateY(0);
}

/* Header Styles */
.corner-popup-header {
    padding: 17px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.1);
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.corner-popup-title {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: inherit;
    padding:0px!important;
}

.corner-popup-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: inherit;
    opacity: 0.8;
    transition: opacity 0.2s ease;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.corner-popup-close:hover {
    opacity: 1;
}

.corner-popup-close .et-pb-icon::before {
    content: "×";
    font-size: 25px;
    line-height: 1;
    position: absolute;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Toggle Button Styles */
.corner-popup-toggle {
    position: fixed;
    width: 57px;
    height: 57px;
    background-color: #ffffff;
    border: 1px solid #84a8c8;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 9998;
    appearance: none;
    padding: 0;
    transition: transform 0.2s ease;
}

.corner-popup-toggle:active {
    transform: scale(0.95);
}

.corner-popup-toggle .toggle-icon {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    line-height: 1;
    transition: transform 0.3s ease;
    font-weight: bold;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Toggle Position Variants */
.corner-popup-toggle-top-left {
    top: 20px;
    left: 20px;
}

.corner-popup-toggle-top-right {
    top: 20px;
    right: 20px;
}

.corner-popup-toggle-bottom-left {
    bottom: 20px;
    left: 20px;
}

.corner-popup-toggle-bottom-right {
    bottom: 20px;
    right: 20px;
}

/* Toggle Icon States */
.toggle-icon.icon-open::before {
    content: "⌃";
    display: block;
    transform: rotate(-180deg);
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-180deg);
}

.toggle-icon.icon-close::before {
    content: "⌃";
    display: block;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 77%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Multi-message functionality */
#corner-popup-messages {
    position: relative;
    display: grid;
    grid-template-rows: 1fr;
}

.corner-popup-message {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease;
    padding: 0;
    /* Use grid to maintain height during transitions */
    grid-row: 1;
    grid-column: 1;
}

.corner-popup-message.active {
    opacity: 1;
    visibility: visible;
    position: relative; /* Allow natural document flow */
    z-index: 2; /* Ensure active message is on top */
}

/* Content Area Styles */
.corner-popup-content {
    padding: 25px 20px;
    line-height: 1.6;
    position: relative;
    color: inherit;
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    .corner-popup {
        max-width: calc(100% - 40px);
        margin: 0 20px;
    }
    
    .corner-popup-toggle {
        width: 57px;
        height: 57px;
    }
    
    .corner-popup-toggle .toggle-icon {
        font-size: 28px;
    }
}