/**
 * ABP Subscription – Frontend Styles
 *
 * Covers:
 *  - Subscribe button injected into the search toolbar
 *  - Modal overlay + dialog
 *  - Filter pills inside the modal
 *  - Feedback / notice banners
 *  - Responsive adjustments
 *
 * BEM-style naming: .abp-sub-* keeps the scope narrow.
 *
 * @package Statistical_Report_Plugin
 * @version 1.0
 */

/* ── CSS Custom Properties ─────────────────────────────────────────────────── */

:root {
    --abp-sub-teal      : #26a69a;
    --abp-sub-teal-dark : #00897b;
    --abp-sub-teal-light: rgba(38, 166, 154, .12);
    --abp-sub-error     : #c62828;
    --abp-sub-error-bg  : #ffebee;
    --abp-sub-success   : #2e7d32;
    --abp-sub-success-bg: #e8f5e9;
    --abp-sub-radius    : 10px;
    --abp-sub-shadow    : 0 8px 32px rgba(0, 0, 0, .18);
    --abp-sub-font      : -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --abp-sub-z-overlay : 99990;
    --abp-sub-z-modal   : 99991;
    --abp-sub-transition: 0.22s ease;
}

/* ── Subscribe button ─────────────────────────────────────────────────────── */

.abp-subscribe-btn-wrap {
    display      : inline-flex;
    align-items  : center;
    margin-left  : auto;      /* push to right side of the toolbar */
}

.abp-subscribe-btn {
    display        : inline-flex;
    align-items    : center;
    gap            : 6px;
    padding        : 8px 18px;
    background     : #fff;
    color          : var(--abp-sub-teal);
    border         : 2px solid var(--abp-sub-teal);
    border-radius  : 20px;
    font-family    : var(--abp-sub-font);
    font-size      : 14px;
    font-weight    : 600;
    cursor         : pointer;
    transition     : background var(--abp-sub-transition),
                     color      var(--abp-sub-transition),
                     transform  var(--abp-sub-transition);
    white-space    : nowrap;
    line-height    : 1;
}

.abp-subscribe-btn:hover,
.abp-subscribe-btn:focus-visible {
    background  : var(--abp-sub-teal);
    color       : #fff;
    transform   : translateY(-1px);
    outline     : none;
}

.abp-subscribe-btn:active {
    transform : translateY(0);
}

/* ── Modal overlay ────────────────────────────────────────────────────────── */

.abp-sub-overlay {
    position        : fixed;
    inset           : 0;
    background      : rgba(0, 0, 0, .52);
    z-index         : var(--abp-sub-z-overlay);
    display         : flex;
    align-items     : center;
    justify-content : center;
    padding         : 16px;
    opacity         : 0;
    pointer-events  : none;
    transition      : opacity var(--abp-sub-transition);
}

.abp-sub-overlay.is-open {
    opacity        : 1;
    pointer-events : all;
}

/* Prevent body scroll when modal is open */
body.abp-modal-open {
    overflow : hidden;
}

/* ── Modal dialog ─────────────────────────────────────────────────────────── */

.abp-sub-modal {
    background    : #fff;
    border-radius : var(--abp-sub-radius);
    box-shadow    : var(--abp-sub-shadow);
    width         : 100%;
    max-width     : 480px;
    max-height    : 90vh;
    overflow-y    : auto;
    font-family   : var(--abp-sub-font);
    transform     : translateY(24px) scale(.97);
    transition    : transform var(--abp-sub-transition);
    position      : relative;
}

.abp-sub-overlay.is-open .abp-sub-modal {
    transform : translateY(0) scale(1);
}

/* ── Modal header ─────────────────────────────────────────────────────────── */

.abp-sub-modal-header {
    background    : var(--abp-sub-teal);
    padding       : 22px 24px 18px;
    border-radius : var(--abp-sub-radius) var(--abp-sub-radius) 0 0;
    position      : relative;
}

.abp-sub-modal-header h2 {
    margin      : 0 0 6px;
    font-size   : 18px;
    font-weight : 700;
    color       : #fff;
    line-height : 1.2;
}

.abp-sub-desc {
    margin      : 0;
    font-size   : 13px;
    color       : rgba(255, 255, 255, .85);
    line-height : 1.4;
}

