/**
 * Pay2Member Pro - V3 Professional Stylesheet
 * - Uses CSS variables for easy theming.
 * - Organized with clear sections.
 */

/* --- 1. Root Variables & Global Setup --- */
:root {
    --p2m-font-primary: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* Brand & Accent Colors */
    --p2m-color-primary: #007BFF;
    --p2m-color-primary-dark: #0056b3;
    --p2m-color-primary-light: #e6f7ff;

    /* Text Colors */
    --p2m-color-text-base: #212529;
    --p2m-color-text-muted: #6c757d;
    --p2m-color-text-light: #ADB5BD;

    /* Semantic Colors */
    --p2m-color-success: #28a745;
    --p2m-color-danger: #dc3545;
    --p2m-color-white: #fff;

    /* UI Element Colors */
    --p2m-color-background: #fff;
    --p2m-color-border: #e9ecef;
    --p2m-color-toggle-bg: #ccc;

    /* Sizing & Effects */
    --p2m-border-radius: 8px;
    --p2m-shadow-soft: 0 5px 15px rgba(0,0,0,0.03);
    --p2m-shadow-featured: 0 10px 25px rgba(0,123,255,0.15);
    --p2m-transition-speed: 0.3s;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

.p2m-pricing-container {
    max-width: 1100px;
    margin: 40px auto;
    padding: 0 20px;
    font-family: var(--p2m-font-primary);
}


/* --- 2. Billing Cycle Toggle --- */
.p2m-billing-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 40px;
}

.p2m-toggle-label {
    font-size: 1rem;
    font-weight: 500;
    color: var(--p2m-color-text-muted);
    margin: 0 12px;
}

.p2m-toggle-label.is-active {
    color: var(--p2m-color-text-base);
}

.p2m-toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.p2m-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.p2m-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--p2m-color-toggle-bg);
    transition: var(--p2m-transition-speed);
    border-radius: 28px;
}

.p2m-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: var(--p2m-color-white);
    transition: var(--p2m-transition-speed);
    border-radius: 50%;
}

input:checked + .p2m-toggle-slider {
    background-color: var(--p2m-color-primary);
}

input:checked + .p2m-toggle-slider:before {
    transform: translateX(22px);
}


/* --- 3. Pricing Cards --- */
.p2m-pricing-table-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
}

.p2m-plan {
    border: 1px solid var(--p2m-color-border);
    border-radius: var(--p2m-border-radius);
    padding: 30px;
    text-align: left;
    background-color: var(--p2m-color-background);
    box-shadow: var(--p2m-shadow-soft);
    transition: transform var(--p2m-transition-speed), box-shadow var(--p2m-transition-speed);
    display: flex;
    flex-direction: column;
}

.p2m-plan.is-featured {
    border-color: var(--p2m-color-primary);
    transform: translateY(-10px);
    box-shadow: var(--p2m-shadow-featured);
}

.p2m-plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.p2m-plan-name {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.p2m-plan-description {
    font-size: 0.9rem;
    color: var(--p2m-color-text-muted);
    min-height: 40px;
    margin-bottom: 25px;
}

.p2m-plan-price-wrapper {
    margin-bottom: 25px;
}

.p2m-plan-price {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
}

.p2m-plan-price .currency {
    font-size: 1.5rem;
    font-weight: 500;
    vertical-align: top;
    margin-right: 5px;
}

.p2m-plan-interval {
    font-size: 1rem;
    color: var(--p2m-color-text-muted);
}


/* --- 4. Plan Features & Badges --- */
.p2m-savings-badge {
    background-color: var(--p2m-color-primary-light);
    color: var(--p2m-color-primary);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 10px;
    flex-shrink: 0;
}

.p2m-plan-features {
    list-style: none;
    padding: 25px 0 0;
    margin: 25px 0 0;
    border-top: 1px solid var(--p2m-color-border);
    flex-grow: 1;
}

.p2m-plan-features li {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.p2m-plan-features li span:first-child {
    color: var(--p2m-color-text-muted);
}

.p2m-plan-features li .feature-value {
    font-weight: 600;
    color: var(--p2m-color-text-base);
}

.p2m-plan-features li .feature-value.is-yes {
    font-size: 0; /* Hide the "Yes" text */
}
.p2m-plan-features li .feature-value.is-yes::before {
    content: '✔';
    color: var(--p2m-color-success);
    font-size: 1.2rem;
}

.p2m-plan-features li .feature-value.is-no {
    font-size: 0; /* Hide the "No" text */
}
.p2m-plan-features li .feature-value.is-no::before {
    content: '✖';
    color: var(--p2m-color-danger);
    font-size: 1.2rem;
}

.p2m-savings-footer {
    display: none !important;
}


/* --- 5. Buttons --- */
.p2m-plan-button {
    display: block;
    width: 100%;
    padding: 15px;
    margin-top: auto; /* Pushes button to bottom if features list is short */
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    color: var(--p2m-color-primary);
    background-color: var(--p2m-color-primary-light);
    border-radius: var(--p2m-border-radius);
    transition: all 0.2s;
}

.p2m-plan.is-featured .p2m-plan-button {
    background-color: var(--p2m-color-primary);
    color: var(--p2m-color-white);
}

.p2m-plan-button:hover {
    background-color: var(--p2m-color-primary-dark);
    color: var(--p2m-color-white);
}

/* --- 6. Account Dashboard Styles --- */
.p2m-account-dashboard {
    background-color: #f9f9f9;
    border: 1px solid var(--p2m-color-border);
    border-radius: var(--p2m-border-radius);
    padding: 25px;
    max-width: 700px;
    margin: 20px auto;
    font-family: var(--p2m-font-primary);
}

.p2m-account-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
}

.p2m-account-table th, .p2m-account-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--p2m-color-border);
}

