/* KHS Cookie Consent – เทศบาลตำบลเขาหินซ้อน */
:root {
	--khs-cc-primary: #1f6f43;
	--khs-cc-bg: #ffffff;
	--khs-cc-text: #1d2327;
	--khs-cc-muted: #50575e;
	--khs-cc-border: #dcdcde;
	--khs-cc-radius: 10px;
	--khs-cc-shadow: 0 8px 30px rgba(0, 0, 0, .18);
}

.khs-cc, .khs-cc-modal, .khs-cc-reopen, .khs-cc-ph {
	font-family: inherit;
	font-size: 15px;
	line-height: 1.6;
	color: var(--khs-cc-text);
	box-sizing: border-box;
}
.khs-cc *, .khs-cc-modal *, .khs-cc-ph * { box-sizing: border-box; }
.khs-cc[hidden], .khs-cc-modal[hidden], .khs-cc-reopen[hidden] { display: none !important; }

/* ---------- Banner ---------- */
.khs-cc {
	position: fixed;
	z-index: 999998;
	background: var(--khs-cc-bg);
	box-shadow: var(--khs-cc-shadow);
	animation: khs-cc-in .3s ease-out;
}
.khs-cc__title { margin: 0 0 4px; font-size: 17px; font-weight: 700; color: var(--khs-cc-text); line-height: 1.4; }
.khs-cc__desc { margin: 0; color: var(--khs-cc-muted); }
.khs-cc__desc a { color: var(--khs-cc-primary); text-decoration: underline; white-space: nowrap; }
.khs-cc__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* bottom bar */
.khs-cc--bottom { left: 0; right: 0; bottom: 0; border-top: 4px solid var(--khs-cc-primary); }
.khs-cc--bottom .khs-cc__inner {
	max-width: 1200px; margin: 0 auto; padding: 18px 20px;
	display: flex; gap: 20px; align-items: center; justify-content: space-between;
}
.khs-cc--bottom .khs-cc__actions { flex-shrink: 0; }

/* box */
.khs-cc--box {
	left: 20px; bottom: 20px; max-width: 420px;
	border-radius: var(--khs-cc-radius); border-top: 4px solid var(--khs-cc-primary);
}
.khs-cc--box .khs-cc__inner { padding: 20px; }
.khs-cc--box .khs-cc__actions { margin-top: 14px; }

/* center */
.khs-cc--center {
	inset: 0; background: rgba(0, 0, 0, .5); box-shadow: none;
	display: flex; align-items: center; justify-content: center; padding: 16px;
}
.khs-cc--center .khs-cc__inner {
	background: var(--khs-cc-bg); max-width: 520px; width: 100%; padding: 24px;
	border-radius: var(--khs-cc-radius); border-top: 4px solid var(--khs-cc-primary); box-shadow: var(--khs-cc-shadow);
}
.khs-cc--center .khs-cc__actions { margin-top: 16px; justify-content: flex-end; }

