/**
 * Ryc Confirm — สไตล์ฟอร์มหน้าบ้าน
 * โทนสี/ระยะห่างอ้างอิงจากฟอร์มเดิม (Seed Confirm Pro) ที่ลูกค้าคุ้นเคยอยู่แล้ว:
 * inp border #d5d5d7 radius 5px, ปุ่ม/สีเน้น #235b95, label #222
 */

:root {
	--ryc-accent: #235b95;
	--ryc-accent-dark: #1b4771;
	--ryc-border: #d5d5d7;
	--ryc-text: #222222;
	--ryc-radius: 5px;
}

.ryc-confirm-form-wrap {
	max-width: 640px;
	margin: 0 auto;
}

/* ส่วนหัวเมื่อฟอร์มถูกแสดงอัตโนมัติในหน้า Order received ของ WooCommerce
   (ดู RycConfirm_Order_Integration::render_confirm_form_on_thankyou) */
.ryc-confirm-thankyou-section {
	max-width: 640px;
	margin: 2em auto 0;
}

.ryc-confirm-thankyou-heading {
	margin-bottom: 0.6em;
}

.ryc-confirm-form .ryc-field {
	margin: 0 0 1.2em;
}

.ryc-confirm-form .ryc-field-row {
	display: flex;
	flex-wrap: wrap;
	gap: 1em;
}

.ryc-confirm-form .ryc-field-row .ryc-field {
	flex: 1 1 220px;
	min-width: 0;
}

.ryc-confirm-form label {
	display: block;
	font-weight: 600;
	font-size: 15px;
	color: var(--ryc-text);
	margin-bottom: 0.4em;
}

/* .ryc-bank-card เป็น <label> ด้วย (ใช้คลิกทั้งการ์ดเลือกวิทยุได้) — กฎ display:block ด้านบน
   ชนะ .ryc-bank-card { display:flex } เพราะ specificity สูงกว่า (1 class + 1 type > 1 class)
   บังคับ flex กลับด้วย selector ที่จำเพาะกว่า ไม่ให้ QR/เนื้อหาตกไปอยู่คนละบรรทัด */
.ryc-confirm-form .ryc-bank-card {
	display: flex;
	margin-bottom: 0;
}

.ryc-confirm-form input[type="text"],
.ryc-confirm-form input[type="tel"],
.ryc-confirm-form input[type="email"],
.ryc-confirm-form input[type="number"],
.ryc-confirm-form input[type="date"],
.ryc-confirm-form input[type="time"],
.ryc-confirm-form select,
.ryc-confirm-form textarea {
	width: 100%;
	box-sizing: border-box;
	padding: 0.6em 0.75em;
	border: 1px solid var(--ryc-border);
	border-radius: var(--ryc-radius);
	font-size: 16px;
	color: var(--ryc-text);
	background: #fff;
	transition: border-color 0.15s ease;
}

.ryc-confirm-form input[type="file"] {
	width: 100%;
	font-size: 15px;
}

.ryc-confirm-form input:focus,
.ryc-confirm-form select:focus,
.ryc-confirm-form textarea:focus {
	outline: none;
	border-color: var(--ryc-accent);
	box-shadow: 0 0 0 3px rgba(35, 91, 149, 0.12);
}

.ryc-confirm-form .required {
	color: #c0392b;
}

.ryc-confirm-form .ryc-field-hint {
	display: block;
	font-size: 0.85em;
	color: #666;
	margin-top: 0.35em;
}

/* คำสั่งซื้อจากลิงก์ (?orderid=) ไม่อยู่ในรายการที่แจ้งได้ */
.ryc-confirm-form .ryc-field-notice {
	margin: 0 0 1em;
	padding: 0.7em 0.9em;
	border-left: 4px solid #d98e04;
	background: #fff8e5;
	color: var(--ryc-text);
	border-radius: var(--ryc-radius);
	font-size: 0.95em;
}

/* -------- slip preview -------- */
.ryc-slip-preview[hidden] {
	display: none;
}

.ryc-slip-preview {
	display: block;
	margin-top: 0.6em;
}

.ryc-slip-preview img {
	max-width: 160px;
	max-height: 160px;
	border: 1px solid var(--ryc-border);
	border-radius: var(--ryc-radius);
	padding: 4px;
	background: #fff;
}

/* -------- bank / promptpay card selector -------- */
.ryc-bank-list {
	display: flex;
	flex-direction: column;
	gap: 0.6em;
}

