/* A Popup Styles - Improved */
#ap-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    padding: 20px;
    /* BEST PRACTICE: Prevents padding from affecting the total width/height. */
    box-sizing: border-box;
}

#ap-popup-content {
    /* background: #fff;  <-- Controlled by PHP */
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
    text-align: center;
    max-width: 500px;
    width: 100%;
    position: relative;
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;

    /* --- KEY FAILSAFES (Applied to all screen sizes) --- */
    /* * 1. This prevents the popup from ever being taller than 90% of the 
     * visible screen height, solving the issue on small screens and high zoom.
     */
    max-height: 90vh;
    /* vh = viewport height */

    /* * 2. If content is too tall, a vertical scrollbar appears *inside* the popup.
     * The 'X' button will always remain visible.
     */
    overflow-y: auto;
}

#ap-dismiss-button {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #888;
}

#ap-dismiss-button:hover {
    color: #000;
}

#ap-popup-body {
    order: 2;
}

#ap-popup-buttons {
    order: 3;
}

#ap-popup-footer {
    order: 4;
}

#ap-popup-body img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    margin-bottom: 20px;
}

#ap-popup-body h2 {
    font-size: 24px;
    margin-top: 0;
    margin-bottom: 10px;
}

#ap-popup-buttons {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

/* Button Layout Styles */
#ap-popup-buttons.position-center-row {
    justify-content: center;
    align-items: center;
}

#ap-popup-buttons.position-left-stack {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

#ap-popup-buttons.position-right-stack {
    flex-direction: column;
    align-items: flex-end;
}

#ap-popup-buttons.position-top-row {
    order: 1;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    margin-top: 0;
}

.ap-button {
    display: inline-block;
    padding: 12px 25px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    border: 2px solid;
    /* <-- Color controlled by PHP */
    transition: all 0.2s ease-in-out;
}

.ap-button:hover {
    opacity: 1;
    /* <-- Opacity is controlled by specific hover colors */
}

#ap-popup-footer {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #555;
}

#ap-popup-footer input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* --- Refined Responsive Styles --- */
@media (max-width: 768px) {
    #ap-popup-content {
        /* Reduce padding on mobile to give more room for content */
        padding: 25px 20px;
    }

    #ap-popup-body h2 {
        /* Make the title a bit smaller */
        font-size: 22px;
    }

    /* Stack buttons on smaller screens for easier tapping */
    #ap-popup-buttons.position-center-row,
    #ap-popup-buttons.position-top-row {
        flex-direction: column;
        align-items: stretch;
        /* Makes buttons full-width */
    }
}