/* ── Reset & Base ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --font-body: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --color-food: #FF8C42;
    --color-culture: #E63946;
    --color-nature: #2D9F5F;
    --color-shopping: #4A90E2;
    --color-arts: #9B59B6;
    --color-neighborhoods: #16A085;
    --color-accommodation: #F39C12;
    --color-sports: #64748B;
    --color-entertainment: #E84393;

    --panel-bg: #FAFAF9;
    --panel-border: #E8E5E0;
    --panel-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --text-primary: #1A1A19;
    --text-secondary: #6B6966;
    --text-muted: #9C9A96;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    overflow: hidden;
}

/* ── Map ── */
#map {
    position: absolute;
    inset: 0;
}

/* ── Filter Panel ── */
#filter-panel {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 300px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--panel-shadow);
    padding: 20px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--panel-border) transparent;
}

#filter-panel::-webkit-scrollbar {
    width: 4px;
}

#filter-panel::-webkit-scrollbar-thumb {
    background: var(--panel-border);
    border-radius: 2px;
}

.panel-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.panel-header-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.panel-header h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

#pin-count {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Panel Sections ── */
.panel-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.hint {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Geocoder Override ── */
#geocoder-container .mapboxgl-ctrl-geocoder {
    width: 100%;
    max-width: none;
    box-shadow: none;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 13px;
    min-width: 0;
}

#geocoder-container .mapboxgl-ctrl-geocoder input {
    font-family: var(--font-body);
    font-size: 13px;
    padding: 6px 8px 6px 32px;
    height: 36px;
}

#geocoder-container .mapboxgl-ctrl-geocoder .suggestions {
    font-family: var(--font-body);
    font-size: 13px;
    border-radius: var(--radius-sm);
}

/* ── Travel Time Slider ── */
.travel-time-slider-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 2px;
}

.travel-time-value {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    color: #4A90E2;
    text-align: center;
    height: 18px;
    line-height: 18px;
}

#travel-time-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 3px;
    background: var(--panel-border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    margin: 6px 0 2px;
}

#travel-time-slider:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#travel-time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4A90E2;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    margin-top: -6.5px;
}

#travel-time-slider:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
}

#travel-time-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #4A90E2;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

#travel-time-slider:disabled::-moz-range-thumb {
    cursor: not-allowed;
}

#travel-time-slider::-webkit-slider-runnable-track {
    height: 3px;
    border-radius: 2px;
}

#travel-time-slider::-moz-range-track {
    height: 3px;
    background: var(--panel-border);
    border-radius: 2px;
    border: none;
}

.travel-time-ticks {
    display: flex;
    justify-content: space-between;
    padding: 0;
}

.travel-time-ticks span {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
    min-width: 0;
}

/* ── Travel Mode Tabs ── */
.travel-mode-tabs {
    display: flex;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.travel-mode-tabs.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.travel-mode-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 0;
    background: white;
    border: none;
    border-right: 1px solid var(--panel-border);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.travel-mode-tab:last-child {
    border-right: none;
}

.travel-mode-tab:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.03);
}

.travel-mode-tab.active {
    background: var(--text-primary);
    color: white;
    font-weight: 500;
}

.travel-mode-tab:disabled {
    cursor: not-allowed;
}

/* ── Category Toggles ── */
#category-toggles {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.category-toggle:hover {
    background: rgba(0, 0, 0, 0.03);
}

.category-toggle input[type="checkbox"] {
    display: none;
}

.category-indicator {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 2px solid var(--cat-color);
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
    position: relative;
}

.category-toggle input:checked + .category-indicator {
    background: var(--cat-color);
}

.category-toggle input:checked + .category-indicator::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 3px;
    width: 4px;
    height: 7px;
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.category-name {
    font-size: 13px;
    font-weight: 400;
    flex: 1;
}

.category-count {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    min-width: 20px;
    text-align: right;
}

/* ── Clear Button ── */
.clear-btn {
    background: none;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: rgba(0, 0, 0, 0.03);
    border-color: #ccc;
    color: var(--text-primary);
}

/* ── Loading Overlay ── */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(250, 250, 249, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.3s;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--panel-border);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Mapbox Popup Overrides ── */
.mapboxgl-popup-content {
    font-family: var(--font-body);
    border-radius: var(--radius-md) !important;
    padding: 0 !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06) !important;
    overflow: hidden;
}

.mapboxgl-popup-close-button {
    font-size: 18px;
    padding: 4px 8px;
    color: var(--text-secondary);
    right: 4px;
    top: 4px;
}

.mapboxgl-popup-close-button:hover {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

/* ── Tooltip (hover) ── */
.tooltip-content {
    padding: 10px 14px;
    max-width: 280px;
}

.tooltip-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.tooltip-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.category-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    color: white;
    line-height: 1.4;
}

.tooltip-location {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ── Detail Popup (click) ── */
.detail-content {
    padding: 16px;
    min-width: 220px;
    max-width: 300px;
}

.detail-name-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    margin-bottom: 6px;
    padding-right: 28px;
}

.detail-name {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
    margin-right: 2px;
}

.detail-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.detail-location {
    font-size: 12px;
    color: var(--text-secondary);
}

.detail-description {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.detail-recommended {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.detail-notes {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 10px;
}

.detail-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: #4A90E2;
    text-decoration: none;
    padding: 4px 0;
    transition: opacity 0.2s;
}

.detail-link:hover {
    opacity: 0.7;
}

/* ── Add Place Button ── */
.panel-header-right {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

#add-place-btn {
    width: 24px;
    height: 24px;
    background: none;
    border: 1px solid var(--panel-border);
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#add-place-btn:hover {
    border-color: #ccc;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.03);
}

/* ── Sign-out Button ── */
.sign-out-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: opacity 0.2s;
}

