/* =====================
   Subscription Modal - Hybrid Bottom Sheet / Centered Dialog
   ===================== */

/* Backdrop */
.sub-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: flex-end;          /* Bottom sheet on mobile */
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Panel - Mobile first (bottom sheet) */
.sub-modal-panel {
    width: 100%;
    max-height: 90vh;
    background: var(--color-bg, #ffffff);
    border-radius: var(--radius-lg, 16px) var(--radius-lg, 16px) 0 0;
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.3s ease;
}

/* Desktop: centered modal */
@media (min-width: 640px) {
    .sub-modal-backdrop {
        align-items: center;
    }

    .sub-modal-panel {
        max-width: 480px;
        max-height: 85vh;
        border-radius: var(--radius-lg, 16px);
        box-shadow: var(--shadow-lg, 0 4px 16px rgba(0, 0, 0, 0.1));
        transform: scale(0.95);
        opacity: 0;
    }
}

/* Header */
.sub-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem 0.75rem;
    position: sticky;
    top: 0;
    background: var(--color-bg, #ffffff);
    z-index: 1;
}

/* Drag handle on mobile */
.sub-modal-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--color-border, #e5e7eb);
}

@media (min-width: 640px) {
    .sub-modal-header::before {
        display: none;
    }
}

.sub-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text, #1f2937);
    margin: 0;
}

.sub-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--color-text-muted, #9ca3af);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    touch-action: manipulation;
}

