/**
 * Hilanaw — Subscription Page
 * Scoped to .hilanaw-sub-page — never bleeds into theme styles.
 *
 * @package Hilanaw_AI_Core
 * @version 1.0.0
 *
 * SECTIONS:
 *   1.  Reset & Wrapper
 *   2.  Cart Resume Bar (sticky top)
 *   3.  Active Subscription Banner
 *   4.  Billing Toggle (monthly / yearly)
 *   5.  Role Tabs (guest only)
 *   6.  Plan Grid & Cards
 *   7.  Plan Card States (current, upgrade, inactive)
 *   8.  Feature List
 *   9.  CTA Buttons
 *  10.  Savings Badge
 *  11.  Guest Register Notice
 *  12.  Loading / Skeleton
 *  13.  Responsive
 */

/* ============================================================
 * 1. Reset & Wrapper
 * ============================================================ */

.hilanaw-sub-page *,
.hilanaw-sub-page *::before,
.hilanaw-sub-page *::after {
    box-sizing: border-box;
}

.hilanaw-sub-page {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    color: #111827;
    line-height: 1.5;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px 60px;
}

/* ============================================================
 * 2. Cart Resume Bar
 * ============================================================ */

.hilanaw-cart-bar {
    display: none; /* shown via JS when cart has items */
    position: sticky;
    top: var(--hilanaw-header-height, 60px); /* offset below the sticky global header;
                                                 set --hilanaw-header-height on :root via
                                                 JS or theme CSS to match the actual header height */
    z-index: 99; /* one below the header's z-index: 100 so it never overlaps */
    background: linear-gradient(135deg, #0046a0 0%, #0066cc 100%);
    color: #fff;
    padding: 10px 20px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 70, 160, 0.25);
    animation: hsp-slideDown 0.25s ease-out;
}

.hilanaw-cart-bar.is-visible {
    display: flex;
}

.hilanaw-cart-bar__text {
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hilanaw-cart-bar__text svg {
    flex-shrink: 0;
    opacity: 0.9;
}

.hilanaw-cart-bar__btn {
    flex-shrink: 0;
    background: #fff;
    color: #0046a0;
    border: none;
    border-radius: 6px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
}

.hilanaw-cart-bar__btn:hover {
    background: #e0eaff;
    transform: translateY(-1px);
    text-decoration: none;
    color: #003380;
}

/* ============================================================
 * 3. Active Subscription Banner
 * ============================================================ */

.hilanaw-active-sub {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1.5px solid #16a34a;
    border-radius: 14px;
    padding: 22px 24px;
    margin: 28px 0 32px;
    display: flex;
    align-items: flex-start;
    gap: 18px;
    box-shadow: 0 2px 12px rgba(22, 163, 74, 0.1);
    animation: hsp-fadeIn 0.3s ease-out;
}

.hilanaw-active-sub__icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.hilanaw-active-sub__body {
    flex: 1;
}

.hilanaw-active-sub__title {
    font-size: 17px;
    font-weight: 700;
    color: #15803d;
    margin: 0 0 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.hilanaw-active-sub__badge {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    background: #16a34a;
    color: #fff;
    padding: 2px 8px;
    border-radius: 20px;
}

.hilanaw-active-sub__badge.is-pro {
    background: #7c3aed;
}

.hilanaw-active-sub__badge.is-investor {
    background: #0046a0;
}

.hilanaw-active-sub__badge.is-org {
    background: #b45309;
}

.hilanaw-active-sub__meta {
    font-size: 14px;
    color: #166534;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
}

.hilanaw-active-sub__meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hilanaw-active-sub__expiry-warn {
    display: inline-block;
    margin-top: 10px;
    font-size: 12px;
    font-weight: 600;
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    padding: 3px 10px;
}

/* ============================================================
 * 4. Billing Toggle
 * ============================================================ */

.hilanaw-billing-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 0 32px;
}

.hilanaw-billing-toggle__label {
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.15s;
    user-select: none;
}

.hilanaw-billing-toggle__label.is-active {
    color: #111827;
    font-weight: 600;
}

/* The pill switch */
.hilanaw-toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.hilanaw-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.hilanaw-toggle-switch__track {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s;
}

.hilanaw-toggle-switch input:checked + .hilanaw-toggle-switch__track {
    background: #0046a0;
}

.hilanaw-toggle-switch__track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.hilanaw-toggle-switch input:checked + .hilanaw-toggle-switch__track::after {
    transform: translateX(22px);
}

/* ============================================================
 * 5. Role Tabs (guest only)
 * ============================================================ */

.hilanaw-role-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 32px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.hilanaw-role-tabs::-webkit-scrollbar { display: none; }

.hilanaw-role-tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

.hilanaw-role-tab:hover {
    color: #1d4ed8;
}

.hilanaw-role-tab.is-active {
    color: #1d4ed8;
    border-bottom-color: #2563eb;
    font-weight: 600;
}

.hilanaw-role-panel {
    display: none;
}

.hilanaw-role-panel.is-active {
    display: block;
    animation: hsp-fadeIn 0.2s ease-out;
}

/* ============================================================
 * 6. Plan Grid & Cards
 * ============================================================ */

.hilanaw-plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 20px;
    align-items: start;
}

