body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f0f2f5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.purchase-container {
    width: 100%;
    max-width: 600px;
}

.purchase-form-wrapper {
    background-color: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 10px;
}

.purchase-form-wrapper > p {
    text-align: center;
    color: #666;
    margin-bottom: 10px;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.form-group input[type="email"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    box-sizing: border-box;
}

.package-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.package-option {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.package-option input[type="radio"] {
    display: none;
}

.package-option:hover {
    border-color: #007bff;
    box-shadow: 0 0 10px rgba(0,123,255,0.2);
}

input[type="radio"]:checked + .package-details {
    /* This style is applied via JS or within a parent selector in more complex setups */
}

input[type="radio"]:checked ~ .package-details {
    /* A sibling selector might not work if input is inside label. We'll use border on parent. */
}
.package-option input[type="radio"]:checked {
    /* To show selection, we style the parent label */
}
label:has(input:checked) {
    border-color: #007bff;
    background-color: #f0f8ff;
}

.package-details h3 {
    margin: 0 0 10px 0;
    color: #0056b3;
}
.package-details .price {
    font-size: 24px;
    font-weight: bold;
    color: #28a745;
    margin: 0 0 5px 0;
}
.package-details .duration {
    font-size: 14px;
    color: #ff0000;
    margin: 0;
}

.payment-info {
    background-color: #e9f7ef;
    border: 1px solid #a3e0c0;
    border-radius: 6px;
    padding: 20px;
    margin-top: 30px;
}

.payment-info p { margin: 5px 0; }

button[type="submit"] {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    background-color: #28a745;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 30px;
    transition: background-color 0.2s;
}

button[type="submit"]:hover {
    background-color: #218838;
}

.message {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 6px;
    text-align: center;
}
.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ... โค้ด CSS เดิม ... */
.form-group input[type="file"] {
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 6px;
    display: block;
    width: 100%;
    box-sizing: border-box;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #6c757d;
}

/* --- Payment Method Radio Options --- */
.payment-method-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.payment-method-option {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.payment-method-option input[type="radio"] {
    display: none; /* ซ่อน radio button ดั้งเดิม */
}

.payment-method-option:hover {
    border-color: #007bff;
    box-shadow: 0 0 10px rgba(0,123,255,0.1);
}

/* ใช้ :has() เพื่อสไตล์ label เมื่อ radio ข้างในถูก checked */
label.payment-method-option:has(input:checked) {
    border-color: #007bff;
    background-color: #f0f8ff;
}

.payment-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}
.payment-icon {
    font-size: 28px;
    line-height: 1;
}
.payment-details strong {
    font-size: 16px;
}
.payment-details small {
    font-size: 12px;
    color: #666;
}

.payment-icon-img {
    width: 40px;  /* กำหนดขนาดความกว้าง */
    height: 40px; /* กำหนดขนาดความสูง */
    margin-bottom: 8px; /* ระยะห่างด้านล่าง */
    object-fit: contain; /* ทำให้ภาพพอดีกับกรอบโดยไม่เสียสัดส่วน */
}

/* ลบสไตล์ของ emoji icon เก่า ถ้ามี */
.payment-icon {
    display: none; 
}

/* ... โค้ด CSS เดิม ... */

/* --- Order Summary Styles --- */
.order-summary {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin-top: 25px;
    margin-bottom: 25px;
}

.order-summary h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 18px;
    color: #333;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 10px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 16px;
}

.summary-item span:first-child {
    color: #6c757d;
}

.summary-item span:last-child {
    font-weight: 500;
    color: #212529;
}

.summary-item.total {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
    font-size: 20px;
}

.summary-item.total span {
    font-weight: bold;
    color: #28a745;
}

/* ... โค้ด CSS เดิม ... */

/* --- Order Summary Styles --- */
.order-summary {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin-top: 25px;
    margin-bottom: 25px;
}

.order-summary h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 18px;
    color: #333;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 10px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 16px;
}

.summary-item span:first-child {
    color: #6c757d;
}

.summary-item span:last-child {
    font-weight: 500;
    color: #212529;
}

.summary-item.total {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
    font-size: 20px;
}

.summary-item.total span {
    font-weight: bold;
    color: #28a745;
}

/* ... โค้ด CSS เดิม ... */

/* --- Spinner Styles --- */
.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: #09f;
    animation: spin 1s ease infinite;
    margin: 20px auto 0 auto; /* จัดให้อยู่กลางเมื่อปุ่มหายไป */
}

.spinner.hidden {
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ... โค้ด CSS เดิม ... */

/* --- Inline Spinner for Payment Element --- */
.spinner-inline {
    border: 3px solid rgba(0, 0, 0, 0.1);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border-left-color: #09f;
    animation: spin 1s ease infinite;
    margin: 20px auto;
}

.text-center {
    text-align: center;
}

.btn-primary {
    background-color: #007bff;
    width: 100%;
    padding: 10px;
    font-size: 15px;
    font-weight: bold;
    color: #fff; 
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 25px;
    transition: background-color 0.2s;
}