/* Frontend Proposal Styles */
.stp-frontend-proposal {
    margin-top: 30px;
    font-family: inherit;
}

.stp-milestone-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.stp-milestone-header {
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.stp-milestone-title {
    font-size: 1.5em;
    margin: 0 0 10px 0;
    color: #333;
}

.stp-milestone-description {
    color: #666;
    font-size: 1.1em;
    line-height: 1.6;
}

.stp-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.stp-product-card {
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stp-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.stp-product-image {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    object-fit: cover;
    background: #e1e1e1;
}

.stp-product-details {
    flex: 1;
}

.stp-product-name {
    font-weight: 600;
    font-size: 1.1em;
    color: #333;
    margin-bottom: 5px;
    display: block;
    text-decoration: none;
}

.stp-product-price-qty {
    font-size: 0.9em;
    color: #777;
    display: flex;
    gap: 10px;
    align-items: center;
}

.stp-qty-badge {
    background: #e0e0e0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
}

.stp-order-status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    float: right;
}

.stp-status-pending {
    background: #fff3cd;
    color: #856404;
}

.stp-status-processing {
    background: #d1ecf1;
    color: #0c5460;
}

.stp-status-completed {
    background: #d4edda;
    color: #155724;
}

.stp-status-cancelled {
    background: #f8d7da;
    color: #721c24;
}

@media (max-width: 600px) {
    .stp-milestone-card {
        padding: 15px;
    }

    .stp-milestone-title {
        font-size: 1.3em;
    }
}

/* ── Payment Status Banner ── */
.stp-payment-status-banner {
    position: sticky;
    top: 0;
    z-index: 999;
    padding: 12px 20px;
    margin-bottom: 24px;
    border-radius: 6px;
    border: 1px solid transparent;
}

/* Offset for WordPress admin bar */
.admin-bar .stp-payment-status-banner {
    top: 32px;
}

@media (max-width: 782px) {
    .admin-bar .stp-payment-status-banner {
        top: 46px;
    }
}

.stp-banner-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
}

.stp-banner-title {
    font-weight: 700;
    font-size: 1em;
    white-space: nowrap;
}

.stp-banner-title::after {
    content: ' —';
    font-weight: 400;
    opacity: 0.6;
}

.stp-banner-message {
    flex: 1;
    font-size: 0.95em;
    min-width: 0;
}

.stp-banner-action {
    margin-left: auto;
    flex-shrink: 0;
}

.stp-banner-action .stp-banner-pay-btn {
    white-space: nowrap;
}

/* Banner state colours */
.stp-banner-needs_payment {
    background: #fff3cd;
    color: #856404;
    border-color: #ffc107;
}

.stp-banner-processing {
    background: #d1ecf1;
    color: #0c5460;
    border-color: #bee5eb;
}

.stp-banner-completed {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.stp-banner-on_hold {
    background: #fff3cd;
    color: #856404;
    border-color: #ffc107;
}

@media (max-width: 600px) {
    .stp-payment-status-banner {
        padding: 10px 14px;
    }

    .stp-banner-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .stp-banner-action {
        margin-left: 0;
        width: 100%;
    }

    .stp-banner-action .stp-pay-btn {
        width: 100%;
        text-align: center;
    }
}

/* ── Product Actions & Modals ── */
.stp-product-actions {
    margin-top: 12px;
    display: flex;
    gap: 10px;
}

.stp-action-btn {
    background: rgba(46, 125, 255, 0.08);
    color: #2e7dff;
    border: 1px solid rgba(46, 125, 255, 0.2);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stp-action-btn:hover {
    background: rgba(46, 125, 255, 0.15);
    border-color: rgba(46, 125, 255, 0.3);
}

/* ── Base product modal (used by Add Info) ── */
.stp-product-modal {
    border: none;
    border-radius: 12px;
    padding: 0;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    background: #fff;
    color: #333;
}

/* ── Full-width "What" modal ── */
.stp-product-modal--full {
    max-width: 85vw !important;
    width: 85vw !important;
    height: 88vh !important;
    max-height: 88vh !important;
    border-radius: 14px !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    margin: auto !important;
}

.stp-product-modal::backdrop,
.stp-product-modal--full::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
}

.stp-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 22px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
    border-radius: 14px 14px 0 0;
    flex-shrink: 0;
}

