/* ─────────────────────────────────────────────────────────────────────────────
   Centralized Store Locator v1.1
   All colours reference CSS variables so CI overrides from the Settings page
   apply automatically per-site.
───────────────────────────────────────────────────────────────────────────── */

/* Default token values — overridden per-site via inline style injection */
#csl-app {
    --csl-primary:         #2563eb;
    --csl-primary-hover:   #1d4ed8;
    --csl-secondary:       #16a34a;
    --csl-secondary-hover: #15803d;
    --csl-height:          650px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
                 Arial, "Noto Sans Thai", sans-serif;
    font-size: 14px;
    color: #111827;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.csl-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.csl-search-wrap {
    position: relative;
    flex: 1;
    min-width: 180px;
}
.csl-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: #9ca3af;
    pointer-events: none;
}
.csl-search-input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    box-sizing: border-box;
}
.csl-search-input:focus {
    border-color: var(--csl-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--csl-primary) 15%, transparent);
}

.csl-select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
    outline: none;
    cursor: pointer;
    transition: border-color .15s;
}
.csl-select:focus { border-color: var(--csl-primary); }

.csl-btn-geo {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.csl-btn-geo:hover { border-color: var(--csl-primary); color: var(--csl-primary); }
.csl-btn-geo--active {
    background: var(--csl-primary);
    border-color: var(--csl-primary);
    color: #fff;
}
.csl-btn-geo:disabled { opacity: .6; cursor: not-allowed; }

.csl-count {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    margin-left: auto;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.csl-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: var(--csl-height);
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

/* ── Store List ──────────────────────────────────────────────────────────── */
.csl-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
    border-right: 1px solid #e5e7eb;
}
.csl-list::-webkit-scrollbar       { width: 4px; }
.csl-list::-webkit-scrollbar-track { background: #f1f5f9; }
.csl-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.csl-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    padding: 32px;
    text-align: center;
}

/* ── Store Card ──────────────────────────────────────────────────────────── */
.csl-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    border: none;
    border-bottom: 1px solid #f3f4f6;
    background: #fff;
    cursor: pointer;
    transition: background .12s;
    border-left: 3px solid transparent;
}
.csl-card:hover  { background: #f8faff; }
.csl-card--active {
    background: #eff6ff;
    border-left-color: var(--csl-primary);
}

.csl-card__thumb {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
}
.csl-card__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.csl-card__img-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: #d1d5db;
}

.csl-card__body  { flex: 1; min-width: 0; }
.csl-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 2px;
}
.csl-card__name {
    font-weight: 600;
    font-size: 13px;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.csl-card__province {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 2px;
}
.csl-card__address {
    font-size: 12px;
    color: #4b5563;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.csl-card__tags,
.csl-card__phones {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

/* ── Badges & Tags ───────────────────────────────────────────────────────── */
.csl-badge-open {
    flex-shrink: 0;
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 99px;
    background: color-mix(in srgb, var(--csl-secondary) 12%, transparent);
    color: var(--csl-secondary);
    white-space: nowrap;
}
.csl-badge-closed {
    flex-shrink: 0;
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 99px;
    background: #fef2f2;
    color: #dc2626;
    white-space: nowrap;
}

.csl-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 99px;
    white-space: nowrap;
}
.csl-tag--hours {
    background: color-mix(in srgb, var(--csl-secondary) 10%, transparent);
    color: var(--csl-secondary);
}
.csl-tag--phone {
    background: color-mix(in srgb, var(--csl-primary) 10%, transparent);
    color: var(--csl-primary);
}
.csl-tag--dist {
    background: #f3f4f6;
    color: #374151;
}

/* ── Map Panel ───────────────────────────────────────────────────────────── */
.csl-map-panel {
    display: flex;
    flex-direction: column;
    background: #f1f5f9;
}
.csl-map-wrap   { position: relative; flex: 1; }
.csl-map-frame  { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.csl-map-placeholder {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: #f8fafc;
}

/* ── Detail Strip ────────────────────────────────────────────────────────── */
.csl-detail {
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 14px 16px;
    max-height: 220px;
    overflow-y: auto;
}
.csl-detail__inner {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
}
.csl-detail__info  { flex: 1; min-width: 200px; }
.csl-detail__name  { font-weight: 700; font-size: 14px; color: #111827; }
.csl-detail__address { font-size: 12px; color: #6b7280; margin-top: 2px; }
.csl-detail__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
}

/* ── Hours accordion ─────────────────────────────────────────────────────── */
.csl-hours-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--csl-primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-top: 4px;
}
.csl-hours-table {
    margin-top: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    font-size: 12px;
}
.csl-hours-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
    border-bottom: 1px solid #f3f4f6;
}
.csl-hours-row:last-child { border-bottom: none; }
.csl-hours-row--today {
    background: color-mix(in srgb, var(--csl-primary) 6%, transparent);
    font-weight: 600;
}
.csl-hours-day  { color: #374151; }
.csl-hours-time { color: #111827; }
.csl-hours-time--closed { color: #dc2626; }

/* ── Action buttons ──────────────────────────────────────────────────────── */
.csl-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background .12s;
}
.csl-btn--primary {
    background: var(--csl-primary);
    color: #fff;
}
.csl-btn--primary:hover { background: var(--csl-primary-hover); color: #fff; }
.csl-btn--line   { background: #06c755; color: #fff; }
.csl-btn--line:hover { background: #05a847; color: #fff; }
.csl-btn--dark   { background: #1f2937; color: #fff; }
.csl-btn--dark:hover { background: #111827; color: #fff; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.csl-spin { animation: csl-spin 1s linear infinite; }
@keyframes csl-spin { to { transform: rotate(360deg); } }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
    .csl-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .csl-list {
        max-height: 360px;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }
    .csl-map-wrap { height: 380px; position: relative; }
    .csl-map-frame { position: absolute; }
}
