/* ===== WRAP — fullscreen ===== */
#lgc-wrap {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    position: fixed;
    inset: 0;
    z-index: 9000;
    box-sizing: border-box;
}

/* WP Admin Bar offset */
.admin-bar #lgc-wrap {
    top: 32px;
}

@media screen and (max-width: 782px) {
    .admin-bar #lgc-wrap {
        top: 46px;
    }
}

/* ===== BACKGROUND MAP ===== */
#lgc-bg-map {
    position: absolute;
    inset: 0;
    z-index: 0;
}

/* ===== OVERLAY ===== */
#lgc-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10,20,40,0.55);
    z-index: 1;
}

/* ===== SEARCH MODAL ===== */
#lgc-search-modal {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    padding: 20px;
    box-sizing: border-box;
}

.lgc-modal-box {
    background: #fff;
    border-radius: 20px;
    padding: 40px 44px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.35);
    box-sizing: border-box;
}

.lgc-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #111;
    margin: 0 0 6px 0;
}

.lgc-modal-sub {
    color: #777;
    font-size: 14px;
    margin: 0 0 22px 0;
}

/* ===== FORM ===== */
.lgc-modal-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Autocomplete */
.lgc-autocomplete-wrap {
    position: relative;
}

.lgc-autocomplete-wrap input[type="text"],
.lgc-modal-form > input[type="text"] {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    color: #111;
    background: #f8fafc;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    box-sizing: border-box;
}

.lgc-autocomplete-wrap input[type="text"]:focus,
.lgc-modal-form > input[type="text"]:focus {
    border-color: #1a56a0;
    background: #fff;
}

.lgc-autocomplete-wrap input.lgc-selected {
    border-color: #16a34a;
    background: #f0fdf4;
}

#lgc-autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 100;
    overflow: hidden;
    display: none;
}

.lgc-ac-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f4f4f4;
    transition: background 0.15s;
}
.lgc-ac-item:last-child { border-bottom: none; }
.lgc-ac-item:hover { background: #f0f7ff; }

.lgc-ac-name {
    font-size: 14px;
    font-weight: 600;
    color: #111;
}

.lgc-ac-addr {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

/* Selects row */
.lgc-modal-row-selects {
    display: flex;
    gap: 12px;
}

.lgc-select-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lgc-select-wrap label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.lgc-select-wrap select {
    padding: 13px 16px;
    height: 50px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    color: #111;
    background: #f8fafc;
    outline: none;
    box-sizing: border-box;
    appearance: auto;
    -webkit-appearance: auto;
}

/* Spinner animation */
@keyframes lgc-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.lgc-spinner-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0 4px;
}

.lgc-spinner-circle {
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: #1a56a0;
    border-radius: 50%;
    animation: lgc-spin 0.8s linear infinite;
    flex-shrink: 0;
}

.lgc-spinner-text {
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

/* Button */
.lgc-modal-btn {
    background: #1a56a0;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 15px 32px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    align-self: flex-start;
}
.lgc-modal-btn:hover:not(:disabled) { background: #154080; }
.lgc-modal-btn:disabled { background: #9ab0cc; cursor: not-allowed; }

.lgc-error {
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 14px;
}

/* ===== RESULT AREA ===== */
#lgc-result {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
}

#lgc-result-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
    flex-shrink: 0;
    z-index: 10;
}

#lgc-result-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 140px;
}

#lgc-result-title {
    font-size: 15px;
    font-weight: 700;
    color: #111;
}

#lgc-result-meta {
    font-size: 12px;
    color: #888;
}

#lgc-legend {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: #555;
    flex-wrap: wrap;
}

.lgc-legend-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 11px;
    color: #fff;
}

