/**
 * map_sidebar.css — shared widget-style map sidebar for web_app map pages.
 * Mirrors the sidebar + list/detail styles from widget_app/css/map.css
 * (the authoritative source). Class names match the widget so markup can
 * be copied between the two. Load AFTER leaflet-sidebar-v2's CSS.
 * Do NOT load on widget_app pages — they use map.css directly.
 */

/* ── Frame (widget: .leaflet-sidebar rules) ─────────────────────────── */

.leaflet-sidebar {
    width: 100%;
    max-width: 350px;
    background: #fff;
    border-radius: 8px;
    font-family: var(--font-primary, sans-serif);
    overflow: hidden;
    z-index: 1000;
}

.leaflet-sidebar-left.leaflet-touch {
    border: 2px solid #E9F2EE !important;
}

.leaflet-sidebar-tabs {
    display: none !important;
}

/* Fix: the plugin forces pane min-width 305/390/420px at wider
   breakpoints — content then overflows the 350px sidebar. */
.leaflet-sidebar-pane {
    min-width: 0 !important;
    width: 100% !important;
    padding: 0 !important;
    box-sizing: border-box;
}

.leaflet-sidebar-content {
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: auto !important;
    padding: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.leaflet-sidebar-pane.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* ── Header (widget: .leaflet-sidebar-header) ───────────────────────── */

.leaflet-sidebar-header,
h1.leaflet-sidebar-header {
    width: 100%;
    min-height: 44px;
    padding: 0.25rem 38px 0.5rem 14px;
    background: #f3f3f3;
    position: relative;
    font-size: 1rem;
    font-weight: 400;
    color: #333;
    margin: 0;
    line-height: 1.2;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    flex-shrink: 0;
}

.sidebar-back-link {
    cursor: pointer;
    color: #229966;
    font-weight: 500;
}
.sidebar-back-link:hover { text-decoration: underline; }

/* ── Close button (widget: .sidebar-close-button) ───────────────────── */

.sidebar-close-button {
    position: absolute;
    top: 11px;
    right: 10px;
    z-index: 1010;
    background: #fff;
    color: #333;
    border-radius: 50%;
    border: 2px solid #E9F2EE;
    font-size: 1rem;
    width: 22px;
    height: 22px;
    font-weight: 400;
    line-height: 1;
    padding: 0 0 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.sidebar-close-button:hover {
    background: #e9ecef;
    color: #495057;
    border-color: #adb5bd;
}

/* ── Scrollable content ─────────────────────────────────────────────── */

.sidebar-scrollable-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    background: #fff;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}
.sidebar-scrollable-content::-webkit-scrollbar { width: 4px; }
.sidebar-scrollable-content::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

.sidebar-inner-content {
    padding: 20px;
    font-size: 1rem;
    box-sizing: border-box;
}

/* ── List view (widget: .poi-items / .poi-item) ─────────────────────── */

.poi-items {
    flex: 1;
    overflow-y: auto;
    background: #fff;
    border-radius: 8px;
}

.poi-item {
    display: flex;
    align-items: center;
    padding: 0;
    margin-bottom: 8px;
    background-color: #f3f3f3;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
    min-height: 80px;
}

.poi-item:hover {
    background-color: #e9ecef;
}

.poi-item:last-child {
    margin-bottom: 0;
}

.poi-item-preview {
    width: 80px;
    height: 80px;
    border-radius: 4px;
    object-fit: cover;
    margin-right: 15px;
    flex-shrink: 0;
    display: block;
}

.poi-item-preview--empty {
    width: 80px;
    height: 80px;
    border-radius: 4px;
    margin-right: 15px;
    flex-shrink: 0;
    background: #d1d5db;
}

.poi-list-item-image-container {
    position: relative;
}

.poi-item-icon {
    width: 18px;
    height: 18px;
    position: absolute;
    right: 8px;
    top: 17px;
    align-items: center;
    justify-content: center;
}

.poi-item-icon img {
    object-fit: contain;
}

.poi-item-content {
    flex: 1;
    min-width: 0;
    margin-right: 8px;
}

.poi-item-content h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 4px 0;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.poi-item-category {
    font-size: 0.875rem;
    color: #666;
    margin: 0 0 4px 0;
    font-weight: 500;
}

/* ── Detail view (widget: route/poi sidebar content) ────────────────── */

.poi-image {
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
}

.poi-image img {
    width: 100%;
    display: block;
    object-fit: cover;
}

.poi-header {
    margin-bottom: 20px;
}

.poi-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.poi-category-badge {
    font-size: 0.875rem;
    color: #666;
    font-weight: 500;
    margin: 0;
}

.poi-description {
    margin-bottom: 20px;
    line-height: 1.55;
    color: #444;
    overflow-wrap: break-word;
}

/* Descriptions arrive as sanitized HTML (h3/p/br …) */
.poi-description p {
    margin: 0 0 0.75em;
}

.poi-description h3,
.poi-description h4 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #333;
    margin: 1em 0 0.4em;
}

.poi-description > *:first-child { margin-top: 0; }
.poi-description > *:last-child { margin-bottom: 0; }

/* ── Actions / buttons (widget: .btn, .btn-green-outline) ───────────── */

.poi-actions,
.route-actions {
    margin-top: 24px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: stretch;
}

.route-actions > .btn,
.route-actions > a.btn,
.poi-actions > .btn {
    flex: 1 1 auto;
    min-width: 120px;
    text-align: center;
    justify-content: center;
    white-space: nowrap;
}

.btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-green-outline {
    background: #fff;
    border: 1px solid #229966;
    color: #229966 !important;
}

.btn-green-outline:hover {
    background: #E9F2EE;
    text-decoration: none;
}

/* ── Route/POI list toggle buttons (widget: L.Control.POIRouteToggles) ─ */

.leaflet-control-poi-route-toggles {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.leaflet-control-poi-button,
.leaflet-control-route-button {
    width: 40px;
    height: 40px;
    background: white;
    border: 2px solid #E9F2EE !important;
    border-radius: 20px;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 0 8px 0;
    padding: 0;
}

.leaflet-control-poi-button:hover,
.leaflet-control-route-button:hover,
.leaflet-control-poi-button.active,
.leaflet-control-route-button.active {
    background-color: #f3f3f3;
    border-color: rgba(0, 0, 0, 0.4) !important;
}

/* ── Mobile ─────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
    .leaflet-sidebar {
        max-width: calc(100vw - 56px);
    }
}