.ryc-bank-card {
	display: flex;
	align-items: flex-start;
	gap: 0.75em;
	position: relative;
	border: 1px solid var(--ryc-border);
	border-radius: var(--ryc-radius);
	padding: 0.85em 1em;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ryc-bank-card:hover {
	border-color: #adadb0;
}

.ryc-bank-card input[type="radio"] {
	margin-top: 0.25em;
	flex: 0 0 auto;
	accent-color: var(--ryc-accent);
	width: 18px;
	height: 18px;
}

.ryc-bank-card.is-selected {
	border: 2px solid var(--ryc-accent);
	background: rgba(35, 91, 149, 0.04);
	padding: calc(0.85em - 1px) calc(1em - 1px);
}

.ryc-bank-card-body {
	display: flex;
	flex-direction: column;
	gap: 0.2em;
	flex: 1 1 auto;
}

.ryc-bank-card-row {
	font-size: 14px;
	color: #444;
	display: flex;
	gap: 0.4em;
	align-items: baseline;
	flex-wrap: wrap;
}

.ryc-bank-card-title {
	font-weight: 700;
	font-size: 16px;
	color: var(--ryc-text);
}

.ryc-bank-card-key {
	color: #777;
	min-width: 130px;
}

.ryc-bank-card-number {
	font-size: 16px;
	letter-spacing: 0.02em;
	color: var(--ryc-text);
}

.ryc-bank-card-extra {
	color: #777;
	font-size: 13px;
}

/* -------- PromptPay QR แสดงในการ์ดโดยตรง (ไม่ต้องเลือกก่อนถึงจะเห็น) -------- */
.ryc-bank-card-qr {
	flex: 0 0 auto;
	width: 84px;
	height: 84px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ryc-bank-card-qr img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	border: 1px solid #eee;
	padding: 4px;
	border-radius: var(--ryc-radius);
	background: #fff;
	box-sizing: border-box;
}

.ryc-bank-card-qr img[hidden] {
	display: none;
}

@media (max-width: 480px) {
	.ryc-bank-card-qr {
		width: 64px;
		height: 64px;
	}
}

/* -------- date field (flatpickr) -------- */
.ryc-date-input-wrap {
	position: relative;
	display: block;
}

.ryc-date-input-wrap::after {
	content: "";
	position: absolute;
	right: 12px;
	top: 50%;
	width: 16px;
	height: 16px;
	transform: translateY(-50%);
	pointer-events: none;
	background: currentColor;
	color: #8a8a8d;
	-webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M7 2v2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-2V2h-2v2H9V2H7zm12 8H5v10h14V10z'/></svg>") center / contain no-repeat;
	mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M7 2v2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-2V2h-2v2H9V2H7zm12 8H5v10h14V10z'/></svg>") center / contain no-repeat;
}

.ryc-confirm-form input.ryc-flatpickr-date {
	cursor: pointer;
	background: #fff;
	padding-right: 2.4em;
}

/* -------- time field (flatpickr) -------- */
/* โครงเหมือนช่องวันที่ทุกอย่าง ต่างแค่ไอคอนเป็นรูปนาฬิกา */
.ryc-time-input-wrap {
	position: relative;
	display: block;
}

.ryc-time-input-wrap::after {
	content: "";
	position: absolute;
	right: 12px;
	top: 50%;
	width: 16px;
	height: 16px;
	transform: translateY(-50%);
	pointer-events: none;
	background: currentColor;
	color: #8a8a8d;
	-webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm0 18a8 8 0 1 1 0-16 8 8 0 0 1 0 16zm1-13h-2v6l5 3 1-1.6-4-2.4V7z'/></svg>") center / contain no-repeat;
	mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm0 18a8 8 0 1 1 0-16 8 8 0 0 1 0 16zm1-13h-2v6l5 3 1-1.6-4-2.4V7z'/></svg>") center / contain no-repeat;
}

.ryc-confirm-form input.ryc-flatpickr-time {
	cursor: pointer;
	background: #fff;
	padding-right: 2.4em;
}

/* flatpickr — override สีเน้นให้ตรงกับสีปุ่ม/แบรนด์ของฟอร์ม */
.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.selected:focus {
	background: var(--ryc-accent);
	border-color: var(--ryc-accent);
}

.flatpickr-day.today {
	border-color: var(--ryc-accent);
}

.flatpickr-day.today:hover {
	background: var(--ryc-accent);
	border-color: var(--ryc-accent);
	color: #fff;
}

.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
span.flatpickr-weekday {
	color: var(--ryc-text);
}

.flatpickr-day:hover {
	background: rgba(35, 91, 149, 0.12);
}

/* -------- submit -------- */
.ryc-confirm-form .ryc-field-submit {
	margin-top: 1.6em;
}

.ryc-confirm-form button[type="submit"] {
	display: inline-block;
	background: var(--ryc-accent);
	color: #fff;
	border: none;
	border-radius: var(--ryc-radius);
	padding: 0.75em 2.4em;
	font-size: 18px;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.ryc-confirm-form button[type="submit"]:hover {
	background: var(--ryc-accent-dark);
}

.ryc-confirm-form button[type="submit"]:disabled {
	background: #9aabbb;
	cursor: not-allowed;
}

.ryc-confirm-message {
	padding: 0.85em 1em;
	border-radius: var(--ryc-radius);
	margin-bottom: 1em;
}

.ryc-confirm-message.is-success {
	background: #e8f7ee;
	color: #1e7e34;
	border: 1px solid #b6e6c6;
}

.ryc-confirm-message.is-error {
	background: #fdecea;
	color: #b02a23;
	border: 1px solid #f5c6c3;
}

/* -------- แผ่นคลุมระหว่างรอเซิร์ฟเวอร์ตอบ --------
   /create ใช้เวลาราว 8-10 วินาที แผ่นนี้ทำให้เห็นว่าระบบยังทำงานอยู่ ไม่ได้ค้าง
   และกันไม่ให้แตะฟอร์มหรือกดปุ่มซ้ำระหว่างรอ */
.ryc-confirm-form {
	position: relative;
}

.ryc-confirm-overlay {
	position: absolute;
	inset: 0;
	z-index: 10;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 1em;
	background: rgba(255, 255, 255, 0.75);
	border-radius: var(--ryc-radius);
	/* เบราว์เซอร์ที่ไม่รองรับก็ยังอ่านออก เพราะตัวกล่องข้างในทึบอยู่แล้ว */
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}

.ryc-confirm-overlay[hidden] {
	display: none;
}

/* กล่องต้องทึบ ไม่ใช่แค่ฉากหลังจาง ๆ ไม่งั้นเส้นขอบของช่องกรอกที่อยู่ข้างหลัง
   จะทะลุขึ้นมาปนกับตัวหนังสือจนอ่านยาก
   sticky: ฟอร์มยาวกว่าหน้าจอ กล่องจึงต้องตรึงให้เห็นเสมอแม้ลูกค้าจะเลื่อนจอ */
.ryc-confirm-overlay-box {
	width: 100%;
	max-width: 400px;
	text-align: center;
	position: sticky;
	top: 28vh;
	padding: 1.8em 1.4em 1.6em;
	background: #fff;
	border: 1px solid var(--ryc-border);
	border-radius: 10px;
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
}

.ryc-confirm-spinner {
	width: 42px;
	height: 42px;
	margin: 0 auto 0.9em;
	border: 4px solid rgba(35, 91, 149, 0.18);
	border-top-color: var(--ryc-accent);
	border-radius: 50%;
	animation: ryc-confirm-spin 0.9s linear infinite;
}

@keyframes ryc-confirm-spin {
	to {
		transform: rotate(360deg);
	}
}

.ryc-confirm-overlay-title {
	margin: 0 0 0.35em;
	font-size: 18px;
	font-weight: 600;
	color: var(--ryc-text);
}

.ryc-confirm-overlay-note {
	margin: 0 0 1em;
	font-size: 14px;
	line-height: 1.6;
	color: #5a6a78;
}

.ryc-confirm-progress {
	height: 6px;
	border-radius: 999px;
	background: rgba(35, 91, 149, 0.15);
	overflow: hidden;
}

.ryc-confirm-progress > span {
	display: block;
	width: 0;
	height: 100%;
	border-radius: inherit;
	background: var(--ryc-accent);
	transition: width 0.25s linear;
}

/* สถานะสำเร็จ — เปลี่ยนเป็นเขียวก่อนพาไปหน้าถัดไป ไม่ปล่อยให้ฟอร์มเปล่ากะพริบ */
.ryc-confirm-overlay.is-done .ryc-confirm-spinner {
	animation: none;
	border-color: rgba(30, 126, 52, 0.25);
	border-top-color: #1e7e34;
}

.ryc-confirm-overlay.is-done .ryc-confirm-overlay-title {
	color: #1e7e34;
}

.ryc-confirm-overlay.is-done .ryc-confirm-progress > span {
	background: #1e7e34;
}

/* เคารพการตั้งค่าของผู้ใช้ที่ขอลดการเคลื่อนไหว — คงหลอดความคืบหน้าไว้
   เพราะมันคือตัวบอกว่าระบบยังทำงานอยู่ แต่ไม่หมุน spinner ใส่ */
@media (prefers-reduced-motion: reduce) {
	.ryc-confirm-spinner {
		animation: none;
	}
}

@media (max-width: 480px) {
	.ryc-confirm-form .ryc-field-row {
		flex-direction: column;
		gap: 0;
	}

	/* flex-basis วัดตามแกนหลัก พอสลับเป็น column ค่า 220px ของ flex: 1 1 220px
	   จึงกลายเป็น "ความสูง" ของทุกช่องในแถว (ชื่อ/เบอร์โทร และ วันที่/เวลา) ทำให้เกิด
	   ช่องว่างสูงราว 220px คั่นระหว่างฟิลด์บนมือถือ — ต้องคืนค่าเป็น auto เสมอเมื่อเป็น column */
	.ryc-confirm-form .ryc-field-row .ryc-field {
		flex: 0 0 auto;
	}
}
