/* ===== Polyline Style Editor Panel (Right Side) ===== */
.poly-style-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 340px;
    height: 100%;
    z-index: 3000;
    animation: polySlideIn 0.2s ease;
    pointer-events: none;
}

@keyframes polySlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.poly-style-panel {
    background: white;
    width: 100%;
    height: 100%;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.12);
    overflow-y: auto;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
}

.poly-style-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--bg-subtle), var(--bg-selected));
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.poly-style-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-strong);
}

.poly-style-close {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.poly-style-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.poly-style-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.poly-style-preview {
    height: 56px;
    background: var(--bg-subtle);
    border-radius: 10px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.poly-style-preview svg {
    width: 100%;
    height: 100%;
}

.poly-style-section {
    margin-bottom: 16px;
}

.poly-style-section:last-child {
    margin-bottom: 0;
}

.poly-style-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Conic ring */
.poly-conic-ring {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
    position: relative;
    margin: 0 auto 10px;
    cursor: crosshair;
}

.poly-conic-ring-inner {
    position: absolute;
    top: 26px;
    left: 26px;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.08);
}

.poly-ring-indicator {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    transform: translate(-50%, -50%);
}

/* Preset swatches */
.poly-presets {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 10px;
}

.poly-preset {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
}

.poly-preset:hover {
    transform: scale(1.15);
    border-color: #333;
}

.poly-preset.active {
    border-color: var(--text-strong);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--accent-color);
}

/* Editor row */
.poly-editor-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.poly-editor-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    width: 56px;
    flex-shrink: 0;
}

.poly-editor-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent-color);
    cursor: pointer;
}

.poly-range-val {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-color);
    width: 32px;
    text-align: right;
}

