/* ธีมกลางของระบบจองหอพัก (Bootstrap 5) */
:root {
	--rb-primary: #5b4bb7;
	--rb-primary-dark: #42358f;
	--rb-accent: #96ce11;
	--rb-bg: #f3f2fa;
	--rb-sidebar-width: 280px;
	--bs-primary: #5b4bb7;
	--bs-primary-rgb: 91, 75, 183;
	--bs-link-color: #5b4bb7;
	--bs-link-color-rgb: 91, 75, 183;
	--bs-link-hover-color: #42358f;
	--bs-body-font-family: 'Kanit', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

body {
	background: var(--rb-bg);
	font-weight: 300;
}

h1, h2, h3, h4, h5, .fw-head {
	font-family: 'Mitr', 'Kanit', sans-serif;
	font-weight: 500;
}

.btn-primary {
	--bs-btn-bg: var(--rb-primary);
	--bs-btn-border-color: var(--rb-primary);
	--bs-btn-hover-bg: var(--rb-primary-dark);
	--bs-btn-hover-border-color: var(--rb-primary-dark);
	--bs-btn-active-bg: var(--rb-primary-dark);
	--bs-btn-active-border-color: var(--rb-primary-dark);
	--bs-btn-disabled-bg: var(--rb-primary);
	--bs-btn-disabled-border-color: var(--rb-primary);
}

.btn-outline-primary {
	--bs-btn-color: var(--rb-primary);
	--bs-btn-border-color: var(--rb-primary);
	--bs-btn-hover-bg: var(--rb-primary);
	--bs-btn-hover-border-color: var(--rb-primary);
	--bs-btn-active-bg: var(--rb-primary-dark);
	--bs-btn-active-border-color: var(--rb-primary-dark);
}

.card {
	border: 0;
	border-radius: 1rem;
	box-shadow: 0 .25rem 1rem rgba(40, 30, 100, .08);
}

.form-label {
	font-weight: 400;
}

.required::after {
	content: " *";
	color: var(--bs-danger);
}

/* ---------- หน้าแรก (index.php) ---------- */
.rb-hero {
	background: linear-gradient(135deg, var(--rb-primary) 0%, #864ca5 100%);
	color: #fff;
}

.rb-hero img {
	width: 64px;
	height: 64px;
}

.rb-menu .list-group-item {
	font-size: 1.05rem;
	padding: .8rem 1rem;
}

.rb-menu .list-group-item.active {
	background: var(--rb-primary);
	border-color: var(--rb-primary);
}

.rb-step {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.75rem;
	height: 1.75rem;
	border-radius: 50%;
	background: var(--rb-bg);
	color: var(--rb-primary);
	font-weight: 500;
	margin-right: .5rem;
	flex-shrink: 0;
}

/* ---------- หน้าจองห้อง (showroom.php) ---------- */
.rb-sidebar {
	background: var(--rb-primary-dark);
	color: rgba(255, 255, 255, .85);
	width: var(--rb-sidebar-width);
}

.rb-sidebar a {
	color: rgba(255, 255, 255, .85);
	text-decoration: none;
}

.rb-sidebar .nav-link {
	border-radius: .5rem;
	padding: .65rem .9rem;
	display: flex;
	align-items: center;
	gap: .75rem;
}

.rb-sidebar .nav-link:hover,
.rb-sidebar .nav-link.active {
	background: rgba(255, 255, 255, .12);
	color: #fff;
}

.rb-sidebar .nav-link .fa {
	width: 1.25rem;
	text-align: center;
}

.rb-sidebar .rb-user {
	background: rgba(255, 255, 255, .08);
	border-radius: .75rem;
}

.rb-sidebar.offcanvas-lg {
	--bs-offcanvas-bg: var(--rb-primary-dark);
	--bs-offcanvas-width: var(--rb-sidebar-width);
}

@media (min-width: 992px) {
	.rb-sidebar.offcanvas-lg {
		/* offcanvas-lg ของ Bootstrap ตั้งพื้นหลังโปร่งใสบนจอใหญ่ ต้องทับกลับ */
		background-color: var(--rb-primary-dark) !important;
		position: sticky;
		top: 0;
		height: 100vh;
		overflow-y: auto;
	}
}

.rb-dorm-list .list-group-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .5rem;
}

.rb-dorm-list .list-group-item.active {
	background: var(--rb-primary);
	border-color: var(--rb-primary);
}

.rb-room-table td,
.rb-room-table th {
	vertical-align: middle;
}

.rb-booker {
	display: inline-block;
	background: #e6f6e6;
	color: #1d5c1d;
	border-radius: 1rem;
	padding: .15rem .6rem;
	margin: .15rem;
	font-size: .85rem;
}

.rb-student-photo {
	max-width: 220px;
}

.min-vw-0 {
	min-width: 0;
}

/* ---------- รอบปรับ UI 2: หน้าแรกแบบ landing / สถานะช่วงเวลา / การ์ดห้อง ---------- */
.rb-hero {
	padding: 1.5rem 0;
	background: radial-gradient(circle at 85% 20%, rgba(255, 255, 255, .18) 0, transparent 40%), linear-gradient(135deg, var(--rb-primary) 0%, #864ca5 100%);
}

.rb-hero h1 {
	font-size: clamp(1.35rem, 2.6vw, 2rem);
}

.rb-hero-lg {
	padding: 2.5rem 0 5rem;
}

.rb-eyebrow {
	font-size: .85rem;
	opacity: .8;
	letter-spacing: .02em;
}

.rb-hero-lead {
	max-width: 40rem;
	opacity: .9;
}

/* การ์ดหน้าแรกลอยทับ hero */
.rb-overlap {
	margin-top: -4rem;
}

.rb-path {
	transition: transform .15s ease, box-shadow .15s ease;
}

.rb-path:hover {
	transform: translateY(-2px);
	box-shadow: 0 .75rem 2rem rgba(40, 30, 100, .14);
}

.rb-path-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	border-radius: .9rem;
	background: rgba(91, 75, 183, .12);
	color: var(--rb-primary);
	font-size: 1.5rem;
	flex-shrink: 0;
}

.rb-path-icon-alt {
	background: rgba(13, 148, 136, .12);
	color: #0d9488;
}

.rb-rounds ul {
	display: flex;
	flex-wrap: wrap;
	gap: .35rem;
	list-style: none;
	padding: 0;
	margin: 0;
	font-size: .85rem !important;
	line-height: 1.4 !important;
}

.rb-rounds li {
	background: var(--rb-bg);
	color: var(--rb-primary-dark);
	border-radius: 2rem;
	padding: .15rem .7rem;
}

/* ขั้นตอนแบบมีเส้นเชื่อม */
.rb-steps {
	list-style: none;
	padding: 0;
	margin: 0;
	counter-reset: rbstep;
}

.rb-steps li {
	position: relative;
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: .85rem 0 .85rem 3rem;
	border-top: 1px solid var(--bs-border-color-translucent);
	counter-increment: rbstep;
}

.rb-steps li::before {
	content: counter(rbstep);
	position: absolute;
	left: 0;
	top: .9rem;
	width: 2rem;
	height: 2rem;
	border-radius: 50%;
	background: var(--rb-primary);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 500;
}

/* ป้ายสถานะช่วงเวลา */
.rb-phase {
	display: inline-flex;
	align-items: center;
	gap: .35rem;
	margin-top: .35rem;
	font-size: .8rem;
	border-radius: 2rem;
	padding: .15rem .65rem;
}

.rb-phase-open {
	background: #dcfce7;
	color: #166534;
}

.rb-phase-soon {
	background: #fef3c7;
	color: #92400e;
}

.rb-phase-closed {
	background: #f1f5f9;
	color: #64748b;
}

.rb-dot {
	width: .5rem;
	height: .5rem;
	border-radius: 50%;
	background: #16a34a;
	animation: rbpulse 1.6s infinite;
}

@keyframes rbpulse {
	0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .6); }
	70% { box-shadow: 0 0 0 .45rem rgba(22, 163, 74, 0); }
	100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.rb-countdown {
	font-variant-numeric: tabular-nums;
	font-weight: 500;
}