.p2m-account-table th {
    width: 30%;
    font-weight: 600;
    color: var(--p2m-color-text-muted);
}

.p2m-status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--p2m-color-white);
}

.p2m-status-active { background-color: var(--p2m-color-success); }
.p2m-status-pending { background-color: #ffc107; color: #212529; }
.p2m-status-cancelled { background-color: var(--p2m-color-danger); }

.p2m-account-actions p {
    color: var(--p2m-color-text-muted);
    font-size: 0.9rem;
}

.p2m-button-danger {
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--p2m-border-radius);
    cursor: pointer;
    border: 1px solid var(--p2m-color-danger);
    background-color: var(--p2m-color-danger);
    color: var(--p2m-color-white);
    transition: all 0.2s;
}
.p2m-button-danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
}
.p2m-button-danger:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#p2m-cancel-feedback.success { color: var(--p2m-color-success); font-weight: bold; }
#p2m-cancel-feedback.error { color: var(--p2m-color-danger); font-weight: bold; }
/* --- 2. Checkout Page Layout --- */
.p2m-checkout-container {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    max-width: 900px;
    margin: 40px auto;
    font-family: var(--p2m-font-primary);
    color: var(--p2m-color-text-body);
}

.p2m-order-summary {
    flex: 1;
    min-width: 280px;
    background-color: var(--p2m-color-background-light);
    padding: 30px;
    border-radius: var(--p2m-border-radius);
    height: fit-content;
}

.p2m-checkout-form-area {
    flex: 2;
    min-width: 400px;
}

/* --- 3. Order Summary Styles --- */
.p2m-order-summary .p2m-section-title {
    font-size: 1.3rem;
    color: var(--p2m-color-text-base);
    margin-top: 0;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--p2m-color-border);
}

.p2m-summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.p2m-summary-item.total {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--p2m-color-text-base);
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--p2m-color-border);
}

.p2m-secure-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 25px;
    font-size: 0.9rem;
    color: var(--p2m-color-text-muted);
}
.p2m-lock-icon {
    font-size: 1.1rem;
}

/* --- 4. Main Form Styles --- */
.p2m-form {
    width: 100%;
}

.p2m-form-section {
    margin-bottom: 30px;
}

.p2m-form-section .p2m-section-title {
    font-size: 1.2rem;
    color: var(--p2m-color-text-base);
    padding-bottom: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--p2m-color-border);
}

.p2m-form-group {
    margin-bottom: 20px;
}

.p2m-form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--p2m-color-text-base);
}

/* --- 5. Notifications & Form Controls --- */
.p2m-notice.info {
    color: var(--p2m-color-info-text);
    background-color: var(--p2m-color-info-bg);
    padding: 15px;
    border-radius: var(--p2m-border-radius);
    margin-bottom: 20px;
}

.p2m-error {
    color: var(--p2m-color-error-text);
    background-color: var(--p2m-color-error-bg);
    padding: 15px;
    border-radius: var(--p2m-border-radius);
    font-weight: 500;
}

.p2m-form-toggle, .p2m-legal-text {
    font-size: 0.9rem;
    color: var(--p2m-color-text-muted);
    text-align: center;
}
.p2m-form-toggle a, .p2m-legal-text a {
    color: var(--p2m-color-primary);
    text-decoration: none;
    font-weight: 500;
}
.p2m-form-toggle a:hover, .p2m-legal-text a:hover {
    text-decoration: underline;
}

.p2m-form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid #CED4DA; /* Standard border */
    border-radius: var(--p2m-border-radius);
    font-size: 1rem;
    font-family: var(--p2m-font-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: var(--p2m-color-white);
}

