/* ICP Dealer Map — styles (สีแดงตราม้าบิน) */
.icpdm {
	--icpdm-red: #b3151b;
	--icpdm-red-dark: #7a0c10;
	--icpdm-pink: #fdeaea;
	--icpdm-text: #1f1f1f;
	--icpdm-muted: #6b6b6b;
	--icpdm-border: #e6e6e6;
	--icpdm-radius: 14px;
	--icpdm-h: 620px;
	font-family: inherit;
	color: var(--icpdm-text);
	margin: 0 auto;
}
.icpdm *, .icpdm *::before, .icpdm *::after { box-sizing: border-box; }

.icpdm__head { margin-bottom: 18px; }
.icpdm__title { color: var(--icpdm-red); font-size: 32px; font-weight: 700; margin: 0 0 4px; line-height: 1.3; }
.icpdm__count { margin: 0; color: var(--icpdm-muted); font-size: 16px; }

.icpdm__box {
	display: grid;
	grid-template-columns: 300px 1fr;
	height: var(--icpdm-h);
	background: #fff;
	border: 1px solid var(--icpdm-border);
	border-radius: var(--icpdm-radius);
	box-shadow: 0 6px 24px rgba(0,0,0,.08);
	overflow: hidden;
}

/* ---------- side panel ---------- */
.icpdm__side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--icpdm-border); background: #fff; }
.icpdm__search { position: relative; margin: 16px 16px 8px; }
.icpdm__search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #888; pointer-events: none; }
.icpdm__search input {
	width: 100%; height: 44px; padding: 0 44px 0 38px; border: 1px solid #cfcfcf; border-radius: 8px;
	font-size: 14px; font-family: inherit; color: var(--icpdm-text); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.icpdm__search input:focus { border-color: var(--icpdm-red); box-shadow: 0 0 0 3px rgba(179,21,27,.12); }
.icpdm__search input::placeholder { color: #9a9a9a; }
.icpdm__locate {
	position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; border-radius: 6px;
	background: transparent; color: var(--icpdm-red); cursor: pointer; display: grid; place-items: center;
}
.icpdm__locate:hover { background: var(--icpdm-pink); }
.icpdm.is-locating .icpdm__locate svg { animation: icpdm-spin 1s linear infinite; }
@keyframes icpdm-spin { to { transform: rotate(360deg); } }
.icpdm__status { margin: 0 16px 6px; min-height: 18px; font-size: 12px; color: var(--icpdm-muted); }

.icpdm__list { list-style: none; margin: 0; padding: 0 16px 16px; overflow-y: auto; flex: 1; min-height: 0; }
.icpdm__item {
	padding: 14px 12px; border-bottom: 1px solid var(--icpdm-border); border-radius: 8px; cursor: pointer; transition: background .15s;
	font-size: 13px; line-height: 1.55;
}
.icpdm__item:hover, .icpdm__item:focus-visible { background: #f7f7f7; outline: none; }
.icpdm__item.is-active { background: var(--icpdm-pink); border-bottom-color: transparent; }
.icpdm__item.no-coord { opacity: .7; }
.icpdm__item-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.icpdm__item strong { font-size: 15px; font-weight: 700; color: var(--icpdm-text); }
.icpdm__item.is-active strong { color: var(--icpdm-red); }
.icpdm__dist { flex: none; font-size: 12px; color: var(--icpdm-text); font-weight: 700; white-space: nowrap; background: #f1f1f1; border-radius: 999px; padding: 2px 8px; }
.icpdm__item.is-active .icpdm__dist { background: #fff; }
.icpdm__formulas { color: var(--icpdm-red); margin-top: 4px; }
.icpdm__addr { color: var(--icpdm-muted); margin-top: 4px; }
.icpdm__phone { color: var(--icpdm-muted); display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.icpdm__empty { padding: 24px 12px; color: var(--icpdm-muted); text-align: center; }

/* ---------- map ---------- */
.icpdm__map { min-height: 0; height: 100%; width: 100%; background: #e9f3f7; }
.icpdm__map .leaflet-container { font-family: inherit; }

/* marker: วงกลมแดงจุดขาว (เหมือน mockup) */
.icpdm-pin span {
	display: block; width: 30px; height: 30px; border-radius: 50%; background: var(--icpdm-red, #b3151b);
	border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); position: relative;
}
.icpdm-pin span::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: #fff; }
.icpdm-pin:hover span { transform: scale(1.12); }
/* marker ที่เลือก: หมุด SVG ตั้งตรง */
.icpdm-pin--active svg { display: block; filter: drop-shadow(0 4px 6px rgba(0,0,0,.4)); transform-origin: bottom center; animation: icpdm-drop .25s ease-out; }
@keyframes icpdm-drop { from { transform: translateY(-10px) scale(.9); opacity: .4; } to { transform: none; opacity: 1; } }
.icpdm-user span { display: block; width: 22px; height: 22px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26,115,232,.25); }

/* ป้ายชื่อร้านข้างหมุด: โชว์เฉพาะตอนซูมเข้า */
.icpdm-label.leaflet-tooltip {
	background: transparent; border: 0; box-shadow: none; padding: 0 0 0 2px; font-size: 14px; font-weight: 700; color: #1f1f1f;
	text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 4px #fff, 1px 1px 0 #fff, -1px -1px 0 #fff; white-space: nowrap; pointer-events: none;
}
.icpdm-label.leaflet-tooltip::before { display: none; }
.icpdm__map:not(.icpdm--labels) .icpdm-label:not(.icpdm-label--user) { display: none; }

/* cluster */
.icpdm-cluster { background: rgba(179,21,27,.25); border-radius: 50%; }
.icpdm-cluster span {
	display: grid; place-items: center; width: 40px; height: 40px; margin: 0; border-radius: 50%; background: var(--icpdm-red, #b3151b);
	color: #fff; font-weight: 700; font-size: 14px; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3);
}

/* popup card */
.icpdm-popup .leaflet-popup-content-wrapper { padding: 0; border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.icpdm-popup .leaflet-popup-content { margin: 0; width: auto !important; min-width: 380px; max-width: min(420px, calc(100vw - 48px)); line-height: 1.5; overflow-wrap: anywhere; }
.icpdm-popup .leaflet-popup-tip { box-shadow: 0 3px 10px rgba(0,0,0,.2); }
.icpdm-popup .leaflet-popup-close-button { top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,.9); color: #333; font-size: 20px; line-height: 28px; text-align: center; padding: 0; }
.icpdm-card__img { display: block; width: 100%; height: 200px; object-fit: cover; }
.icpdm-card__body { padding: 14px 16px 16px; }
.icpdm-card__name { margin: 0 0 6px; font-size: 18px; font-weight: 700; color: #1f1f1f; }
.icpdm-card__dist { color: #b3151b; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.icpdm-card__dl { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 6px 10px; margin: 0 0 14px; font-size: 14px; }
.icpdm-card__dl dt { color: #777; }
.icpdm-card__dl dd { margin: 0; color: #1f1f1f; }
.icpdm-card__dl dd a { color: inherit; text-decoration: none; }
.icpdm-card__formulas { color: #b3151b; white-space: normal; overflow-wrap: anywhere; }
.icpdm-card__btn {
	display: block; text-align: center; padding: 12px; border-radius: 8px; color: #fff !important; font-weight: 700; font-size: 16px; text-decoration: none !important;
	background: linear-gradient(180deg, #d0252b 0%, #a3121a 100%); box-shadow: 0 3px 8px rgba(163,18,26,.35); transition: filter .15s;
}
.icpdm-card__btn:hover { filter: brightness(1.08); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
	.icpdm__box { grid-template-columns: 1fr; height: auto; }
	.icpdm__map { height: 440px; order: 1; }
	.icpdm-popup .leaflet-popup-content { min-width: min(300px, calc(100vw - 64px)); max-height: 360px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
	.icpdm-card__img { height: 120px; }
	.icpdm__side { order: 2; border-right: 0; border-top: 1px solid var(--icpdm-border); }
	.icpdm__list { max-height: 420px; }
	.icpdm__title { font-size: 26px; }
}

/* attribution แบบเล็ก ไม่รบกวนสายตา (ต้องคงไว้ตามเงื่อนไข OpenStreetMap) */
.icpdm__map .leaflet-control-attribution, .icpdm-point .leaflet-control-attribution {
	font-size: 9px; line-height: 1.2; padding: 1px 5px; background: rgba(255,255,255,.6); color: #777; border-radius: 4px 0 0 0;
}
.icpdm__map .leaflet-control-attribution a, .icpdm-point .leaflet-control-attribution a { color: #777; text-decoration: none; }

/* ระยะทางตามถนน */
.icpdm__dist--road { background: #fdecec; color: #b3151b; }
.icpdm__item.is-active .icpdm__dist--road { background: #fff; }
.icpdm-card__distv { font-weight: 700; }