.sign-out-btn:hover {
    opacity: 0.7;
}

.sign-out-btn.hidden {
    display: none;
}

.sign-out-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--text-primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Add Place Overlay & Modal ── */
#add-place-overlay {
    position: fixed;
    inset: 0;
    background: rgba(250, 250, 249, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.3s;
}

#add-place-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#add-place-modal {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--panel-shadow);
    width: 440px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--panel-border) transparent;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

#modal-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

#modal-close-btn:hover {
    color: var(--text-primary);
}

/* ── Add Place Form ── */
#add-place-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.form-label .required {
    color: #E63946;
}

#add-place-form input[type="text"],
#add-place-form input[type="url"],
#add-place-form textarea,
#add-place-form select {
    appearance: none;
    -webkit-appearance: none;
    background: white;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-primary);
    transition: border-color 0.2s;
}

#add-place-form input[type="text"]:focus,
#add-place-form input[type="url"]:focus,
#add-place-form textarea:focus,
#add-place-form select:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.15);
}

#add-place-form select {
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%236B6966' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center;
    padding-right: 28px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.form-divider {
    border: none;
    border-top: 1px solid var(--panel-border);
    margin: 4px 0;
}

.url-status {
    font-size: 12px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
}

.url-status.success {
    color: #2D9F5F;
    background: rgba(45, 159, 95, 0.08);
}

.url-status.error {
    color: #E63946;
    background: rgba(230, 57, 70, 0.08);
}

.url-status.loading {
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.03);
}

.url-status.hidden {
    display: none;
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 4px;
}

.btn-cancel {
    background: none;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: rgba(0, 0, 0, 0.03);
    border-color: #ccc;
    color: var(--text-primary);
}

.btn-export {
    background: none;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    margin-right: auto;
}

.btn-export:hover {
    background: rgba(0, 0, 0, 0.03);
    border-color: #ccc;
    color: var(--text-primary);
}

.btn-submit {
    background: var(--text-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-submit:hover {
    opacity: 0.85;
}

.btn-submit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Detail Actions (Edit + Delete) ── */
.detail-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.edit-place-btn {
    background: none;
    border: 1px solid #4A90E2;
    color: #4A90E2;
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.edit-place-btn:hover {
    background: #4A90E2;
    color: white;
}

.delete-place-btn {
    background: none;
    border: 1px solid #E63946;
    color: #E63946;
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.delete-place-btn:hover {
    background: #E63946;
    color: white;
}

/* ── User Presence ── */
.user-presence {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    min-height: 0;
}

.user-presence:empty {
    display: none;
}

.presence-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--text-primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}

/* ── Likes Filter ── */
.likes-filter-radios {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.likes-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
    font-size: 13px;
}

.likes-radio:hover {
    background: rgba(0, 0, 0, 0.03);
}

.likes-radio input[type="radio"] {
    accent-color: var(--text-primary);
    margin: 0;
}

/* ── Heart Button (inline with name) ── */
.like-heart-btn {
    width: 24px;
    height: 24px;
    min-width: 24px;
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, transform 0.15s;
    margin: 0;
    padding: 0;
    vertical-align: middle;
}

.like-heart-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

.like-heart-btn .heart-icon {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: var(--text-secondary);
    stroke-width: 1.5;
    transition: fill 0.15s, stroke 0.15s;
}

.like-heart-btn.liked .heart-icon {
    fill: #E63946;
    stroke: #E63946;
}

.like-heart-btn.heart-animate {
    animation: heart-pop 0.3s ease;
}

@keyframes heart-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ── Like Avatars (inline with name) ── */
.like-avatars {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    margin: 0 0 0 -2px;
    min-height: 0;
}

.like-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    color: white;
    font-size: 9px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: -4px;
    border: 1.5px solid white;
    cursor: default;
    position: relative;
}

.like-avatar:last-child {
    margin-right: 0;
}

/* ── Display Name Modal ── */
#display-name-overlay {
    position: fixed;
    inset: 0;
    background: rgba(250, 250, 249, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: opacity 0.3s;
}

#display-name-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.display-name-modal {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--panel-shadow);
    padding: 24px;
    width: 320px;
    max-width: calc(100vw - 32px);
}

.display-name-modal h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}

.display-name-modal input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.display-name-modal input:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.15);
}

.display-name-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── Session Expired Banner ── */
.session-expired {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #FEF3C7;
    border: 1px solid #F59E0B;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 13px;
    color: #92400E;
    z-index: 150;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.session-expired.hidden {
    display: none;
}

.session-expired a {
    color: #92400E;
    font-weight: 600;
}

/* ── Sign-in Prompt ── */
.signin-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px;
    border: 1px dashed var(--panel-border);
    border-radius: var(--radius-sm);
}

.signin-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--text-primary);
    color: white;
    text-decoration: none;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: opacity 0.2s;
}

.signin-btn:hover {
    opacity: 0.85;
}

.signin-hint {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Responsive ── */
@media (max-width: 480px) {
    #filter-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 45vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 16px;
    }

    #add-place-overlay {
        align-items: stretch;
    }

    #add-place-modal {
        width: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        height: 100%;
    }

    .form-row {
        flex-direction: column;
        gap: 14px;
    }
}