.p2m-form-control:focus {
    outline: none;
    border-color: var(--p2m-color-primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

.p2m-submit-button {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--p2m-color-white);
    background-color: var(--p2m-color-primary);
    border: none;
    border-radius: var(--p2m-border-radius);
    cursor: pointer;
    transition: background-color 0.2s;
}
.p2m-submit-button:hover {
    background-color: var(--p2m-color-primary-dark);
}
.p2m-submit-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/*
=====================================================
--- 6. THE CRITICAL IFRAME INTEGRATION STYLES (V3) ---
=====================================================
*/

/*
 * This is the most important rule. It targets the div holding our iframe
 * by its ID and makes the container itself completely INVISIBLE.
 * The !important flags are used to override any conflicting theme styles.
 */
#p2m-card-element.p2m-form-control {
    border: none !important;
    background-color: var(--p2m-color-white) !important;
    box-shadow: none !important;
    padding: 0 !important; /* Padding is handled inside the iframe now */
    min-height: 195px; /* ** THE FIX for the scrollbar **. Ensures enough vertical space. */
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}
/*
 * Apply focus styles to our container when the iframe inside is focused.
 * We will add a class with JS for this to work.
 */
/* We use a class added by our JS to apply focus styles,
   making it behave just like a native text input. */
#p2m-card-element.p2m-form-control.is-focused {
    border-color: var(--p2m-color-primary) !important;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2) !important;
}

/*
 * This rule ensures the iframe element that 2Checkout creates
 * properly fills the invisible container we made above.
 */
#p2m-card-element iframe {
    width: 100% !important;
    height: 100% !important;
    min-height: 190px;
    border: none !important; /* Ensure no default iframe borders */
}


/*
 * --- THE MAGIC: Mobile Responsive Re-ordering ---
 */
@media (max-width: 992px) {
    .p2m-checkout-layout-container {
        flex-direction: column; /* Stack vertically on mobile */
        gap: 32px;
    }

    .p2m-checkout-main-content {
        order: 2; /* Change order to appear SECOND on mobile */
    }

    .p2m-checkout-sidebar-summary {
        order: 1; /* Change order to appear FIRST on mobile */
        width: 100%;
        position: static; /* Un-stick on mobile */
        padding: 0; /* Optional: Remove padding on mobile if desired */
        background-color: transparent; /* Optional: Remove background on mobile */
    }
}

/* --- 7. Smart Pricing Table States --- */

.p2m-plan.is-current {
    border: 2px solid var(--p2m-color-success);
    background-color: #f8fdfa;
}

.p2m-plan-button:disabled {
    background-color: var(--p2m-color-toggle-bg);
    color: var(--p2m-color-text-muted);
    border-color: var(--p2m-color-border);
    cursor: not-allowed;
}

.p2m-plan.is-current .p2m-plan-button:disabled {
    background-color: var(--p2m-color-success);
    color: var(--p2m-color-white);
    opacity: 0.8;
}/* --- 8. Custom Login Form Styles --- */

.p2m-login-container {
    max-width: 450px;
    margin: 60px auto;
    padding: 20px;
    font-family: var(--p2m-font-primary);
}

.p2m-login-form-wrapper {
    background-color: var(--p2m-color-background);
    border: 1px solid var(--p2m-color-border);
    border-radius: var(--p2m-border-radius);
    padding: 40px;
    box-shadow: var(--p2m-shadow-soft);
}

.p2m-form-title {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 8px;
    color: var(--p2m-color-text-base);
}

.p2m-form-subtitle {
    text-align: center;
    color: var(--p2m-color-text-muted);
    margin-top: 0;
    margin-bottom: 30px;
}

#p2m-login-feedback {
    margin-bottom: 20px;
}

/* We can reuse the notice styles from the checkout page */
.p2m-notice {
    padding: 15px;
    border-radius: var(--p2m-border-radius);
    font-weight: 500;
}
.p2m-notice.error {
    color: #721c24; /* Darker red for text */
    background-color: #f8d7da; /* Light red background */
    border: 1px solid #f5c6cb;
}
.p2m-notice.success {
    color: #155724; /* Darker green for text */
    background-color: #d4edda; /* Light green background */
    border: 1px solid #c3e6cb;
}


.p2m-form-footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--p2m-color-border);
    font-size: 0.9rem;
}

.p2m-form-footer p {
    margin: 10px 0;
    color: var(--p2m-color-text-muted);
}

.p2m-form-footer a {
    color: var(--p2m-color-primary);
    font-weight: 500;
    text-decoration: none;
}
.p2m-form-footer a:hover {
    text-decoration: underline;
}
/* --- 9. Multi-Step Checkout Styles --- */

.p2m-progress-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
}