.abp-sub-close {
    position   : absolute;
    top        : 14px;
    right      : 16px;
    background : none;
    border     : none;
    color      : rgba(255, 255, 255, .8);
    font-size  : 22px;
    line-height: 1;
    cursor     : pointer;
    padding    : 4px;
    transition : color var(--abp-sub-transition);
}

.abp-sub-close:hover { color: #fff; }

/* ── Form layout ──────────────────────────────────────────────────────────── */

.abp-sub-form {
    padding : 22px 24px;
    display : flex;
    flex-direction : column;
    gap     : 18px;
}

.abp-sub-field {
    display        : flex;
    flex-direction : column;
    gap            : 6px;
}

.abp-sub-field label {
    font-size   : 13px;
    font-weight : 600;
    color       : #444;
    user-select : none;
}

.abp-sub-field input[type="email"],
.abp-sub-field select {
    width        : 100%;
    padding      : 10px 14px;
    border       : 1.5px solid #d0d0d0;
    border-radius: 8px;
    font-family  : var(--abp-sub-font);
    font-size    : 14px;
    color        : #222;
    background   : #fff;
    transition   : border-color var(--abp-sub-transition),
                   box-shadow   var(--abp-sub-transition);
    box-sizing   : border-box;
}

.abp-sub-field input[type="email"]:focus,
.abp-sub-field select:focus {
    outline      : none;
    border-color : var(--abp-sub-teal);
    box-shadow   : 0 0 0 3px var(--abp-sub-teal-light);
}

/* ── Filter preview pills ─────────────────────────────────────────────────── */

.abp-sub-filters-display {
    display     : flex;
    flex-wrap   : wrap;
    gap         : 6px;
    padding     : 10px 12px;
    background  : #f7f7f7;
    border      : 1.5px solid #e0e0e0;
    border-radius : 8px;
    min-height  : 42px;
    align-items : center;
}

.abp-sub-filter-pill {
    display       : inline-flex;
    align-items   : center;
    gap           : 4px;
    padding       : 3px 10px;
    background    : var(--abp-sub-teal-light);
    color         : var(--abp-sub-teal-dark);
    border        : 1px solid rgba(38, 166, 154, .25);
    border-radius : 12px;
    font-size     : 12px;
    font-weight   : 600;
    white-space   : nowrap;
}

/* ── Feedback area ────────────────────────────────────────────────────────── */

.abp-sub-feedback {
    font-size     : 14px;
    line-height   : 1.4;
    border-radius : 6px;
    padding       : 0;
    transition    : padding var(--abp-sub-transition), background var(--abp-sub-transition);
}

.abp-sub-feedback:not(:empty) {
    padding : 10px 14px;
}

.abp-sub-feedback--success {
    background : var(--abp-sub-success-bg);
    color      : var(--abp-sub-success);
    border     : 1px solid rgba(46, 125, 50, .25);
}

.abp-sub-feedback--error {
    background : var(--abp-sub-error-bg);
    color      : var(--abp-sub-error);
    border     : 1px solid rgba(198, 40, 40, .25);
}

/* ── Action buttons ───────────────────────────────────────────────────────── */

.abp-sub-actions {
    display  : flex;
    gap      : 10px;
    flex-wrap: wrap;
}

.abp-sub-submit {
    flex        : 1;
    padding     : 11px 20px;
    background  : var(--abp-sub-teal);
    color       : #fff;
    border      : none;
    border-radius : 8px;
    font-family : var(--abp-sub-font);
    font-size   : 15px;
    font-weight : 600;
    cursor      : pointer;
    transition  : background var(--abp-sub-transition), transform var(--abp-sub-transition);
}

.abp-sub-submit:hover { background: var(--abp-sub-teal-dark); transform: translateY(-1px); }
.abp-sub-submit:active { transform: translateY(0); }
.abp-sub-submit:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.abp-sub-cancel {
    padding      : 11px 18px;
    background   : transparent;
    color        : #666;
    border       : 1.5px solid #d0d0d0;
    border-radius: 8px;
    font-family  : var(--abp-sub-font);
    font-size    : 14px;
    cursor       : pointer;
    transition   : border-color var(--abp-sub-transition), color var(--abp-sub-transition);
}

.abp-sub-cancel:hover { border-color: #999; color: #333; }

/* ── URL notice banner (shown after verify / unsubscribe redirect) ────────── */

.abp-sub-url-notice {
    max-width     : 800px;
    margin        : 0 auto 20px;
    padding       : 14px 20px;
    background    : var(--abp-sub-success-bg);
    color         : var(--abp-sub-success);
    border        : 1px solid rgba(46, 125, 50, .3);
    border-radius : var(--abp-sub-radius);
    font-family   : var(--abp-sub-font);
    font-size     : 14px;
    font-weight   : 600;
    transition    : opacity 0.4s ease;
    text-align    : center;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
    .abp-sub-modal {
        max-width  : 100%;
        max-height : 95vh;
        border-radius : var(--abp-sub-radius) var(--abp-sub-radius) 0 0;
        position   : fixed;
        bottom     : 0;
        left       : 0;
        right      : 0;
        transform  : translateY(40px);
    }

    .abp-sub-overlay.is-open .abp-sub-modal {
        transform : translateY(0);
    }

    .abp-sub-actions {
        flex-direction : column-reverse;
    }

    .abp-sub-cancel {
        text-align : center;
    }

    .abp-subscribe-btn {
        font-size : 12px;
        padding   : 7px 12px;
    }
}

@media (max-width: 400px) {
    .abp-sub-form {
        padding : 16px;
    }

    .abp-sub-modal-header {
        padding : 18px 16px 14px;
    }
}

/* ── v1.2: Checkable filter grid inside the modal ──────────────────────────── */

.abp-sub-section-label {
    font-size    : 13px;
    font-weight  : 600;
    color        : #444;
    display      : block;
    margin-bottom: 8px;
    user-select  : none;
}

.abp-sub-checkbox-grid {
    display        : flex;
    flex-wrap      : wrap;
    gap            : 6px;
    padding        : 10px 12px;
    background     : #f7f7f7;
    border         : 1.5px solid #e0e0e0;
    border-radius  : 8px;
    min-height     : 42px;
    align-items    : flex-start;
    align-content  : flex-start;
}

.abp-sub-checkbox-grid--years {
    /* years wrap into a tighter row */
    gap: 4px;
}

.abp-sub-check-label {
    display        : inline-flex;
    align-items    : center;
    gap            : 6px;
    padding        : 5px 12px;
    background     : #fff;
    border         : 1.5px solid #d0d0d0;
    border-radius  : 20px;
    font-size      : 12px;
    font-weight    : 500;
    color          : #444;
    cursor         : pointer;
    transition     : border-color var(--abp-sub-transition, .22s ease),
                     background   var(--abp-sub-transition, .22s ease),
                     color        var(--abp-sub-transition, .22s ease);
    user-select    : none;
    white-space    : nowrap;
}

.abp-sub-check-label:hover {
    border-color : var(--abp-sub-teal, #26a69a);
    color        : var(--abp-sub-teal-dark, #00897b);
}

/* Hide the native checkbox — the pill itself is the visual */
.abp-sub-check-label input[type="checkbox"] {
    position : absolute;
    opacity  : 0;
    width    : 0;
    height   : 0;
    margin   : 0;
}

/* Checked state — filled pill */
.abp-sub-check-label:has(input:checked) {
    background   : var(--abp-sub-teal, #26a69a);
    border-color : var(--abp-sub-teal, #26a69a);
    color        : #fff;
}

/* Fallback for browsers without :has() support (Firefox < 121) */
.abp-sub-check-label input:checked + span {
    /* text stays white via parent rule; add a marker on very old browsers */
}

/* Focus ring for keyboard users */
.abp-sub-check-label:focus-within {
    outline       : 2px solid var(--abp-sub-teal, #26a69a);
    outline-offset: 2px;
}

/* Empty state message inside the grid */
.abp-sub-checkbox-grid em {
    color     : #999;
    font-size : 12px;
    padding   : 2px 0;
}

@media (max-width: 480px) {
    .abp-sub-check-label {
        font-size : 11px;
        padding   : 4px 10px;
    }
}