/* ---------- Buttons ---------- */
.khs-btn {
	display: inline-flex; align-items: center; justify-content: center;
	min-height: 40px; padding: 8px 18px; border-radius: 6px;
	font: inherit; font-size: 15px; font-weight: 600; line-height: 1.2;
	cursor: pointer; border: 2px solid var(--khs-cc-primary); text-decoration: none;
	transition: background .15s, color .15s, filter .15s;
}
.khs-btn--primary { background: var(--khs-cc-primary); color: #fff; }
.khs-btn--primary:hover { filter: brightness(1.1); color: #fff; }
.khs-btn--outline { background: #fff; color: var(--khs-cc-primary); }
.khs-btn--outline:hover { background: var(--khs-cc-primary); color: #fff; }
.khs-btn--link { background: transparent; border-color: transparent; color: var(--khs-cc-primary); text-decoration: underline; padding-left: 8px; padding-right: 8px; }
.khs-btn:focus-visible, .khs-cc-reopen:focus-visible, .khs-cc-modal__close:focus-visible, .khs-switch input:focus-visible + .khs-switch__track {
	outline: 3px solid #f0b429; outline-offset: 2px;
}

/* ---------- Modal ---------- */
.khs-cc-lock { overflow: hidden; }
.khs-cc-modal {
	position: fixed; inset: 0; z-index: 999999;
	background: rgba(0, 0, 0, .55);
	display: flex; align-items: center; justify-content: center; padding: 16px;
}
.khs-cc-modal__box {
	background: var(--khs-cc-bg); width: 100%; max-width: 620px; max-height: calc(100vh - 32px);
	border-radius: var(--khs-cc-radius); box-shadow: var(--khs-cc-shadow);
	display: flex; flex-direction: column; overflow: hidden; animation: khs-cc-in .25s ease-out;
}
.khs-cc-modal__head {
	display: flex; align-items: center; justify-content: space-between;
	padding: 16px 20px; border-bottom: 1px solid var(--khs-cc-border);
	border-top: 4px solid var(--khs-cc-primary);
}
.khs-cc-modal__head h2 { margin: 0; font-size: 19px; font-weight: 700; color: var(--khs-cc-text); }
.khs-cc-modal__close {
	background: none; border: 0; font-size: 28px; line-height: 1; cursor: pointer;
	color: var(--khs-cc-muted); width: 40px; height: 40px; border-radius: 50%;
}
.khs-cc-modal__close:hover { background: #f0f0f1; }
.khs-cc-modal__body { padding: 16px 20px; overflow-y: auto; }
.khs-cc-modal__body > p { margin: 0 0 12px; color: var(--khs-cc-muted); }
.khs-cc-modal__ref { padding: 10px 20px; font-size: 13px; color: var(--khs-cc-muted); border-top: 1px solid var(--khs-cc-border); }
.khs-cc-modal__ref[hidden] { display: none; }
.khs-cc-modal__ref code { font-size: 12px; background: #f0f0f1; padding: 1px 6px; border-radius: 4px; user-select: all; word-break: break-all; }
.khs-cc-modal__foot {
	display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end;
	padding: 14px 20px; border-top: 1px solid var(--khs-cc-border); background: #f6f7f7;
}

.khs-cc-cat { border: 1px solid var(--khs-cc-border); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.khs-cc-cat__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.khs-cc-cat__label { font-weight: 700; cursor: pointer; }
.khs-cc-cat__always { font-size: 13px; font-weight: 600; color: var(--khs-cc-primary); white-space: nowrap; }
.khs-cc-cat__desc { margin: 6px 0 0; font-size: 14px; color: var(--khs-cc-muted); }

/* switch */
.khs-switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.khs-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.khs-switch__track {
	position: absolute; inset: 0; background: #a7aaad; border-radius: 26px; transition: background .2s;
}
.khs-switch__track::before {
	content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
	background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.khs-switch input:checked + .khs-switch__track { background: var(--khs-cc-primary); }
.khs-switch input:checked + .khs-switch__track::before { transform: translateX(20px); }

/* ---------- Reopen button ---------- */
.khs-cc-reopen {
	position: fixed; left: 16px; bottom: 16px; z-index: 999997;
	width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
	background: var(--khs-cc-primary); color: #fff; box-shadow: 0 3px 12px rgba(0,0,0,.25);
	display: flex; align-items: center; justify-content: center; opacity: .85; transition: opacity .15s, transform .15s;
}
.khs-cc-reopen:hover { opacity: 1; transform: scale(1.06); }

/* ---------- iframe placeholder ---------- */
.khs-cc-ph {
	background: #f6f7f7; border: 1px dashed #a7aaad; border-radius: 8px;
	padding: 20px; text-align: center; display: flex; flex-direction: column;
	align-items: center; justify-content: center; margin: 0 0 1em; min-height: 180px;
}
.khs-cc-ph p { margin: 0 0 10px; }
.khs-cc-ph p:last-child { margin: 0; }

/* ---------- Policy page ---------- */
.khs-cc-policy__table { width: 100%; border-collapse: collapse; margin: 0 0 1.5em; }
.khs-cc-policy__table th, .khs-cc-policy__table td { border: 1px solid var(--khs-cc-border); padding: 8px 10px; text-align: left; vertical-align: top; }
.khs-cc-policy__table th { background: #f6f7f7; }

@keyframes khs-cc-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .khs-cc, .khs-cc-modal__box { animation: none; } }

/* ---------- Mobile ---------- */
@media (max-width: 782px) {
	.khs-cc--bottom .khs-cc__inner { flex-direction: column; align-items: stretch; gap: 12px; padding: 16px; }
	.khs-cc--box { left: 10px; right: 10px; bottom: 10px; max-width: none; }
	.khs-cc__actions { flex-direction: column-reverse; align-items: stretch; }
	.khs-cc__actions .khs-btn { width: 100%; }
	.khs-cc-modal__foot { flex-direction: column-reverse; }
	.khs-cc-modal__foot .khs-btn { width: 100%; }
	.khs-cc-policy__table { display: block; overflow-x: auto; }
}
