/* Fixed sidebar layout across all pages */
.app{min-height:100vh;}
.sidebar{
	position:fixed !important;
	top:0; left:0; bottom:0;
	width:260px;
	overflow-y:auto;
	background:var(--card,#fff);
	border-right:1px solid var(--border);
	z-index:10;
}
.main{
	margin-left:260px;
}

/* Optional: keep content usable on very small screens */
@media (max-width:640px){
	.sidebar{width:220px;}
	.main{margin-left:220px;}
}
:root {
	--bg: #f8fafc;
	--surface: #ffffff;
	--card: #ffffff;
	--border: #e5e7eb;
	--text: #0f172a;
	--muted: #64748b;
	--primary: #3b82f6;
	--primary-600: #2563eb;
	--success: #10b981;
	--danger: #ef4444;
	--shadow: 0 6px 18px rgba(0,0,0,0.08);
	--row-alt: #f9fafb;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
	background: linear-gradient(180deg, var(--bg) 0%, #ffffff 100%);
	color: var(--text);
}

.auth-layout {
	min-height: 100vh;
	display: grid;
	grid-template-columns: 1.2fr 1fr;
	align-items: center;
	padding: 4rem 8vw;
	gap: 4rem;
}

.brand { display: flex; align-items: center; gap: 1.25rem; }
.logo {
	width: 56px; height: 56px; border-radius: 14px;
	background: linear-gradient(135deg, var(--primary), #8b5cf6);
	display: grid; place-items: center; font-weight: 700; font-size: 1.25rem;
	box-shadow: var(--shadow);
}
.brand-text h1 { margin: 0; font-size: 2rem; letter-spacing: 0.5px; }
.brand-text p { margin: 0.25rem 0 0; color: var(--muted); }

.card {
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: 16px;
	padding: 2rem;
	box-shadow: var(--shadow);
	max-width: 440px;
}
.card h2 { margin-top: 0; font-size: 1.5rem; }

.form-field { margin-bottom: 1rem; }
.form-field label { display: block; margin-bottom: 0.5rem; color: var(--muted); font-size: 0.9rem; }
.form-field input {
	width: 100%;
	padding: 0.75rem 0.9rem;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: #ffffff;
	color: var(--text);
	outline: none;
}
.form-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }

.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }
.btn {
	padding: 0.75rem 1rem;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: #ffffff; color: var(--text);
	cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary-600); }
.btn.primary:hover { background: var(--primary-600); }

.error { margin-top: 0.75rem; color: var(--danger); }

@media (max-width: 900px) {
	.auth-layout { grid-template-columns: 1fr; padding: 3rem 6vw; }
}

/* Utils */
.hidden-col { display: none; }