.stp-modal-header-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.stp-modal-header h4 {
    margin: 0;
    font-size: 1.15em;
    font-weight: 600;
    color: #222;
}

.stp-modal-product-link {
    font-size: 0.78em;
    color: #2e7dff;
    text-decoration: none;
    opacity: 0.75;
    transition: opacity 0.2s;
}

.stp-modal-product-link:hover { opacity: 1; }

.stp-modal-subtitle {
    margin: 4px 0 0;
    font-size: 0.85em;
    color: #888;
    font-weight: 400;
}

.stp-modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
    line-height: 1;
    padding: 0 5px;
    flex-shrink: 0;
}

.stp-modal-close:hover { color: #ff4757; }

/* Standard modal content (Add Info) */
.stp-modal-content {
    padding: 25px;
    font-size: 1em;
    line-height: 1.6;
    max-height: 70vh;
    overflow-y: auto;
}

.stp-modal-content p:last-child { margin-bottom: 0; }

.stp-modal-content table {
    width: 100%;
    border-collapse: collapse;
}

.stp-modal-content th, .stp-modal-content td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    text-align: left;
}

/* Iframe modal content (What) */
.stp-modal-content--iframe {
    padding: 0 !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    max-height: none !important;
    height: 0 !important; /* flex will stretch it; explicit 0 forces flex to own the height */
    overflow: hidden !important;
    position: relative !important;
    border-radius: 0 0 14px 14px !important;
}

.stp-iframe-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.stp-spinner {
    animation: stpSpin 0.9s linear infinite;
    color: #2e7dff;
}

@keyframes stpSpin {
    to { transform: rotate(360deg); }
}

.stp-what-iframe {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    display: block !important;
    opacity: 0;
    transition: opacity 0.3s ease;
    position: absolute !important;
    inset: 0 !important;
}

@media (max-width: 768px) {
    .stp-product-modal--full {
        max-width: 96vw !important;
        width: 96vw !important;
        height: 92vh !important;
        max-height: 92vh !important;
    }
}