.sub-modal-close:hover {
    background: var(--color-bg-subtle, #f9fafb);
    color: var(--color-text, #1f2937);
}

/* Body */
.sub-modal-body {
    padding: 0.75rem 1.5rem 1.5rem;
    flex: 1;
    overflow-y: auto;
}

.sub-modal-subtitle {
    font-size: 0.9375rem;
    color: var(--color-text-secondary, #6b7280);
    margin: 0 0 1.25rem;
    line-height: 1.5;
}

/* =====================
   Plan List (Step 1)
   ===================== */

.sub-plan-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.sub-plan-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border: 1.5px solid var(--color-border, #e5e7eb);
    border-radius: var(--radius-md, 12px);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    min-height: 52px;
    user-select: none;
    touch-action: manipulation;
}

.sub-plan-option:hover {
    border-color: var(--color-primary, #2563eb);
    background: var(--color-primary-light, #eff6ff);
}

.sub-plan-option.selected {
    border-color: var(--color-primary, #2563eb);
    background: var(--color-primary-light, #eff6ff);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.sub-plan-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.sub-plan-radio {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border, #e5e7eb);
    border-radius: 50%;
    position: relative;
    transition: border-color 0.15s;
}

.sub-plan-option.selected .sub-plan-radio,
.sub-plan-option input:checked ~ .sub-plan-radio {
    border-color: var(--color-primary, #2563eb);
}

.sub-plan-option.selected .sub-plan-radio::after,
.sub-plan-option input:checked ~ .sub-plan-radio::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-primary, #2563eb);
}

.sub-plan-label {
    flex: 1;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text, #1f2937);
}

.sub-plan-price {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--color-text, #1f2937);
    white-space: nowrap;
}

/* =====================
   Buttons
   ===================== */

.sub-modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md, 12px);
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 52px;
    width: 100%;
    font-family: var(--font-family, 'Inter', sans-serif);
    touch-action: manipulation;
}

.sub-modal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sub-modal-btn-primary {
    background: var(--color-primary, #2563eb);
    color: #ffffff;
}

.sub-modal-btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover, #1d4ed8);
}

.sub-modal-btn-ghost {
    background: transparent;
    color: var(--color-text-secondary, #6b7280);
    border: 1px solid var(--color-border, #e5e7eb);
}

.sub-modal-btn-ghost:hover {
    background: var(--color-bg-subtle, #f9fafb);
    color: var(--color-text, #1f2937);
}

/* =====================
   Step 2: Payment
   ===================== */

.sub-payment-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--color-bg-subtle, #f9fafb);
    border-radius: var(--radius-md, 12px);
    margin-bottom: 1.25rem;
    border: 1px solid var(--color-border, #e5e7eb);
}

.sub-payment-plan-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text, #1f2937);
}

.sub-payment-plan-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-primary, #2563eb);
}

.sub-payment-steps {
    margin-bottom: 1.25rem;
}

.sub-payment-steps-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text, #1f2937);
    margin: 0 0 0.75rem;
}

.sub-payment-steps-list {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary, #6b7280);
    line-height: 1.8;
}

.sub-payment-steps-list strong {
    color: var(--color-text, #1f2937);
}

.sub-till-number {
    font-size: 1rem;
    color: var(--color-primary, #2563eb);
    letter-spacing: 0.5px;
}

.sub-payment-info {
    background: var(--color-bg-subtle, #f9fafb);
    border-radius: var(--radius-md, 12px);
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--color-border, #e5e7eb);
}

.sub-payment-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.sub-payment-info-row:not(:last-child) {
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.sub-payment-info-label {
    font-size: 0.8125rem;
    color: var(--color-text-muted, #9ca3af);
    font-weight: 500;
}

.sub-payment-info-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text, #1f2937);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.sub-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 6px;
    background: transparent;
    color: var(--color-text-muted, #9ca3af);
    cursor: pointer;
    transition: all 0.15s;
    touch-action: manipulation;
    flex-shrink: 0;
}

.sub-copy-btn:hover {
    background: var(--color-bg-subtle, #f9fafb);
    color: var(--color-text, #1f2937);
    border-color: var(--color-text-muted, #9ca3af);
}

.sub-copy-btn.copied {
    color: #059669;
    border-color: #059669;
    background: #ecfdf5;
}

.sub-payment-note {
    font-size: 0.8125rem;
    color: var(--color-text-muted, #9ca3af);
    line-height: 1.6;
    margin-bottom: 0;
    text-align: center;
}

.sub-whatsapp-link {
    color: #25D366;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.sub-whatsapp-link svg {
    flex-shrink: 0;
    vertical-align: middle;
}

.sub-whatsapp-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* =====================
   Phone Input Field
   ===================== */

.sub-phone-field {
    margin-bottom: 1.25rem;
}

.sub-phone-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text, #1f2937);
    margin-bottom: 0.375rem;
}

.sub-phone-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1.5px solid var(--color-border, #e5e7eb);
    border-radius: var(--radius-md, 12px);
    background: var(--color-bg, #ffffff);
    color: var(--color-text, #1f2937);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: var(--font-family, 'Inter', sans-serif);
    box-sizing: border-box;
}

.sub-phone-input:focus {
    border-color: var(--color-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.sub-phone-input.valid {
    border-color: #059669;
}

.sub-phone-input.valid:focus {
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.sub-phone-input.invalid {
    border-color: #dc2626;
}

.sub-phone-input.invalid:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.sub-phone-error {
    display: block;
    font-size: 0.8125rem;
    color: #dc2626;
    margin-top: 0.375rem;
    min-height: 1.2em;
}

.sub-phone-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted, #9ca3af);
    margin-top: 0.25rem;
    line-height: 1.4;
}

.sub-payment-actions {
    display: flex;
    gap: 0.75rem;
}

.sub-payment-actions .sub-modal-btn {
    flex: 1;
}

/* =====================
   Mobile Adjustments
   ===================== */

@media (max-width: 480px) {
    .sub-modal-body {
        padding: 0.75rem 1.25rem 1.25rem;
    }

    .sub-plan-option {
        padding: 0.75rem 0.875rem;
        min-height: 48px;
    }

    .sub-plan-label {
        font-size: 0.875rem;
    }

    .sub-plan-price {
        font-size: 0.875rem;
    }

    .sub-payment-actions {
        flex-direction: column;
    }
}

/* =====================
   Learner Theme (emerald/teal)
   ===================== */

.sub-modal-backdrop.learner-theme {
    --sub-accent: #059669;
    --sub-accent-hover: #047857;
    --sub-accent-light: #ecfdf5;
    --sub-accent-ring: rgba(5, 150, 105, 0.12);
}

.learner-theme .sub-plan-option:hover,
.learner-theme .sub-plan-option.selected {
    border-color: var(--sub-accent);
    background: var(--sub-accent-light);
}

.learner-theme .sub-plan-option.selected {
    box-shadow: 0 0 0 3px var(--sub-accent-ring);
}

.learner-theme .sub-plan-option.selected .sub-plan-radio,
.learner-theme .sub-plan-option input:checked ~ .sub-plan-radio {
    border-color: var(--sub-accent);
}

.learner-theme .sub-plan-option.selected .sub-plan-radio::after,
.learner-theme .sub-plan-option input:checked ~ .sub-plan-radio::after {
    background: var(--sub-accent);
}

.learner-theme .sub-modal-btn-primary {
    background: var(--sub-accent);
}

.learner-theme .sub-modal-btn-primary:hover:not(:disabled) {
    background: var(--sub-accent-hover);
}

.learner-theme .sub-payment-plan-price,
.learner-theme .sub-till-number {
    color: var(--sub-accent);
}

.learner-theme .sub-phone-input:focus {
    border-color: var(--sub-accent);
    box-shadow: 0 0 0 3px var(--sub-accent-ring);
}

/* =====================
   Landscape Adjustments
   ===================== */

@media (orientation: landscape) and (max-height: 500px) {
    .sub-modal-panel {
        max-height: 95vh;
    }

    .sub-modal-header {
        padding: 1rem 1.25rem 0.5rem;
    }

    .sub-modal-body {
        padding: 0.5rem 1.25rem 1rem;
    }

    .sub-plan-option {
        padding: 0.625rem 0.875rem;
        min-height: 44px;
    }
}

/* Confirmation Checkbox */
.sub-confirm-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.75rem;
    margin-top: 0.875rem;
    margin-bottom: 1rem;
    background: var(--color-surface-alt, #f0fdf4);
    border: 1.5px solid var(--color-border, #d1d5db);
    border-radius: var(--radius-md, 10px);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.sub-confirm-checkbox:has(input:checked) {
    border-color: var(--color-primary, #10b981);
    background: var(--color-surface-alt, #ecfdf5);
}

.sub-confirm-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.sub-confirm-checkmark {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border, #d1d5db);
    border-radius: 4px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-top: 1px;
}

.sub-confirm-checkbox input:checked ~ .sub-confirm-checkmark {
    background: var(--color-primary, #10b981);
    border-color: var(--color-primary, #10b981);
}

.sub-confirm-checkbox input:checked ~ .sub-confirm-checkmark::after {
    content: '';
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.sub-confirm-text {
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--color-text, #374151);
    font-weight: 500;
}

/* Teacher theme */
.sub-modal-backdrop:not(.learner-theme) .sub-confirm-checkbox:has(input:checked) {
    border-color: var(--color-primary, #3b82f6);
}

.sub-modal-backdrop:not(.learner-theme) .sub-confirm-checkbox input:checked ~ .sub-confirm-checkmark {
    background: var(--color-primary, #3b82f6);
    border-color: var(--color-primary, #3b82f6);
}