.rb-period {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: .5rem;
	background: var(--rb-bg);
	border-radius: .75rem;
	padding: .75rem 1rem;
	font-size: .95rem;
}

.rb-period .rb-phase {
	margin-top: 0;
}

/* ---------- หน้าจอง ---------- */
.rb-closing {
	background: #fff7ed;
	color: #9a3412;
	border-radius: .75rem;
	padding: .5rem 1rem;
	text-align: right;
	box-shadow: 0 .25rem 1rem rgba(154, 52, 18, .08);
}

.rb-stepper {
	display: flex;
	list-style: none;
	padding: 0;
	margin: 0;
	gap: .5rem;
}

.rb-stepper li {
	flex: 1;
	display: flex;
	align-items: center;
	gap: .5rem;
	color: var(--bs-secondary-color);
	font-size: .95rem;
	position: relative;
}

.rb-stepper li:not(:last-child)::after {
	content: "";
	flex: 1;
	height: 2px;
	background: var(--bs-border-color);
	margin: 0 .25rem;
}

.rb-stepper li span {
	width: 2rem;
	height: 2rem;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	border: 2px solid var(--bs-border-color);
	flex-shrink: 0;
	font-weight: 500;
}

.rb-stepper li.current {
	color: var(--rb-primary);
	font-weight: 500;
}

