/* ==========================================================================
   Local Store Pro - Frontend Styles (iframe edition)
   ========================================================================== */

.lsp-wrapper {
    --lsp-height: 600px;
    --lsp-primary: #d32f2f;
    --lsp-primary-soft: rgba(211, 47, 47, 0.08);
    --lsp-sidebar-width: 360px;
    --lsp-border: #e5e7eb;
    --lsp-bg: #ffffff;
    --lsp-bg-soft: #f9fafb;
    --lsp-text: #111827;
    --lsp-text-muted: #6b7280;
    --lsp-radius: 10px;
    --lsp-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);

    display: flex;
    height: var(--lsp-height);
    background: var(--lsp-bg);
    border: 1px solid var(--lsp-border);
    border-radius: var(--lsp-radius);
    overflow: hidden;
    box-shadow: var(--lsp-shadow);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--lsp-text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    box-sizing: border-box;
}

.lsp-wrapper *,
.lsp-wrapper *::before,
.lsp-wrapper *::after {
    box-sizing: border-box;
}

.lsp-sidebar-right { flex-direction: row-reverse; }

/* Sidebar
   -------------------------------------------------------------------------- */
.lsp-sidebar {
    width: var(--lsp-sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--lsp-bg);
    border-right: 1px solid var(--lsp-border);
}
.lsp-sidebar-right .lsp-sidebar {
    border-right: none;
    border-left: 1px solid var(--lsp-border);
}

/* Search box */
.lsp-search-box {
    padding: 16px 16px 12px;
    background: var(--lsp-bg);
    border-bottom: 1px solid var(--lsp-border);
}

.lsp-search-wrap {
    position: relative;
    margin-bottom: 10px;
}

.lsp-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--lsp-text-muted);
    pointer-events: none;
}

.lsp-wrapper #lsp-search {
    width: 100%;
    padding: 11px 12px 11px 38px;
    border: 1px solid var(--lsp-border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--lsp-bg-soft);
    color: var(--lsp-text);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    font-family: inherit;
}
.lsp-wrapper #lsp-search:focus {
    outline: none;
    border-color: var(--lsp-primary);
    background: #fff;
    box-shadow: 0 0 0 3px var(--lsp-primary-soft);
}

.lsp-wrapper #lsp-province-filter {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--lsp-border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--lsp-bg-soft);
    color: var(--lsp-text);
    cursor: pointer;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.lsp-wrapper #lsp-province-filter:focus {
    outline: none;
    border-color: var(--lsp-primary);
    background-color: #fff;
    box-shadow: 0 0 0 3px var(--lsp-primary-soft);
}

/* Count bar */
.lsp-count-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--lsp-primary);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.2px;
}
.lsp-count-bar strong { font-weight: 700; font-size: 14px; }

.lsp-locate-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
.lsp-locate-btn:hover { background: rgba(255, 255, 255, 0.28); }

/* List */
.lsp-list {
    flex: 1;
    overflow-y: auto;
    background: var(--lsp-bg);
    scrollbar-width: thin;
    scrollbar-color: #cfcfcf transparent;
}
.lsp-list::-webkit-scrollbar { width: 6px; }
.lsp-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.lsp-list::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

.lsp-item {
    padding: 14px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background 0.15s, padding-left 0.2s;
    position: relative;
}

.lsp-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--lsp-primary);
    transform: scaleY(0);
    transform-origin: center;
    transition: transform 0.2s;
}

.lsp-item:hover { background: var(--lsp-primary-soft); padding-left: 19px; }
.lsp-item:hover::before, .lsp-item.is-active::before { transform: scaleY(1); }
.lsp-item.is-active { background: var(--lsp-primary-soft); padding-left: 19px; }

.lsp-item-title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--lsp-text);
    line-height: 1.4;
}

.lsp-item-title .lsp-province-badge {
    display: inline-block;
    background: var(--lsp-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: 4px;
    letter-spacing: 0.3px;
    vertical-align: middle;
    position: relative;
    top: -1px;
    white-space: nowrap;
    text-transform: uppercase;
}

.lsp-item .lsp-meta {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 13px;
    color: var(--lsp-text-muted);
    margin-top: 3px;
    line-height: 1.45;
}
.lsp-item .lsp-meta svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--lsp-text-muted);
}
.lsp-item .lsp-meta-link {
    color: inherit;
    text-decoration: none;
}
.lsp-item .lsp-meta-link:hover {
    color: var(--lsp-primary);
    text-decoration: underline;
}
.lsp-item .lsp-distance {
    display: inline-block;
    background: #fff;
    border: 1px solid var(--lsp-border);
    border-radius: 4px;
    padding: 1px 7px;
    font-size: 11px;
    color: var(--lsp-text-muted);
    font-weight: 500;
}

.lsp-item-cta {
    display: inline-flex;
    margin-top: 10px;
    font-size: 12px !important;
    padding: 6px 11px !important;
    line-height: 1.25 !important;
}

.lsp-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--lsp-text-muted);
    font-size: 14px;
}

