/**
 * MemberPress credit selector styles
 * 
 * Styles for the Early Bird credit package selector 
 * that appears in the MemberPress registration form.
 *
 * @package TIST_26_Comp_Early_Birds
 * @since 1.1.0
 */

/* Wrapper */
.tist-eb-credit-selector-wrapper {
    margin: 0 0 1em 0;
    padding: 1em;
    background: #f0f4f8;
    border-radius: 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background: #f0f4f8 !important; /* Fallback for old browsers */
    background: -webkit-linear-gradient(#f0f4f8 52%, #ccdceb) !important; /* Chrome 10-25, Safari 5.1-6 */
    background: -moz-linear-gradient(#f0f4f8 52%, #ccdceb) !important; /* Firefox 3.6-15 */
    background: -o-linear-gradient(#f0f4f8 52%, #ccdceb) !important; /* Opera 11.1-12 */
    background: linear-gradient(#f0f4f8 52%, #ccdceb) !important; /* Standard syntax */
}x

/* Header */
.tist-eb-credit-header {
    margin-bottom: 24px;
    text-align: center;
}

.tist-eb-credit-title {
    margin: 0 0 8px 0;
    font-size: 1.5em;
    font-weight: 700;
    color: #1e3a5f;
}

.tist-eb-icon {
    margin-right: 8px;
}

.tist-eb-credit-description {
    margin: 0;
    font-size: 0.95em;
    color: #5a6c7d;
    line-height: 1.5;
}

/* Currency Selector */
.tist-eb-currency-selector {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin-bottom: 24px;
}

.tist-eb-currency-selector label {
    white-space: nowrap;
}

.tist-eb-currency-dropdown {
    padding: 10px 16px;
    font-size: 1em;
    font-weight: 500;
    border: 2px solid #d1d9e0;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: auto !important;
    min-width: 160px;
    flex-shrink: 0;
}

.tist-eb-currency-dropdown:hover,
.tist-eb-currency-dropdown:focus {
    border-color: #2563eb;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Package Grid */
.tist-eb-packages {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 1fr;
    gap: 1em;
    margin-bottom: 2em;
}

/* Individual Package Card */
.tist-eb-package {
    position: relative;
    display: grid !important;
    grid-template-rows: auto auto auto 1fr auto !important;
    background: #fff;
    border: 2px solid #ffffff;
    border-radius: 1em;
    padding: 1em;
    text-align: center;
    transition: all 0.3s ease;
}

.tist-eb-package:hover {
    border-color: #2563eb;
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.15);
}

.tist-eb-package input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.tist-eb-package:has(input:checked) {
    border-color: #2563eb;
    border-width: 2px;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.2);
}

/* Badge styles */
.tist-eb-badge {
    position: absolute;
    top: -17px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 16px;
    font-size: 0.7em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 20px;
    color: #fff;
    white-space: nowrap;
}

.tist-eb-badge-popular {
    background: #2563eb;
}

.tist-eb-badge-value {
    background: #4caf50;
}

/* Popular package highlight - only this one has a visible border */
.tist-eb-package.tist-eb-popular {
    border-color: #2563eb;
}

.tist-eb-package.tist-eb-popular:has(input:checked) {
    border-color: #2563eb;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.25);
}

/* Best value package - no border, just badge */
.tist-eb-package.tist-eb-best-value {
    border-color: #ffffff;
}

.tist-eb-package.tist-eb-best-value:has(input:checked) {
    border-color: #4caf50;
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.25);
}

/* Package content - block display for vertical stacking */
.tist-eb-package-name {
    display: block;
    margin: 1em 0;
    font-size: 1.1em;
    color: #1e293b;
    font-weight: 700;
}

.tist-eb-package-price {
    display: block;
    font-size: 2.5em;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 8px;
    line-height: 1.2;
}

.tist-eb-package-per-credit {
    display: block;
    font-size: 0.9em;
    color: #64748b;
    margin: 0 0 10px;
}

/* Savings wrapper - aligns to bottom of its grid cell */
.tist-eb-savings-wrapper {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 15px;
}

/* Savings badge */
.tist-eb-savings {
    display: inline-block;
    padding: 4px 12px;
    background: #dcfce7;
    color: #166534;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
}

/* Select button */
.tist-eb-select-btn {
    display: block;
    width: 100%;
    padding: 14px 24px;
    font-size: 1em;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tist-eb-package:hover .tist-eb-select-btn {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.tist-eb-package:has(input:checked) .tist-eb-select-btn {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
}

.tist-eb-package.tist-eb-best-value .tist-eb-select-btn {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
}

.tist-eb-package.tist-eb-best-value:hover .tist-eb-select-btn {
    background: linear-gradient(135deg, #15803d 0%, #166534 100%);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.tist-eb-package.tist-eb-best-value:has(input:checked) .tist-eb-select-btn {
    background: #388e3c;
}

/* Selection confirmation */
.tist-eb-credit-notice {
    margin-top: 20px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-radius: 10px;
    border: 2px solid #4caf50;
}

.tist-eb-credit-notice p {
    margin: 0;
    font-size: 1em;
    color: #2e7d32;
    line-height: 1.6;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.tist-eb-confirm-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #4caf50;
    color: #fff;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
}

.tist-eb-confirm-text {
    flex: 1;
}

.tist-eb-selected-package {
    color: #1b5e20;
    font-weight: 700;
}

/* Stripe footer */
.tist-eb-stripe-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85em;
    color: #7a8b9a;
}

/* Disabled submit button state */
.mepr-submit.tist-eb-btn-disabled,
.mepr-submit:disabled {
    background: #94a3b8 !important;
    cursor: not-allowed !important;
    opacity: 0.7;
    border-color: #94a3b8 !important;
    padding: 10px 35px 12px;
    font: 14px system-ui, -apple-system, BlinkMacSystemFont, Poppins, Helvetica Neue, Helvetica, Tahoma, Arial, sans-serif !important;
}

/* Hide MemberPress price banner when our credit selector is present */
.mepr-signup-form:has(.tist-eb-credit-selector-wrapper) .mp-form-row.mepr_bold.mepr_price {
    display: none !important;
}

/* ================================================================
   REGISTRATION FIELDS WRAPPER
   Narrower container centered below the credit selector
   ================================================================ */
.tist-eb-registration-fields-wrapper {
    max-width: 680px;
    margin: 0 auto;
    padding-top: 1em;
}

/* Two-column layout for registration form fields inside the wrapper */
.tist-eb-registration-fields-wrapper {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 24px;
}

/* Make password strength row span full width */
.tist-eb-registration-fields-wrapper .mp-form-row:has(.mepr-password-meter),
.tist-eb-registration-fields-wrapper .mp-form-row.mp-password-strength-area {
    grid-column: 1 / -1;
    margin-bottom: 2em;
}

/* Make checkbox rows span full width */
.tist-eb-registration-fields-wrapper .mp-form-row:has(input[type="checkbox"]) {
    grid-column: 1 / -1;
    margin: 0;
}

/* Make submit button row span full width */
.tist-eb-registration-fields-wrapper .mp-form-row:has(input[type="submit"]),
.tist-eb-registration-fields-wrapper .mp-form-row:has(button[type="submit"]),
.tist-eb-registration-fields-wrapper .mp-form-submit {
    grid-column: 1 / -1;
}

.tist-eb-registration-fields-wrapper .mp-form-submit {
    margin-top: 1em;
}

/* Make error message rows span full width */
.tist-eb-registration-fields-wrapper .mp-form-row.mepr_error,
.tist-eb-registration-fields-wrapper .mp-form-row:has(.mepr-form-has-errors) {
    grid-column: 1 / -1;
}

/* Mobile responsive - revert to single column */
@media (max-width: 768px) {
    .tist-eb-registration-fields-wrapper {
        grid-template-columns: 1fr;
        max-width: 100%;
        padding-left: 0;
        padding-right: 0;
    }
    
    .tist-eb-registration-fields-wrapper .mp-form-row {
        grid-column: 1;
    }
}

/* Loading state */
.tist-eb-credit-selector-wrapper.tist-eb-loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.tist-eb-credit-selector-wrapper.tist-eb-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b5998;
    border-radius: 50%;
    animation: tist-eb-spin 0.8s linear infinite;
}

@keyframes tist-eb-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .tist-eb-packages {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .tist-eb-packages {
        grid-template-columns: 1fr;
    }
    
    .tist-eb-credit-selector-wrapper {
        padding: 20px;
        margin: 0 0 20px 0;
    }
    
    .tist-eb-credit-title {
        font-size: 1.3em;
    }
    
    .tist-eb-package {
        padding: 20px 16px;
    }
    
    
    .tist-eb-package-price {
        font-size: 2em;
    }
    
    .tist-eb-currency-selector {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
}
