/* Beezy Docs: หน้าตาเวอร์ชันใหม่ของระบบเอกสาร (โหลดเฉพาะโหมด "ใหม่") */
:root {
	--bbn-bg: #f3f4f6;
	--bbn-card: #fff;
	--bbn-ink: #1f2328;
	--bbn-muted: #5b6470;
	--bbn-line: #e2e5ea;
	--bbn-head: #2b2f36;
	--bbn-accent: #f5c400;
	--bbn-accent-soft: #fff7d1;
	--bbn-link: #0a58ca;
	--bbn-radius: 12px;
}

html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0 !important;
	padding: 76px 16px 96px !important;
	background: var(--bbn-bg) !important;
	color: var(--bbn-ink);
	font: 15px/1.6 "Sarabun", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif !important;
}
body, td, th, input, select, textarea, button { font-family: "Sarabun", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif !important; }
td, th { font-size: 15px; color: inherit; }
a { color: var(--bbn-link); text-underline-offset: 2px; }
a:hover { color: #084298; }

/* ---- แถบบน ---- */
.bbn-bar {
	position: fixed; top: 0; left: 0; right: 0; z-index: 9000;
	height: 60px; padding: 0 16px;
	display: flex; align-items: center; gap: 12px;
	background: var(--bbn-head); color: #fff;
	box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
.bbn-bar__brand { display: flex; align-items: center; gap: 10px; color: #fff !important; text-decoration: none; min-width: 0; }
.bbn-bar__brand img { width: 34px; height: 34px; border-radius: 8px; background: #fff; padding: 2px; flex: none; }
.bbn-bar__brand span { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.bbn-bar__brand b { font-size: 15px; letter-spacing: .02em; }
.bbn-bar__brand small { font-size: 12px; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bbn-bar__nav { margin-left: auto; display: flex; gap: 6px; flex: none; }
.bbn-bar__nav a {
	display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px;
	border-radius: 8px; background: var(--bbn-accent); color: var(--bbn-ink) !important;
	font-weight: 600; text-decoration: none;
}
.bbn-bar__nav a.is-quiet { background: rgba(255, 255, 255, .12); color: #fff !important; }
.bbn-bar__nav a:hover { filter: brightness(1.05); }

/* ---- การ์ดครอบตาราง (เลื่อนซ้ายขวาได้บนมือถือ) ---- */
.bbn-card {
	max-width: 1100px; margin: 0 auto 20px;
	background: var(--bbn-card);
	border: 1px solid var(--bbn-line); border-radius: var(--bbn-radius);
	box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .04);
	overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.bbn-card > table { width: 100% !important; margin: 0 !important; border-collapse: collapse !important; border: 0 !important; }
.bbn-card > table[width="1000"] { min-width: 880px; }
.bbn-card > table[width="800"] { min-width: 700px; }
.bbn-card:has(> table[width="1000"]) { max-width: 1400px; }
.bbn-card td form { margin: 0; }

/* คอลัมน์ในหน้ารายการเอกสาร */
.bbn-card > table > tbody > tr > td[width="500"] { min-width: 200px; }
.bbn-card > table[width="1000"] > tbody > tr > td[width="150"] { white-space: nowrap; }

/* ตารางที่มีเส้น (border=1) */
table[border="1"] { border-collapse: collapse !important; }
table[border="1"] > tbody > tr > td,
table[border="1"] > tbody > tr > th,
table[border="1"] > tr > td {
	border: 1px solid var(--bbn-line) !important;
	padding: 10px 12px !important;
	vertical-align: middle;
}
.bbn-card > table[border="1"] > tbody > tr > td:first-child { border-left: 0 !important; }
.bbn-card > table[border="1"] > tbody > tr > td:last-child { border-right: 0 !important; }
.bbn-card > table[border="1"] > tbody > tr:first-child > td { border-top: 0 !important; }
.bbn-card > table[border="1"] > tbody > tr:last-child > td { border-bottom: 0 !important; }

/* แถวหัวตาราง (เดิมพื้นดำ ตัวขาว) */
td[bgcolor="#000000" i], tr[style*="color:#FFF" i] > td {
	background: var(--bbn-head) !important; color: #fff !important;
	font-weight: 600; font-size: 14px; white-space: nowrap;
}
td[bgcolor="#000000" i] *, tr[style*="color:#FFF" i] > td * { color: #fff !important; }

/* แถวแรกของการ์ด = หัวเรื่องของหน้า */
.bbn-card > table > tbody > tr:first-child > td[colspan],
.bbn-card > table > tbody > tr:first-child > td[bgcolor="#eeeeee" i] {
	background: #fafbfc !important; padding: 16px !important; font-size: 16px; line-height: 1.7;
}
td[bgcolor="#FFFF66" i] { background: var(--bbn-accent-soft) !important; }
.bbn-card > table > tbody > tr:first-child > td[colspan] a,
td[bgcolor="#eeeeee" i] > strong > a {
	display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; margin: 2px;
	border: 1px solid var(--bbn-line); border-radius: 8px; background: #fff;
	color: var(--bbn-ink) !important; text-decoration: none; font-size: 14px; font-weight: 600;
}
.bbn-card > table > tbody > tr:first-child > td[colspan] a:hover { border-color: var(--bbn-accent); background: var(--bbn-accent-soft); }
.bbn-card > table > tbody > tr:first-child > td[colspan] img { vertical-align: middle; border-radius: 8px; }

/* แถวข้อมูล */
table[border="1"] > tbody > tr:not([style]):hover > td:not([bgcolor]) { background: #fffbea; }
table[border="1"] td a { font-weight: 600; }

/* ปุ่มก๊อปปี้เอกสาร (เดิมพื้นชมพู) */
td[bgcolor="#FF0066" i] { background: #c2255c !important; color: #fff !important; }
td[bgcolor="#FF0066" i] * { color: #fff !important; }
td[bgcolor="#FFCCCC" i] { background: #fff0f4 !important; padding: 8px 6px !important; }
td[bgcolor="#FFCCCC" i] a {
	display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px;
	background: #fff; border: 1px solid #f3c4d2; color: #a61e4d !important; text-decoration: none; white-space: nowrap;
}

/* ---- ฟอร์ม ---- */
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input:not([type]), select, textarea {
	font-size: 15px !important; color: var(--bbn-ink);
	padding: 8px 10px; min-height: 38px; box-sizing: border-box; max-width: 100%;
	border: 1px solid #c9d1d9; border-radius: 8px; background: #fff;
}
textarea { min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--bbn-accent); outline-offset: 0; border-color: #d4a900; }
input[readonly], .ReadOnly_Box { background: #f3f4f6 !important; color: var(--bbn-muted); }
input[type="submit"], input[type="button"], input[type="reset"], button {
	font-size: 15px !important; font-weight: 600;
	min-height: 38px; padding: 0 18px; margin: 2px;
	border-radius: 8px; border: 1px solid transparent; cursor: pointer;
	background: var(--bbn-accent); color: var(--bbn-ink);
}
input[type="reset"] { background: #e9ecef; }
input[type="submit"]:hover, input[type="button"]:hover, button:hover { filter: brightness(.97); }

/* ฟอร์มเพิ่ม/แก้ไข (เดิมพื้นฟ้าทั้งตาราง) */
td[bgcolor="#9DC9FD" i] { background: #fff !important; }
tr > td[bgcolor="#9DC9FD" i]:first-child:not([colspan]) { background: #fafbfc !important; color: var(--bbn-muted); font-weight: 600; }
span[onclick^="addFile"], span[onclick^="removeFile"] {
	display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; margin: 4px 0;
	border-radius: 8px; border: 1px solid #f0d97a; background: var(--bbn-accent-soft);
	color: var(--bbn-ink) !important; font-weight: 600;
}
span[onclick^="removeFile"] { border-color: #f3c4d2; background: #fff0f4; color: #a61e4d !important; }
span[onclick^="addFile"] *, span[onclick^="removeFile"] * { color: inherit !important; }

/* ---- หน้า login ---- */
[data-bbn="index"] { display: flex; flex-direction: column; justify-content: center; min-height: 100vh; box-sizing: border-box; }
[data-bbn="index"] br { display: none; }
[data-bbn="index"] .bbn-card { max-width: 440px; width: 100%; }
[data-bbn="index"] .bbn-card > table > tbody > tr:first-child > td { padding: 20px !important; font-size: 17px; background: var(--bbn-accent-soft) !important; }
[data-bbn="index"] form table { width: 100% !important; }
[data-bbn="index"] form td { display: block; width: auto !important; text-align: left !important; padding: 4px 4px !important; height: auto !important; }
[data-bbn="index"] input[type="text"], [data-bbn="index"] input[type="password"] { width: 100%; }
[data-bbn="index"] form { margin: 0; padding: 8px 12px 16px; }

/* ---- หน้าเมนูหลัก ---- */
[data-bbn="all_index"] .bbn-card { max-width: 720px; }
[data-bbn="all_index"] .bbn-card td { background: #fff !important; padding: 0 !important; font-size: 16px; }
[data-bbn="all_index"] .bbn-card tr:first-child td:not(:has(a)) { padding: 14px 18px !important; font-weight: 700; background: #fafbfc !important; }
[data-bbn="all_index"] .bbn-card td a {
	display: flex; align-items: center; gap: 14px; padding: 16px 18px;
	color: var(--bbn-ink) !important; text-decoration: none;
}
[data-bbn="all_index"] .bbn-card td a:hover { background: var(--bbn-accent-soft); }
[data-bbn="all_index"] .bbn-card td a img { height: 52px !important; width: auto; flex: none; }
[data-bbn="all_index"] .bbn-card td a br { display: none; }
[data-bbn="all_index"] .bbn-card td a::after { content: "›"; margin-left: auto; font-size: 22px; color: var(--bbn-muted); }
[data-bbn="all_index"] .bbn-card td a[href="logout.php"]:empty { display: none; }
/* ซ่อนขีด "-" กับบรรทัดว่างหน้าลิงก์เมนู */
[data-bbn="all_index"] .bbn-card td:has(a) { font-size: 0 !important; line-height: 0; }
[data-bbn="all_index"] .bbn-card td:has(a) > br { display: none; }
[data-bbn="all_index"] .bbn-card td a { font-size: 16px; line-height: 1.5; }
[data-bbn="all_index"] > p { display: none; }

/* ---- มือถือ ---- */
@media (max-width: 640px) {
	body { padding: 72px 10px 88px !important; }
	.bbn-bar { height: 56px; padding: 0 10px; }
	.bbn-bar__brand small { display: none; }
	.bbn-bar__nav a { padding: 0 10px; font-size: 14px; }
	.bbn-card { border-radius: 10px; }
	td, th { font-size: 14px; }
	.bbn-card > table[width="800"] { min-width: 540px; }
	/* หัวเรื่องของหน้าค้างอยู่ในส่วนที่มองเห็น แม้ตารางจะเลื่อนซ้ายขวา */
	.bbn-head-cell { text-align: left !important; }
	.bbn-head-inner { position: sticky; left: 12px; max-width: calc(100vw - 52px); text-align: center; }
}

/* ---- พิมพ์ ---- */
@media print {
	.bbn-bar { display: none !important; }
	body { padding: 0 !important; background: #fff !important; }
	.bbn-card { border: 0; box-shadow: none; overflow: visible; }
}