.hilanaw-plan-card {
    background: #ffffff;
    border: 1.5px solid #e5e7eb;
    border-radius: 16px;
    padding: 28px 24px 24px;
    position: relative;
    transition: box-shadow 0.2s, transform 0.2s;
}

.hilanaw-plan-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.09);
    transform: translateY(-2px);
}

/* Pro card highlight */
.hilanaw-plan-card.is-featured {
    border-color: #7c3aed;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.12);
}

.hilanaw-plan-card.is-featured:hover {
    box-shadow: 0 8px 30px rgba(124, 58, 237, 0.18);
}

/* Current plan (greyed out) */
.hilanaw-plan-card.is-current {
    background: #f9fafb;
    border-color: #d1d5db;
    opacity: 0.85;
}

.hilanaw-plan-card.is-current:hover {
    transform: none;
    box-shadow: none;
    cursor: default;
}

/* ============================================================
 * 7. Plan Card States
 * ============================================================ */

/* Top ribbon */
.hilanaw-plan-card__ribbon {
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    background: #7c3aed;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 4px 14px;
    border-radius: 0 0 8px 8px;
    white-space: nowrap;
}

.hilanaw-plan-card__ribbon.is-current-ribbon {
    background: #6b7280;
}

/* Card header */
.hilanaw-plan-card__header {
    margin-bottom: 16px;
}

.hilanaw-plan-card__name {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 4px;
}

.hilanaw-plan-card.is-featured .hilanaw-plan-card__name {
    color: #6d28d9;
}