.rb-stepper li.current span {
	border-color: var(--rb-primary);
	color: var(--rb-primary);
}

.rb-stepper li.done {
	color: var(--bs-body-color);
}

.rb-stepper li.done span {
	background: var(--rb-primary);
	border-color: var(--rb-primary);
	color: #fff;
}

.rb-stepper li.done::after {
	background: var(--rb-primary);
}

.rb-status-icon {
	width: 3rem;
	height: 3rem;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--rb-bg);
	color: var(--rb-primary);
	font-size: 1.25rem;
	flex-shrink: 0;
}

.rb-status-done {
	background: linear-gradient(135deg, #16a34a 0%, #0d9488 100%);
	color: #fff;
}

.rb-status-done .rb-status-icon {
	background: rgba(255, 255, 255, .2);
	color: #fff;
}

.rb-status-done .form-label,
.rb-status-done .text-danger {
	color: #fff !important;
}

.rb-status-done #form1_nv {
	border-color: rgba(255, 255, 255, .35) !important;
}

.rb-dorm-list {
	display: grid;
	gap: .5rem;
}

.rb-dorm {
	display: block;
	padding: .7rem .9rem;
	border: 1px solid var(--bs-border-color);
	border-radius: .75rem;
	color: var(--bs-body-color);
	text-decoration: none;
	transition: border-color .15s, background .15s;
}

.rb-dorm:hover {
	border-color: var(--rb-primary);
	color: var(--bs-body-color);
}

.rb-dorm.active {
	border-color: var(--rb-primary);
	background: rgba(91, 75, 183, .07);
	box-shadow: inset 3px 0 0 var(--rb-primary);
}

.rb-dorm.is-full {
	opacity: .65;
}

.rb-dorm .progress {
	height: 5px;
}

.rb-room-card {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--bs-border-color);
	border-radius: .9rem;
	padding: .9rem 1rem;
	background: #fff;
	transition: border-color .15s, box-shadow .15s;
}

.rb-room-card:hover {
	border-color: var(--rb-primary);
	box-shadow: 0 .25rem 1rem rgba(40, 30, 100, .08);
}

.rb-room-card.is-full {
	background: #f8f9fb;
}

.rb-room-card.is-mine {
	border: 2px solid var(--rb-primary);
	background: rgba(91, 75, 183, .05);
}

.rb-room-no {
	font-family: 'Mitr', sans-serif;
	font-size: 1.5rem;
	line-height: 1.1;
}

.rb-seats .fa {
	font-size: 1.1rem;
	margin-right: .2rem;
	color: #cbd5e1;
}

.rb-seats .fa.taken {
	color: var(--rb-primary);
}

.rb-booker-list {
	font-size: .82rem;
	color: var(--bs-secondary-color);
	padding-left: 1.1rem;
	margin-bottom: .6rem;
}

@media (max-width: 575.98px) {
	.rb-stepper li {
		font-size: .8rem;
	}

	.rb-stepper li:not(:last-child)::after {
		display: none;
	}

	.rb-closing {
		text-align: left;
		width: 100%;
	}
}

.rb-steps .btn {
	white-space: nowrap;
}

/* ---------- รอบปรับ UI 3: เมนูทุกจุดใช้รูปแบบเดียวกัน ---------- */
.rb-brand {
	display: flex;
	align-items: center;
	gap: .6rem;
	font-family: 'Mitr', sans-serif;
	font-size: 1.05rem;
	color: var(--rb-primary-dark);
}

.rb-brand img {
	border-radius: 50%;
}

.rb-nav .nav-link {
	font-size: .95rem;
	font-weight: 400;
	color: var(--bs-body-color);
	padding: .5rem .8rem !important;
	border-radius: .5rem;
	display: flex;
	align-items: center;
	gap: .4rem;
}

.rb-nav .nav-link .fa {
	color: var(--rb-primary);
	width: 1rem;
	text-align: center;
}

.rb-nav .nav-link:hover {
	background: var(--rb-bg);
	color: var(--rb-primary-dark);
}