.p2m-progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--p2m-color-text-light);
    transition: color 0.4s;
}

.p2m-progress-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--p2m-color-white);
    border: 2px solid var(--p2m-color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: background-color 0.4s, border-color 0.4s;
}

.p2m-progress-label {
    margin-top: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.p2m-progress-line {
    flex-grow: 1;
    height: 2px;
    background-color: var(--p2m-color-border);
    margin: 0 10px;
    transform: translateY(-18px); /* Align with center of dots */
}

/* Active/Completed Step Styles */
.p2m-progress-step.is-active .p2m-progress-dot {
    border-color: var(--p2m-color-primary);
    background-color: var(--p2m-color-primary);
    color: var(--p2m-color-white);
}

.p2m-progress-step.is-active {
    color: var(--p2m-color-text-base);
}

.p2m-progress-step.is-complete .p2m-progress-dot {
    border-color: var(--p2m-color-success);
    background-color: var(--p2m-color-success);
    color: var(--p2m-color-white);
}
.p2m-progress-step.is-complete .p2m-progress-dot::before {
    content: '✔';
    font-size: 1.1rem;
}
.p2m-progress-step.is-complete {
    color: var(--p2m-color-text-base);
}


/* Step Visibility */
.p2m-checkout-step {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}
.p2m-checkout-step.is-active-step {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Step Navigation Buttons */
.p2m-form-navigation {
    display: flex;
    gap: 15px;
}

.p2m-secondary-button {
    padding: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    background-color: transparent;
    color: var(--p2m-color-text-muted);
    border: 1px solid var(--p2m-color-border);
    border-radius: var(--p2m-border-radius);
    cursor: pointer;
    transition: all 0.2s;
}
.p2m-secondary-button:hover {
    border-color: var(--p2m-color-text-base);
    color: var(--p2m-color-text-base);
}

/* --- 10. Modern SaaS Dashboard Layout --- */

.p2m-dashboard {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    max-width: 1200px;
    margin: 40px auto;
    font-family: var(--p2m-font-primary);
}

.p2m-dashboard__sidebar {
    flex: 1;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.p2m-dashboard__main {
    flex: 2.5;
    min-width: 450px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* --- Profile & Sidebar Cards --- */
.p2m-profile-card, .p2m-sidebar-card, .p2m-content-card {
    background-color: var(--p2m-color-white);
    border: 1px solid var(--p2m-color-border);
    border-radius: var(--p2m-border-radius);
    padding: 25px;
    box-shadow: var(--p2m-shadow-soft);
}

.p2m-profile-card {
    text-align: center;
}
.p2m-profile-card__avatar {
    border-radius: 50%;
    margin-bottom: 15px;
    border: 3px solid var(--p2m-color-white);
    box-shadow: var(--p2m-shadow-soft);
}
.p2m-profile-card__name {
    margin: 0 0 5px 0;
    font-size: 1.3rem;
    color: var(--p2m-color-text-base);
}
.p2m-profile-card__email {
    margin: 0;
    color: var(--p2m-color-text-muted);
}

.p2m-sidebar-card h4 {
    margin-top: 0;
    font-size: 1.1rem;
}
.p2m-sidebar-card p {
    font-size: 0.9rem;
    color: var(--p2m-color-text-muted);
    line-height: 1.5;
}

/* --- Main Content Cards --- */
.p2m-content-card h3 {
    margin-top: 0;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--p2m-color-border);
}

.p2m-details-list {
    margin: 0;
    padding: 0;
}
.p2m-details-list div {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--p2m-color-border);
}
.p2m-details-list div:last-child {
    border-bottom: none;
}
.p2m-details-list dt {
    color: var(--p2m-color-text-muted);
}
.p2m-details-list dd {
    margin: 0;
    font-weight: 500;
    color: var(--p2m-color-text-base);
}

/* --- Billing History Styles --- */
.p2m-billing-history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.p2m-billing-history-item {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 15px;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--p2m-color-border);
}
.p2m-billing-history-item:last-child {
    border-bottom: none;
}
.p2m-billing-history-item .date {
    font-weight: 500;
}
.p2m-billing-history-item .status-paid {
    color: var(--p2m-color-success);
    font-weight: 600;
}
.p2m-billing-history-item .total {
    font-weight: 600;
    text-align: right;
}
#p2m-billing-history-container .p2m-notice { margin-top: 15px; }


/* --- Loader & Spinner --- */
.p2m-billing-history__loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 0;
    color: var(--p2m-color-text-muted);
}
.p2m-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--p2m-color-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: p2m-spin 1s linear infinite;
    margin-bottom: 15px;
}
@keyframes p2m-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Stacking */
@media (max-width: 992px) {
    .p2m-dashboard {
        flex-direction: column;
    }
}