.lgc-legend-text { margin-right: 8px; font-size: 12px; }
.lgc-green  { background: #16a34a; }
.lgc-orange { background: #ea580c; }
.lgc-red    { background: #dc2626; }

.lgc-reset-btn {
    background: #f1f5f9;
    color: #334155;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.lgc-reset-btn:hover { background: #e2e8f0; }

/* ===== MAP (result) ===== */
#lgc-map {
    flex: 1;
    width: 100%;
    z-index: 0;
    min-height: 0;
}

/* ===== STATS ===== */
#lgc-stats {
    display: flex;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.lgc-stat-box {
    flex: 1;
    padding: 12px;
    text-align: center;
    border-right: 1px solid #e2e8f0;
}
.lgc-stat-box:last-child { border-right: none; }

.lgc-stat-num { font-size: 22px; font-weight: 700; }
.lgc-stat-label { font-size: 11px; color: #888; margin-top: 2px; }

/* ===== PINS ===== */
.lgc-pin {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    border: 3px solid rgba(255,255,255,0.9);
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.15s;
}
.lgc-pin:hover { transform: scale(1.2); }
.lgc-pin-green  { background: #16a34a; }
.lgc-pin-orange { background: #ea580c; }
.lgc-pin-red    { background: #dc2626; }

/* ===== PIN CLICK POPUP ===== */
#lgc-result-popup {
    position: fixed;
    inset: 0;
    background: rgba(10,20,40,0.55);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.lgc-rp-box {
    background: #fff;
    border-radius: 16px;
    padding: 16px 20px;
    width: 100%;
    max-width: 480px;
    height: auto;
    max-height: 92vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    box-sizing: border-box;
}

.lgc-rp-close {
    position: absolute;
    top: 12px; right: 14px;
    background: none;
    border: none;
    font-size: 22px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
.lgc-rp-close:hover { color: #333; }

.lgc-rp-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.lgc-rp-pos-badge {
    width: 38px; height: 38px;
    border-radius: 50%;
    font-size: 16px; font-weight: 700;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.lgc-rp-pos-label { font-size: 11px; color: #888; margin-bottom: 2px; }
.lgc-rp-pos-text  { font-size: 14px; font-weight: 700; color: #111; }

.lgc-rp-list { list-style: none; margin: 0; padding: 0; }

.lgc-rp-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 4px;
    border-bottom: 1px solid #f4f4f4;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}
.lgc-rp-item:hover { background: #f8fafc; }
.lgc-rp-item:last-child { border-bottom: none; }
.lgc-rp-item.lgc-mine {
    background: #dcfce7;
    border: 2px solid #16a34a;
    border-radius: 8px;
    padding: 6px 8px;
}
.lgc-rp-item.lgc-mine:hover { background: #bbf7d0; }

.lgc-rp-rank {
    width: 24px; height: 24px;
    border-radius: 50%;
    font-size: 11px; font-weight: 700; color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.lgc-rp-info { flex: 1; min-width: 0; }
.lgc-rp-name {
    font-size: 12px;
    font-weight: 600;
    color: #1a56a0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    display: block;
}
.lgc-rp-name:hover { text-decoration: underline; }
.lgc-rp-name.lgc-mine-name { color: #15803d; font-size: 13px; font-weight: 700; }
.lgc-rp-meta { font-size: 10px; color: #999; margin-top: 1px; }
.lgc-rp-stars { color: #f59e0b; }

@media (max-width: 640px) {
    .lgc-modal-box { padding: 28px 20px; }
    .lgc-modal-row-selects { flex-direction: column; }
    .lgc-stat-num { font-size: 18px; }
    .lgc-rp-box { padding: 22px 18px; }
}

/* ===== HISTORY PANEL ===== */
#lgc-history-panel {
    position: fixed;
    inset: 0;
    background: rgba(10,20,40,0.65);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.lgc-history-box {
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
}

.lgc-history-loading {
    color: #888;
    font-size: 14px;
    padding: 20px 0;
    text-align: center;
}

.lgc-history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    background: #fff;
}
.lgc-history-item:hover { background: #f0f7ff; border-color: #1a56a0; }

.lgc-history-icon {
    width: 40px; height: 40px;
    background: #1a56a0;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.lgc-history-info { flex: 1; min-width: 0; }
.lgc-history-biz { font-size: 14px; font-weight: 700; color: #111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lgc-history-kw  { font-size: 12px; color: #64748b; margin-top: 2px; }
.lgc-history-date { font-size: 11px; color: #94a3b8; white-space: nowrap; }

.lgc-history-actions { display: flex; gap: 6px; }

.lgc-hist-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    color: #475569;
    white-space: nowrap;
    transition: background 0.15s;
}
.lgc-hist-btn:hover { background: #e2e8f0; }
.lgc-hist-btn-del { color: #dc2626; }
.lgc-hist-btn-del:hover { background: #fee2e2; border-color: #fecaca; }

.lgc-btn-ghost {
    background: transparent;
    border: 1.5px solid rgba(255,255,255,0.4);
    color: #fff;
    font-size: 13px;
    padding: 10px 18px;
}
.lgc-btn-ghost:hover { background: rgba(255,255,255,0.1); }

.lgc-history-empty {
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
    padding: 30px 0;
}

/* ===== TOP BAR ===== */
#lgc-top-bar {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.95);
    border-radius: 12px;
    padding: 8px 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    backdrop-filter: blur(8px);
}

#lgc-top-bar-left { display: flex; gap: 8px; }
#lgc-top-bar-right { display: flex; gap: 8px; margin-left: 8px; padding-left: 8px; border-left: 1px solid #e2e8f0; }

.lgc-top-btn {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.lgc-top-btn:hover { background: #e2e8f0; color: #111; }
.lgc-top-btn-primary { background: #1a56a0; color: #fff; border-color: #1a56a0; }
.lgc-top-btn-primary:hover { background: #154080; }

/* Modal close button visible */
.lgc-modal-close {
    position: absolute;
    top: 14px; right: 18px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    width: 30px; height: 30px;
    font-size: 18px;
    color: #64748b;
    cursor: pointer;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.lgc-modal-close:hover { background: #e2e8f0; color: #111; }

/* ===== HISTORY GROUPS ===== */
.lgc-hist-group {
    margin-bottom: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.lgc-hist-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #1a56a0;
    color: #fff;
}

.lgc-hist-group-icon { font-size: 16px; }

.lgc-hist-group-name {
    font-size: 14px;
    font-weight: 700;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lgc-hist-group-count {
    font-size: 11px;
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.lgc-hist-group-items .lgc-history-item {
    border-radius: 0;
    border: none;
    border-bottom: 1px solid #f1f5f9;
    padding: 10px 14px;
}
.lgc-hist-group-items .lgc-history-item:last-child { border-bottom: none; }

.lgc-history-meta {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}