.hilanaw-plan-card__tagline {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

/* Pricing */
.hilanaw-plan-card__price {
    margin: 18px 0 20px;
    min-height: 56px;
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.hilanaw-plan-card__amount {
    font-size: 32px;
    font-weight: 800;
    color: #111827;
    line-height: 1;
}

.hilanaw-plan-card.is-featured .hilanaw-plan-card__amount {
    color: #6d28d9;
}

.hilanaw-plan-card__currency {
    font-size: 16px;
    font-weight: 600;
    color: #6b7280;
    align-self: flex-start;
    margin-top: 4px;
}

.hilanaw-plan-card__period {
    font-size: 13px;
    color: #9ca3af;
    align-self: flex-end;
    margin-bottom: 3px;
}

/* Price loading skeleton */
.hilanaw-price-skeleton {
    display: inline-block;
    width: 100px;
    height: 36px;
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: hsp-shimmer 1.4s infinite;
    border-radius: 6px;
}

/* Savings badge */
.hilanaw-savings-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #15803d;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    border-radius: 20px;
    padding: 2px 9px;
    margin-left: 4px;
    white-space: nowrap;
    vertical-align: middle;
}

/* ============================================================
 * 8. Feature List
 * ============================================================ */

.hilanaw-plan-card__features {
    list-style: none;
    margin: 0 0 24px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.hilanaw-plan-card__features li {
    font-size: 13.5px;
    color: #374151;
    display: flex;
    align-items: flex-start;
    gap: 9px;
    line-height: 1.4;
}

.hilanaw-plan-card__features li::before {
    content: '';
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2316a34a'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 00-1.414 0L8 12.586 4.707 9.293a1 1 0 00-1.414 1.414l4 4a1 1 0 001.414 0l8-8a1 1 0 000-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
}

.hilanaw-plan-card.is-featured .hilanaw-plan-card__features li::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%237c3aed'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 00-1.414 0L8 12.586 4.707 9.293a1 1 0 00-1.414 1.414l4 4a1 1 0 001.414 0l8-8a1 1 0 000-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
}

/* Divider above features */
.hilanaw-plan-card__features-divider {
    height: 1px;
    background: #f3f4f6;
    margin: 0 0 16px;
}

/* ============================================================
 * 9. CTA Buttons
 * ============================================================ */

.hilanaw-plan-card__cta {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

/* Primary (upgrade / get started) */
.hilanaw-plan-card__cta.is-primary {
    background: linear-gradient(135deg, #0046a0 0%, #0066cc 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 70, 160, 0.2);
}

.hilanaw-plan-card__cta.is-primary:hover {
    background: linear-gradient(135deg, #003380 0%, #0055b3 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 70, 160, 0.28);
    color: #fff;
    text-decoration: none;
}

/* Pro CTA */
.hilanaw-plan-card.is-featured .hilanaw-plan-card__cta.is-primary {
    background: linear-gradient(135deg, #6d28d9 0%, #7c3aed 100%);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.2);
}

.hilanaw-plan-card.is-featured .hilanaw-plan-card__cta.is-primary:hover {
    background: linear-gradient(135deg, #5b21b6 0%, #6d28d9 100%);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

/* Current plan (disabled) */
.hilanaw-plan-card__cta.is-current {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    pointer-events: none;
}

/* Outline (secondary action) */
.hilanaw-plan-card__cta.is-outline {
    background: transparent;
    color: #0046a0;
    border: 1.5px solid #0046a0;
}

.hilanaw-plan-card__cta.is-outline:hover {
    background: #eff6ff;
    text-decoration: none;
}

/* ============================================================
 * 10. Savings Badge (yearly toggle)
 * ============================================================ */

/* Handled in section 7 above — .hilanaw-savings-badge */

/* ============================================================
 * 11. Guest Register Notice
 * ============================================================ */

.hilanaw-guest-notice {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 28px;
    font-size: 13.5px;
    color: #1e40af;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.5;
}

.hilanaw-guest-notice__icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.hilanaw-guest-notice a {
    color: #1d4ed8;
    font-weight: 600;
    text-decoration: underline;
}

.hilanaw-guest-notice a:hover {
    color: #1e40af;
}

/* ============================================================
 * 12. Section heading
 * ============================================================ */

.hilanaw-sub-page__heading {
    text-align: center;
    margin: 32px 0 8px;
}

.hilanaw-sub-page__heading h2 {
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 800;
    color: #111827;
    margin: 0 0 8px;
    line-height: 1.2;
}

.hilanaw-sub-page__heading p {
    font-size: 15px;
    color: #6b7280;
    margin: 0 0 28px;
}

/* ============================================================
 * 13. Animations
 * ============================================================ */

@keyframes hsp-slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes hsp-fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes hsp-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
 * 14. Responsive
 * ============================================================ */

@media (max-width: 640px) {
    .hilanaw-sub-page {
        padding: 0 12px 40px;
    }

    .hilanaw-plan-grid {
        grid-template-columns: 1fr;
    }

    .hilanaw-active-sub {
        flex-direction: column;
        gap: 10px;
        padding: 18px 16px;
    }

    .hilanaw-active-sub__icon {
        font-size: 1.5rem;
    }

    .hilanaw-cart-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px 16px;
    }

    .hilanaw-cart-bar__btn {
        width: 100%;
        text-align: center;
    }

    .hilanaw-billing-toggle {
        margin-bottom: 20px;
    }

    .hilanaw-plan-card {
        padding: 24px 18px 20px;
    }
}

@media (min-width: 641px) and (max-width: 900px) {
    .hilanaw-plan-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