/* Main panel = detail card + iframe stack
/* Main panel = just the iframe map now (sidebar holds all info)
   -------------------------------------------------------------------------- */
.lsp-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--lsp-bg-soft);
}

/* Buttons (used for the Chỉ đường CTA in each sidebar item) */
.lsp-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.15s, transform 0.15s;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.2;
}

.lsp-btn:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.lsp-btn-primary {
    background: var(--lsp-primary);
    color: #fff !important;
}

.lsp-btn-outline {
    background: #fff;
    color: var(--lsp-text) !important;
    border: 1px solid var(--lsp-border);
}

/* Map iframe wrap
   Use !important on the iframe rules — many WordPress themes have
   "iframe { max-width: 100%; height: auto; }" which would otherwise
   collapse our map to zero height. */
.lsp-map-wrap {
    flex: 1 1 auto;
    position: relative;
    min-height: 380px;
    background: #e5e7eb;
    overflow: hidden;
}

.lsp-wrapper #lsp-map-iframe,
.lsp-map-wrap > iframe {
    width: 100% !important;
    height: 100% !important;
    min-height: 380px !important;
    max-width: none !important;
    border: 0 !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    /* Disable interaction inside the iframe — prevents Google's broken
       "Place info couldn't load" popup. Custom pin overlay handles clicks instead. */
    pointer-events: none !important;
}

/* Custom pin overlay (sits centered on the iframe, on top of Google's pin) */
.lsp-pin-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -100%);
    width: 32px;
    height: 42px;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--lsp-primary);
    z-index: 5;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
    transition: transform 0.2s ease-out, filter 0.2s;
    animation: lsp-pin-bounce 0.55s ease-out;
}

.lsp-pin-overlay:hover {
    transform: translate(-50%, calc(-100% - 4px));
    filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.4));
}

.lsp-pin-overlay:focus {
    outline: none;
    filter: drop-shadow(0 0 0 3px var(--lsp-primary-soft)) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}

.lsp-pin-overlay svg {
    display: block;
    width: 100%;
    height: 100%;
}

@keyframes lsp-pin-bounce {
    0%   { transform: translate(-50%, -200%); opacity: 0; }
    60%  { transform: translate(-50%, -95%); opacity: 1; }
    100% { transform: translate(-50%, -100%); }
}

/* Custom popup shown above the pin when clicked */
.lsp-pin-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-100% - 52px));
    width: max-content;
    max-width: min(320px, calc(100% - 32px));
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
    padding: 14px 16px 14px;
    z-index: 10;
    display: none;
    pointer-events: auto;
    color: var(--lsp-text);
    text-align: left;
}

.lsp-pin-popup.is-open {
    display: block;
    animation: lsp-popup-in 0.18s ease-out;
}

.lsp-pin-popup::after {
    content: "";
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 14px;
    height: 14px;
    background: #fff;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.05);
}

@keyframes lsp-popup-in {
    from { opacity: 0; transform: translate(-50%, calc(-100% - 66px)); }
    to   { opacity: 1; transform: translate(-50%, calc(-100% - 52px)); }
}

.lsp-pin-popup-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--lsp-text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lsp-pin-popup-close:hover {
    background: var(--lsp-bg-soft);
    color: var(--lsp-text);
}

.lsp-pin-popup-title {
    margin: 0 26px 8px 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--lsp-primary);
}

.lsp-pin-popup-title .lsp-province-badge {
    display: inline-block;
    background: var(--lsp-primary);
    color: #fff;
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: 4px;
    letter-spacing: 0.3px;
    vertical-align: middle;
    position: relative;
    top: -1px;
    text-transform: uppercase;
}

.lsp-pin-popup-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 4px 0;
    font-size: 13px;
    color: var(--lsp-text);
    line-height: 1.45;
}
.lsp-pin-popup-row svg {
    flex-shrink: 0;
    margin-top: 3px;
    color: var(--lsp-primary);
}
.lsp-pin-popup-row a {
    color: #1d4ed8;
    text-decoration: none;
}
.lsp-pin-popup-row a:hover { text-decoration: underline; }

.lsp-pin-popup-cta {
    margin-top: 10px;
    width: 100%;
    justify-content: center;
}

.lsp-map-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--lsp-text-muted);
    background: var(--lsp-bg-soft);
    text-align: center;
    padding: 20px;
}
.lsp-map-placeholder svg { color: var(--lsp-text-muted); opacity: 0.5; }
.lsp-map-placeholder p { margin: 0; font-size: 14px; }

/* Error */
.lsp-error {
    padding: 16px 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    font-size: 14px;
}
.lsp-error a { color: #991b1b; font-weight: 600; text-decoration: underline; }

/* Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 782px) {
    .lsp-wrapper {
        flex-direction: column !important;
        height: auto;
    }
    .lsp-sidebar {
        width: 100% !important;
        max-height: 60vh;
        border-right: none !important;
        border-left: none !important;
        border-bottom: 1px solid var(--lsp-border);
    }
    .lsp-map-wrap { height: 360px; min-height: 360px; }
}