.rb-nav .nav-link.active {
	background: rgba(91, 75, 183, .1);
	color: var(--rb-primary-dark);
	font-weight: 500;
}

/* เลขขั้นตอนในเมนูซ้าย = วงกลมแบบเดียวกับการ์ดหน้าแรก */
.rb-step {
	width: 1.75rem;
	height: 1.75rem;
	background: var(--rb-primary);
	color: #fff;
	font-size: .85rem;
	margin-right: .75rem;
}

.rb-menu .list-group-item {
	font-size: 1rem;
	align-items: center;
}

.rb-menu .list-group-item.active {
	background: rgba(91, 75, 183, .1);
	border-color: var(--bs-list-group-border-color);
	color: var(--rb-primary-dark);
	font-weight: 500;
	box-shadow: inset 3px 0 0 var(--rb-primary);
}

.rb-menu .list-group-item.active .rb-step {
	background: var(--rb-primary);
	color: #fff;
}

.rb-menu .card-header {
	display: flex;
	align-items: center;
	gap: .6rem;
}

.rb-path-icon-sm {
	width: 2rem;
	height: 2rem;
	font-size: 1rem;
	border-radius: .6rem;
}

/* ปุ่มแสดงรหัสผ่าน: ขอบ/พื้นเดียวกับช่องกรอก ให้ดูเป็นชิ้นเดียวกัน */
.rb-pw-toggle {
	background: var(--bs-body-bg);
	border: var(--bs-border-width) solid var(--bs-border-color);
	border-left: 0;
	color: var(--bs-secondary-color);
}

.rb-pw-toggle:hover,
.rb-pw-toggle:active {
	background: var(--bs-body-bg) !important;
	border-color: var(--bs-border-color) !important;
	color: var(--rb-primary) !important;
}

.input-group:has(.rb-pw-toggle) .form-control {
	border-right: 0;
}

.input-group:has(.rb-pw-toggle) .form-control:focus {
	box-shadow: none;
}

.input-group:has(.rb-pw-toggle):focus-within {
	border-radius: var(--bs-border-radius);
	box-shadow: 0 0 0 .25rem rgba(91, 75, 183, .25);
}

.input-group:has(.rb-pw-toggle):focus-within .form-control,
.input-group:has(.rb-pw-toggle):focus-within .rb-pw-toggle {
	border-color: #ada5db;
}

.input-group:has(.form-control.is-invalid) .rb-pw-toggle {
	border-color: var(--bs-form-invalid-border-color);
}

/* ไอคอนวงกลมของการ์ด "ยังไม่เปิด / ปิดแล้ว" */
.rb-closed-icon {
	width: 4rem;
	height: 4rem;
	font-size: 1.75rem;
}

/* ช่องดัก bot: คนมองไม่เห็น (bot มักกรอกทุกช่อง) */
.rb-hp {
	position: absolute !important;
	left: -10000px !important;
	width: 1px;
	height: 1px;
	opacity: 0;
}

/* ตัวเลือกแบบปุ่ม (เช่น เพศ) สูงเท่าช่องกรอก */
.rb-choice {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: .5rem;
}

.rb-choice .btn {
	border: var(--bs-border-width) solid var(--bs-border-color);
	background: var(--bs-body-bg);
	color: var(--bs-body-color);
	padding: .375rem .75rem;
}

.rb-choice .btn .fa {
	color: var(--bs-secondary-color);
	margin-right: .25rem;
}

.rb-choice .btn:hover {
	border-color: var(--rb-primary);
}

.rb-choice .btn-check:checked + .btn {
	background: rgba(91, 75, 183, .1);
	border-color: var(--rb-primary);
	color: var(--rb-primary-dark);
	font-weight: 500;
}

.rb-choice .btn-check:checked + .btn .fa {
	color: var(--rb-primary);
}

.rb-choice .btn-check:focus-visible + .btn {
	box-shadow: 0 0 0 .25rem rgba(91, 75, 183, .25);
}

/* ยังไม่เลือกแล้วกดส่ง */
.was-validated .rb-choice .btn-check:invalid + .btn {
	border-color: var(--bs-form-invalid-border-color);
}

/* ปุ่มรูปตาเปลี่ยนสีขอบตามผลตรวจของช่องรหัสผ่าน (แดง/เขียว) */
.was-validated .input-group:has(.form-control:invalid) .rb-pw-toggle {
	border-color: var(--bs-form-invalid-border-color);
}

.was-validated .input-group:has(.form-control:valid) .rb-pw-toggle {
	border-color: var(--bs-form-valid-border-color);
}