/* App shell with sidebar */
.app { min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem; }
.sidebar .brand { margin-bottom: 1rem; }
.sidebar nav { display: grid; gap: .25rem; }
.sidebar a { display:flex; align-items:center; gap:.6rem; padding:.65rem .75rem; color: var(--text); text-decoration:none; border-radius:10px; }
.sidebar a:hover { background: #f3f4f6; }
.sidebar a.active { background: #eef2f7; border:1px solid var(--border); }
.main { display: grid; grid-template-rows: auto 1fr; }
.topbar { display:flex; align-items:center; justify-content: space-between; padding: 1rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.content { padding: 1.25rem; }
.placeholder { background: var(--card); border:1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); color: var(--muted); text-align:center; padding: 3rem; }

@media (max-width: 900px) {
	/* Keep fixed sidebar behavior; width adjustment handled above */
}

/* Compact table for one-line rows */
.table.compact { width: 100% !important; table-layout: fixed; font-size: 0.7rem; }
.table.compact th, .table.compact td { padding: 0.35rem 0.5rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table.compact thead th { position: sticky; top: 0; background: var(--card); border-bottom: 1px solid var(--border); }
/* Zebra and hover for readability on light theme */
.table.compact tbody tr:nth-child(odd) { background: var(--row-alt); }
.table.compact tbody tr:hover { background: rgba(59,130,246,0.08); }
/* Allow specific columns to wrap fully (show all content) */
.table.compact .wrap { white-space: normal; overflow: visible; text-overflow: unset; }
/* Column-specific widths (override via CSS variables on the table) */
.table.compact {
	/* Defaults: override per table via inline style or extra class */
	    --w-col-1: 60px;/* No. (wider to fit icon+number) */
		--w-col-2: 120px;/* Order No. */
		--w-col-3: 150px;/* ช่องทาง/เพจ */
		--w-col-4: 85px;/* วันที่สั่งซื้อ */
		--w-col-5: 85px;/* ชื่อลูกค้า */
		--w-col-6: 95px;/* เบอร์ติดต่อ */
		--w-col-7: 200px;/* ที่อยู่ */
		--w-col-8: 65px;/* หมายเหตุ */
		--w-col-9: 65px;/* รหัสสินค้า */
		--w-col-10: 150px;/* สินค้า */
		--w-col-11: 90px;/* น้ำหนัก */
		--w-col-12: 100px;/* TRACKING NO. */
		--w-col-13: 120px;/* สถานะพัสดุ */
		--w-col-14: 55px;/* ส่วนลด */
		--w-col-15: 60px;/* ค่าจัดส่ง */
		--w-col-16: 65px;/* ยอดรวม */
		--w-col-17: 95px;/* การชำระเงิน */
		--w-col-18: 100px;/* วันที่ชำระเงิน */
		--w-col-19: 130px;/* สถานะชำระเงิน */
		--w-col-20: 150px;/* สร้างออเดอร์โดย */
		--w-col-21: 150px;/* ยืนยันโดย */
		--w-col-22: 160px;/* เพิ่มยอดขายโดย */
	}

.table.compact th:nth-child(1), .table.compact td:nth-child(1) { width: var(--w-col-1); max-width: var(--w-col-1); }
.table.compact th:nth-child(2), .table.compact td:nth-child(2) { width: var(--w-col-2); max-width: var(--w-col-2); }
.table.compact th:nth-child(3), .table.compact td:nth-child(3) { width: var(--w-col-3); max-width: var(--w-col-3); }
.table.compact th:nth-child(4), .table.compact td:nth-child(4) { width: var(--w-col-4); max-width: var(--w-col-4); }
.table.compact th:nth-child(5), .table.compact td:nth-child(5) { width: var(--w-col-5); max-width: var(--w-col-5); }
.table.compact th:nth-child(6), .table.compact td:nth-child(6) { width: var(--w-col-6); max-width: var(--w-col-6); }
.table.compact th:nth-child(7), .table.compact td:nth-child(7) { width: var(--w-col-7); max-width: var(--w-col-7); }
.table.compact th:nth-child(8), .table.compact td:nth-child(8) { width: var(--w-col-8); max-width: var(--w-col-8); }
.table.compact th:nth-child(9), .table.compact td:nth-child(9) { width: var(--w-col-9); max-width: var(--w-col-9); }
.table.compact th:nth-child(10), .table.compact td:nth-child(10) { width: var(--w-col-10); max-width: var(--w-col-10); }
.table.compact th:nth-child(11), .table.compact td:nth-child(11) { width: var(--w-col-11); max-width: var(--w-col-11); }
.table.compact th:nth-child(12), .table.compact td:nth-child(12) { width: var(--w-col-12); max-width: var(--w-col-12); }
.table.compact th:nth-child(13), .table.compact td:nth-child(13) { width: var(--w-col-13); max-width: var(--w-col-13); }
.table.compact th:nth-child(14), .table.compact td:nth-child(14) { width: var(--w-col-14); max-width: var(--w-col-14); }
.table.compact th:nth-child(15), .table.compact td:nth-child(15) { width: var(--w-col-15); max-width: var(--w-col-15); }
.table.compact th:nth-child(16), .table.compact td:nth-child(16) { width: var(--w-col-16); max-width: var(--w-col-16); }
.table.compact th:nth-child(17), .table.compact td:nth-child(17) { width: var(--w-col-17); max-width: var(--w-col-17); }
.table.compact th:nth-child(18), .table.compact td:nth-child(18) { width: var(--w-col-18); max-width: var(--w-col-18); }
.table.compact th:nth-child(19), .table.compact td:nth-child(19) { width: var(--w-col-19); max-width: var(--w-col-19); }
.table.compact th:nth-child(20), .table.compact td:nth-child(20) { width: var(--w-col-20); max-width: var(--w-col-20); }
.table.compact th:nth-child(21), .table.compact td:nth-child(21) { width: var(--w-col-21); max-width: var(--w-col-21); }
.table.compact th:nth-child(22), .table.compact td:nth-child(22) { width: var(--w-col-22); max-width: var(--w-col-22); }

/* Channel/Page column respects the same variable (kept for class-based targeting) */
.table.compact .col-channel { width: var(--w-col-3); max-width: var(--w-col-3); }

/* Info button inside No. column */
.table.compact td.no-cell {
	display: flex;
	align-items: center;
	gap: 4px;
	overflow: visible; /* allow text next to icon to be visible */
	text-overflow: initial;
}
.table.compact td.no-cell span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-btn {
	width: 18px; height: 18px;
	display: grid; place-items: center;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: #ffffff;
	cursor: pointer;
	color: var(--primary-600);
}
.info-btn:hover { background: rgba(59,130,246,0.08); border-color: var(--primary-600); }
.info-btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.info-btn svg { width: 12px; height: 12px; }

/* Modal (order info) */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: none; place-items: center; z-index: 1000; padding: 2rem; }
.modal.open { display: grid; }
.modal .dialog { width: min(980px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.modal .hd { display:flex; align-items:center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal .hd h3 { margin: 0; font-size: 1.05rem; }
.modal .close { width:32px; height:32px; border:1px solid var(--border); background:#fff; border-radius:8px; display:grid; place-items:center; cursor:pointer; }
.modal .bd { padding: 1rem 1.25rem; display: grid; gap: 1rem; }

.info-sections { display:grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.info-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: .75rem .9rem; }
.info-card h4 { margin: 0 0 .5rem 0; font-size: .9rem; color: var(--muted); font-weight:600; }
.kv { display:grid; grid-template-columns: 120px 1fr; gap: .3rem .75rem; font-size: .85rem; }
.kv .key { color: var(--muted); }
.kv .val { color: var(--text); }

.status-pill { display:inline-flex; align-items:center; gap:.4rem; font-size:.8rem; padding:.2rem .5rem; border-radius: 999px; border:1px solid var(--border); background:#ecfeff; color:#0369a1; }
.status-dot { width:8px; height:8px; border-radius:50%; background:#10b981; }

.mini-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.mini-table th, .mini-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); text-align:left; }
.mini-table thead th { background: var(--row-alt); color: var(--muted); }

.summary { display:grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-top:.25rem; }
.summary .box { background: var(--card); border:1px solid var(--border); border-radius:10px; padding:.6rem .8rem; }
.summary .box .label { color: var(--muted); font-size:.8rem; }
.summary .box .value { font-weight:600; }