/* Dash pattern buttons */
.poly-dash-options {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.poly-dash-btn {
    width: 56px;
    height: 34px;
    border: 1.5px solid var(--border-light);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.poly-dash-btn:hover {
    border-color: var(--accent-color);
    background: var(--bg-selected);
}

.poly-dash-btn.active {
    border-color: var(--accent-color);
    background: var(--bg-selected);
    box-shadow: 0 0 0 1px var(--accent-color);
}

.poly-dash-btn svg {
    width: 44px;
    height: 10px;
}

/* Footer buttons */
.poly-style-footer {
    padding: 0 20px 20px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.poly-style-footer button {
    padding: 8px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
}

.poly-btn-cancel {
    background: var(--bg-input);
    color: var(--text-tertiary);
}

.poly-btn-cancel:hover {
    background: var(--border-light);
}

.poly-btn-save {
    background: var(--accent-color);
    color: white;
}

.poly-btn-save:hover {
    background: var(--accent-hover);
}

/* (drag-over styles moved to sidebar.css) */

.location-item:last-child {
    border-bottom: none;
}

.location-info {
    flex: 1;
    min-width: 0;
}

.location-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.loc-name-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loc-rating {
    font-size: 11px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 2px;
}

.loc-star {
    color: #f59e0b;
    font-size: 10px;
}

.loc-score {
    color: var(--text-tertiary);
    font-weight: 600;
}

.poly-meta {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

.batch-icon {
    font-size: 16px;
    min-width: 20px;
    margin-right: 3px;
    text-align: center;
    line-height: 1;
}

/* Polyline eye button color */
.eye-btn-poly {
    color: #3b82f6;
}
.eye-btn-poly.hidden-eye {
    color: #a0aec0;
}

/* Polyline type icon in sidebar */
.poly-type-icon {
    vertical-align: middle;
    margin-right: 3px;
    flex-shrink: 0;
}

.location-address {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.loading {
    text-align: center;
    padding: 40px 0;
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}


/* Context Menu */
.context-menu {
    position: absolute;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 6px 0;
    z-index: 2000;
    min-width: 160px;
    animation: fadeIn 0.1s ease-out;
}

.context-menu-item {
    padding: 8px 16px;
    font-size: 14px;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}

.context-menu-item:hover {
    background: var(--bg-hover);
    color: var(--primary-color);
}

.context-menu-item.delete {
    color: var(--danger-color);
}

.context-menu-item.delete:hover {
    background: var(--danger-light);
}

.context-menu-separator {
    height: 1px;
    background: #e5e7eb;
    margin: 4px 0;
}

/* Mobile: larger touch targets + fixed positioning (desktop fallback) */
@media (max-width: 768px) {
    .context-menu {
        position: fixed;
        max-height: calc(100vh - 8px);
        overflow-y: auto;
        min-width: 200px;
    }

    .context-menu-item {
        padding: 12px 16px;
        font-size: 15px;
        gap: 10px;
    }

    .context-menu-separator {
        margin: 6px 0;
    }

    /* Modal dialogs: prevent overflow on small screens */
    .style-editor-modal {
        width: 95vw;
        max-width: 580px;
        max-height: 85vh;
    }

    .filter-dialog {
        max-height: 85vh;
        overflow-y: auto;
    }
}

/* Long-press visual feedback: pulsing highlight on touch-hold */
@keyframes longPressHint {
    0% { background-color: transparent; }
    100% { background-color: rgba(37, 99, 235, 0.08); }
}
.long-press-active {
    animation: longPressHint 0.5s ease-out forwards;
    border-radius: 8px;
}

/* Mobile inline toolbar (replaces floating context menu on touch devices) */
.mobile-toolbar-wrap {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.mobile-toolbar-wrap.open {
    max-height: 200px;
}
.mobile-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 10px 8px;
    background: var(--bg-hover, #f0f4fa);
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.mobile-toolbar::-webkit-scrollbar { display: none; }

.mobile-toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    padding: 6px 4px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.12s;
    font-size: 10px;
    color: var(--text-secondary, #6b6b6b);
    text-align: center;
    line-height: 1.2;
    flex-shrink: 0;
    gap: 3px;
    -webkit-tap-highlight-color: transparent;
}
.mobile-toolbar-btn:active { background: rgba(45,127,249,0.10); }
.mobile-toolbar-btn .tb-icon { font-size: 20px; }
.mobile-toolbar-btn.delete { color: var(--danger-color, #e03e3e); }
.mobile-toolbar-btn.delete:active { background: rgba(224,62,62,0.08); }

.mobile-toolbar-sep {
    width: 1px;
    height: 28px;
    background: var(--border-color, #e5e7eb);
    flex-shrink: 0;
    margin: 0 4px;
}

.batch-header.toolbar-active,
.polyline-item.toolbar-active {
    background: rgba(45, 127, 249, 0.05);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Style Editor Modal */
.style-editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.15s ease-out;
}

.style-editor-modal {
    background: white;
    width: 580px;
    height: 85vh;
    max-height: 85vh;
    font-size: 15px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.2s ease-out;
}

.style-editor-header {
    padding: 16px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    font-size: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
}

.style-editor-close {
    cursor: pointer;
    font-size: 28px;
    color: #888;
    line-height: 1;
}

.style-editor-close:hover {
    color: #333;
}

.style-editor-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Combined Preview + Color Row */
.style-preview-color-row {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 14px 16px;
    background: var(--bg-hover);
    border-radius: 8px;
}

.style-preview-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transition: all 0.2s;
}

.color-picker-inline {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: none;
    flex-shrink: 0;
}

.color-picker-inline::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker-inline::-webkit-color-swatch { border: 2px solid rgba(0,0,0,0.1); border-radius: 50%; }
.color-picker-inline::-moz-color-swatch { border: 2px solid rgba(0,0,0,0.1); border-radius: 50%; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
}

.form-label {
    font-size: 16px;
    color: #666;
    font-weight: 500;
}

.color-value-text {
    font-family: monospace;
    color: #666;
    font-size: 13px;
}

/* Shape Picker */
.shape-grid {
    display: flex;
    gap: 4px;
}

.shape-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 4px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 44px;
}

.shape-option:hover { background: var(--bg-hover); }
.shape-option.selected {
    background: var(--bg-selected);
    border-color: var(--primary-color, var(--google-blue));
    box-shadow: 0 0 0 1px var(--primary-color, var(--google-blue));
}

.shape-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 26px;
    transform: scale(0.75);
}

.shape-label {
    font-size: 10px;
    color: #888;
    text-align: center;
}

.shape-option.selected .shape-label { color: var(--primary-color, var(--google-blue)); font-weight: 500; }

/* Emoji Size Slider */
.emoji-size-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding: 4px 0;
}

.emoji-size-slider {
    flex: 1;
    height: 4px;
    accent-color: var(--primary-color, var(--google-blue));
    cursor: pointer;
}

.emoji-size-value {
    font-size: 12px;
    color: #888;
    font-family: monospace;
    min-width: 32px;
    text-align: right;
}

/* Effect Picker */
.effect-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.effect-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 3px 2px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.effect-option:hover { background: var(--bg-hover); }
.effect-option.selected {
    background: var(--bg-selected);
    border-color: var(--primary-color, var(--google-blue));
    box-shadow: 0 0 0 1px var(--primary-color, var(--google-blue));
}

.effect-label {
    font-size: 10px;
    color: #888;
    text-align: center;
    line-height: 1.2;
}

.effect-option.selected .effect-label { color: var(--primary-color, var(--google-blue)); font-weight: 500; }

/* Icon Grid Category Label */
.icon-grid-category {
    grid-column: 1 / -1;
    font-size: 11px;
    color: #aaa;
    font-weight: 500;
    padding: 3px 0 1px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 0;
}

.icon-grid-category:first-child {
    padding-top: 0;
}

/* Icon Grid */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 2px;
    overflow-y: auto;
    padding: 1px;
    flex: 1;
}

.icon-option {
    aspect-ratio: 1;
    border: 1px solid transparent;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.1s;
    padding: 1px;
    filter: drop-shadow(1px 0 0 rgba(0,0,0,0.6)) drop-shadow(-1px 0 0 rgba(0,0,0,0.6)) drop-shadow(0 1px 0 rgba(0,0,0,0.6)) drop-shadow(0 -1px 0 rgba(0,0,0,0.6));
}

.icon-option:hover {
    background: var(--bg-hover);
}

.icon-option.selected {
    background: var(--bg-selected);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
}


.style-editor-footer {
    padding: 16px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f9fafb;
}

.btn-secondary {
    padding: 10px 20px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-primary {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