/* ── Template Purchase Section ── */
/* ── Sticky template purchase bar ── */
.stp-template-purchase-wrap {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #f0f6ff 0%, #fafafa 100%);
    border: 1px solid #d0e4ff;
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
/* Offset for WordPress admin bar */
.admin-bar .stp-template-purchase-wrap {
    top: 32px;
}
@media (max-width: 782px) {
    .admin-bar .stp-template-purchase-wrap {
        top: 46px;
    }
}

.stp-template-purchase-wrap.stp-login-required {
    background: #f9f9f9;
    border-color: #e0e0e0;
    flex-direction: column;
    align-items: flex-start;
}

.stp-template-purchase-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.stp-template-original-price {
    text-decoration: line-through;
    color: #999;
    font-size: 0.95em;
}

.stp-template-discount-badge {
    background: #d4edda;
    color: #155724;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.8em;
    font-weight: 700;
}

.stp-template-total {
    font-size: 1.5em;
    font-weight: 700;
    color: #1a1a2e;
}

.stp-template-buy-btn {
    white-space: nowrap;
    padding: 10px 22px;
    font-size: 1em;
}

/* ── Task Template Badge (in admin milestone assignments) ── */
.stp-task-template-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75em;
    color: #22c55e;
    font-weight: 600;
    margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════
   Dark Glassy Milestone Cards — v2 (page-load animations)
   ══════════════════════════════════════════════════════════ */

:root {
    --milestone-blue:    #89C2E0;
    --milestone-magenta: #b608c9;
    --glass-bg:          rgba(255, 255, 255, 0.02);
    --glass-border:      rgba(255, 255, 255, 0.1);
    --obsidian:          #0b0e14;
}

/* ── Animatable CSS custom property for spinning border ── */
@property --border-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* ── Page-load entrance keyframes ── */
@keyframes cardEnter {
    from { opacity: 0; transform: translateY(40px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

@keyframes introEnter {
    from { opacity: 0; transform: translateX(-28px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes productEnter {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── Animated 3D border spin (activates on hover) ── */
@keyframes borderSpin {
    to { --border-angle: 360deg; }
}

/* ══ Milestone Card ══ */
.stp-milestone-card {
    position: relative;
    isolation: isolate;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 0;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    color: #e8eaf0;
    overflow: hidden;
    /* Page-load entrance — stagger by --card-index */
    animation: cardEnter 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--card-index, 0) * 0.15s);
    will-change: transform, opacity;
    transition: border-color 0.35s ease, box-shadow 0.35s ease, transform 0.35s ease;
}

/* ── Rotating gradient border via ::before — shows on hover ── */
.stp-milestone-card::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 25px;
    background: conic-gradient(
        from var(--border-angle),
        var(--milestone-magenta),
        var(--milestone-blue),
        var(--milestone-magenta)
    );
    z-index: 1;
    opacity: 0;
    transition: opacity 0.4s ease;
    animation: borderSpin 3s linear infinite paused;
    pointer-events: none;
}

/* ── Glass overlay ::after — sits above ::before, applies dark filter over the animation ── */
/*    backdrop-filter here samples everything below it in the same stacking context,          */
/*    including ::before, putting the spinning border visually under the frosted glass.       */
.stp-milestone-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 23px;
    z-index: 2;
    pointer-events: none;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: background 0.35s ease, backdrop-filter 0.35s ease, -webkit-backdrop-filter 0.35s ease;
}

/* ── Hover: 3D tilt + border + glass filter over the animation ── */
.stp-milestone-card:hover {
    border-color: rgba(137, 194, 224, 0.3);
    transform: perspective(1000px) rotateX(-2deg) translateY(-5px);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(137, 194, 224, 0.2),
        0 0 50px rgba(137, 194, 224, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

/* Spinning border becomes visible */
.stp-milestone-card:hover::before {
    opacity: 1;
    animation-play-state: running;
}

/* Glass overlay activates — dark frosted pane filters ::before and page content alike */
.stp-milestone-card:hover::after {
    background: rgba(11, 14, 20, 0.78);
    backdrop-filter: blur(28px) saturate(180%) brightness(0.68);
    -webkit-backdrop-filter: blur(28px) saturate(180%) brightness(0.68);
}

/* ══ Milestone Intro Section (title + description — distinct dark styling) ══ */
.stp-milestone-intro {
    position: relative;
    z-index: 3; /* above ::after glass overlay */
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 28px 28px 22px;
    background: linear-gradient(135deg, rgba(182, 8, 201, 0.07) 0%, rgba(11, 14, 20, 0.55) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    /* Entrance: slide from left after card appears */
    animation: introEnter 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--card-index, 0) * 0.15s + 0.12s);
}

/* Step-number badge */
.stp-step-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--milestone-magenta) 0%, rgba(182, 8, 201, 0.45) 100%);
    color: #fff;
    font-size: 1.2em;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    box-shadow: 0 0 20px rgba(182, 8, 201, 0.5);
    border: 1px solid rgba(182, 8, 201, 0.3);
    letter-spacing: 0.02em;
}

.stp-milestone-intro-content {
    flex: 1;
    min-width: 0;
}

.stp-milestone-title {
    font-size: 1.25em;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--milestone-blue);
    margin: 0 0 8px 0;
    text-shadow: 0 0 20px rgba(137, 194, 224, 0.3);
}

.stp-milestone-description {
    color: rgba(232, 234, 240, 0.72);
    font-size: 0.97em;
    line-height: 1.65;
}

.stp-milestone-description p { margin: 0 0 0.5em 0; }
.stp-milestone-description p:last-child { margin-bottom: 0; }

/* ══ Products Section (visually distinct from intro) ══ */
.stp-milestone-products-wrap {
    position: relative;
    z-index: 3; /* above ::after glass overlay */
    padding: 20px 28px 26px;
    background: rgba(255, 255, 255, 0.012);
}

/* Products grid */
.stp-products-grid {
    gap: 14px;
    margin-top: 0;
}

/* ══ Product Cards ══ */
.stp-product-card {
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 14px;
    color: #e8eaf0;
    /* Page-load entrance: stagger by card + product indices */
    animation: productEnter 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(
        var(--card-index, 0) * 0.15s
        + var(--product-index, 0) * 0.08s
        + 0.28s
    );
    will-change: transform, opacity;
    transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.stp-product-card:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(137, 194, 224, 0.3);
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(137, 194, 224, 0.15);
}

.stp-product-name {
    color: #c8dff0;
    font-weight: 600;
    font-size: 1em;
}

.stp-product-name:hover {
    color: var(--milestone-blue);
}

.stp-product-price-qty {
    color: rgba(232, 234, 240, 0.65);
    font-size: 0.85em;
}

.stp-qty-badge {
    background: rgba(182, 8, 201, 0.18);
    color: #d88ce0;
    border: 1px solid rgba(182, 8, 201, 0.25);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.82em;
    font-weight: 600;
}

.stp-action-btn {
    background: rgba(137, 194, 224, 0.08);
    color: var(--milestone-blue);
    border: 1px solid rgba(137, 194, 224, 0.2);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stp-action-btn:hover {
    background: rgba(137, 194, 224, 0.15);
    border-color: rgba(137, 194, 224, 0.4);
    color: #b0d9ef;
}

/* Milestone-level pay button area */
.stp-milestone-pay-wrap {
    position: relative;
    z-index: 3; /* above ::after glass overlay */
    padding: 0 28px 20px;
}

/* ── Sticky purchase bar dark variant ── */
.stp-template-purchase-wrap {
    background: rgba(11, 14, 20, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(137, 194, 224, 0.2);
    border-radius: 12px;
    color: #e8eaf0;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.stp-template-total {
    color: var(--milestone-blue);
    text-shadow: 0 0 18px rgba(137, 194, 224, 0.4);
}

.stp-template-original-price {
    color: rgba(232, 234, 240, 0.45);
}

.stp-template-discount-badge {
    background: rgba(182, 8, 201, 0.2);
    color: #d88ce0;
    border: 1px solid rgba(182, 8, 201, 0.3);
}

/* ── Credit Payment Widget (inside task-checkout modal) ── */
.stp-credit-widget {
    background: rgba(137, 194, 224, 0.05);
    border: 1px solid rgba(137, 194, 224, 0.15);
    border-radius: 10px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stp-credit-balance-row,
.stp-credit-cost-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95em;
}

.stp-credit-balance-label,
.stp-credit-cost-label {
    color: rgba(232, 234, 240, 0.65);
}

.stp-credit-balance-value {
    font-weight: 700;
    color: #89C2E0;
}

.stp-credit-cost-value {
    font-weight: 700;
    color: #d88ce0;
}

.stp-pay-credits-btn {
    width: 100%;
    text-align: center;
    padding: 12px;
    font-size: 1em;
    font-weight: 600;
    margin-top: 4px;
}

.stp-credit-shortage {
    font-size: 0.9em;
    color: #ffc107;
    margin: 0;
    padding: 8px 0 4px;
}

.stp-credit-result {
    text-align: center;
    font-weight: 600;
    color: #22c55e;
    padding: 8px 0;
}

/* ── IntersectionObserver trigger script (inline, via PHP) ── */