/* =============================================================================
   /map (FlexLayout edition) — popup card, marker shadow, drawer polish.
   Ported from DashEcommerce/assets/css/map.css. Token names mapped onto
   SailsBoard's harbor / brass / tidal palette.
   ============================================================================= */

/* Map cursor + cluster */
.stylecursor {
    cursor: crosshair;
}

.marker-cluster {
    background: transparent !important;
    border: none !important;
}

.marker-cluster div {
    background: transparent !important;
}

/* Location marker icons - shadow + lift on hover */
.map-location-marker {
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4))
            drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s ease, filter 0.2s ease;
    border-radius: 8px;
}

.map-location-marker:hover {
    transform: scale(1.15);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5))
            drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4))
            drop-shadow(0 0 12px rgba(31, 125, 114, 0.4));
}

[data-mantine-color-scheme="dark"] .map-location-marker {
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6))
            drop-shadow(0 0 8px rgba(255, 255, 255, 0.15));
}

[data-mantine-color-scheme="dark"] .map-location-marker:hover {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.7))
            drop-shadow(0 0 16px rgba(31, 125, 114, 0.5));
}

/* Search panel cards */
.map-location-card {
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.map-location-card:hover {
    transform: translateX(2px);
    background: var(--mantine-color-default-hover);
}


/* =============================================================================
   POPUP CARD — content-first, harbor-tinged. Two variants share the
   skeleton: an 80px hero image strip when the row carries a real image,
   a brass-monospace eyebrow band otherwise. Colours come from Mantine
   CSS vars so dark mode swaps without re-rendering.
   ============================================================================= */

.leaflet-popup.location-popup-wrapper .leaflet-popup-content-wrapper {
    background: transparent;
    box-shadow: none;
    padding: 0;
    border-radius: 12px;
}

.leaflet-popup.location-popup-wrapper .leaflet-popup-content {
    margin: 0;
    width: auto !important;
}

.leaflet-popup.location-popup-wrapper .leaflet-popup-tip-container {
    opacity: 0;
}

.location-popup-card {
    width: 260px;
    border-radius: 12px;
    overflow: hidden;
    font-family: var(--mantine-font-family, -apple-system, BlinkMacSystemFont,
                  'Segoe UI', Roboto, sans-serif);

    /* Liquid glass — translucent gradient lets the map peek through
       behind the card while the blur keeps the foreground crisp.
       Tuned subtler than the source's 20px/85% so text stays readable
       over busy harbour-tile backgrounds. */
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.78) 0%,
        rgba(255, 255, 255, 0.70) 100%
    );
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.55);

    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.18),
        0 2px 6px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.6);

    /* Animation owned by the inner card — NOT the .leaflet-popup
       wrapper. Leaflet sets ``transform: translate3d(...)`` on the
       wrapper for positioning, and an animated ``transform`` keyframe
       on that element overrides JS-set transforms (CSS animations
       trump inline styles), snapping popups to (0,0). */
    animation: popupCardIn 0.22s ease-out forwards;
    transform-origin: 50% 100%;
    will-change: opacity, transform;
}

[data-mantine-color-scheme="dark"] .location-popup-card {
    background: linear-gradient(
        135deg,
        rgba(20, 26, 35, 0.80) 0%,
        rgba(15, 19, 27, 0.72) 100%
    );
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.55),
        0 2px 6px rgba(0, 0, 0, 0.30),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.06);
}

@keyframes popupCardIn {
    from { opacity: 0; transform: translateY(4px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Eyebrow band (no image variant) ---------------------------- */

.popup-eyebrow-band {
    padding: 12px 14px 0;
    border-bottom: 1px dashed var(--mantine-color-default-border);
    margin-bottom: 12px;
}

.popup-eyebrow {
    display: inline-block;
    font-family: var(--mantine-font-family-monospace, ui-monospace, monospace);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--mantine-color-brass-7);
    text-transform: uppercase;
    padding-bottom: 8px;
}

[data-mantine-color-scheme="dark"] .popup-eyebrow {
    color: var(--mantine-color-brass-4);
}

/* --- Hero image variant ----------------------------------------- */

.popup-hero-image {
    position: relative;
    width: 100%;
    height: 80px;
    overflow: hidden;
    background: var(--mantine-color-default);
}

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

.popup-hero-image.hero-image-failed img {
    display: none;
}

.popup-hero-image.hero-image-failed::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg,
            var(--mantine-color-harbor-7) 0%,
            var(--mantine-color-tidal-6) 100%);
}

.popup-hero-eyebrow {
    position: absolute;
    left: 12px;
    bottom: 8px;
    font-family: var(--mantine-font-family-monospace, ui-monospace, monospace);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: white;
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.location-popup-card.has-image .popup-content {
    padding-top: 10px;
}

/* --- Content section -------------------------------------------- */

.popup-content {
    padding: 0 14px 14px;
}

.popup-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--mantine-color-text);
    margin: 0 0 4px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.popup-coords {
    font-family: var(--mantine-font-family-monospace, ui-monospace, monospace);
    font-size: 11px;
    color: var(--mantine-color-dimmed);
    margin-bottom: 8px;
}

.popup-description {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--mantine-color-dimmed);
    margin: 0 0 10px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

[data-mantine-color-scheme="dark"] .popup-description {
    color: var(--mantine-color-gray-4);
}

.popup-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 12px;
}

.popup-tag {
    font-size: 10.5px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--mantine-color-default-hover);
    color: var(--mantine-color-text);
    border: 1px solid var(--mantine-color-default-border);
}

[data-mantine-color-scheme="dark"] .popup-tag {
    background: var(--mantine-color-default);
}

/* --- Action row (View Details + Directions) --------------------- */

.popup-actions {
    display: flex;
    gap: 8px;
}

.popup-details-btn,
.popup-directions-btn {
    flex: 1;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.15s ease, box-shadow 0.15s ease,
                background 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
    border: 1px solid transparent;
    font-family: inherit;
}

.popup-details-btn {
    background: linear-gradient(
        135deg,
        var(--mantine-color-harbor-7) 0%,
        var(--mantine-color-tidal-6) 100%
    );
    color: white;
    box-shadow: 0 2px 6px rgba(19, 36, 63, 0.25);
}

.popup-details-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 9px rgba(31, 125, 114, 0.35);
}

.popup-details-btn:active {
    transform: translateY(0);
}

.popup-directions-btn {
    background: var(--mantine-color-default);
    color: var(--mantine-color-text);
    border-color: var(--mantine-color-default-border);
}

.popup-directions-btn:hover {
    background: var(--mantine-color-default-hover);
    border-color: var(--mantine-color-harbor-6);
}

.popup-details-btn svg,
.popup-directions-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

/* --- Close button (Leaflet) ------------------------------------- */

.leaflet-popup-close-button {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45) !important;
    color: white !important;
    border-radius: 50%;
    font-size: 16px;
    z-index: 10;
    transition: background 0.15s ease, transform 0.15s ease;
}

.leaflet-popup-close-button:hover {
    background: rgba(0, 0, 0, 0.65) !important;
    transform: scale(1.05);
}

/* --- Animation -------------------------------------------------- */
/*
 * NOTE: do NOT animate ``.leaflet-popup.location-popup-wrapper``.
 * Leaflet uses ``transform: translate3d(...)`` on that element for
 * popup positioning, and any CSS animation that mentions ``transform``
 * (even a no-op like ``transform: none``) wins over JS-set inline
 * styles, which snaps every popup to (0,0). The fade-in lives on
 * ``.location-popup-card`` instead.
 */

@media (prefers-reduced-motion: reduce) {
    .location-popup-card {
        animation: none !important;
    }
}

@media (max-width: 480px) {
    .location-popup-card {
        width: 240px;
    }
    .popup-name {
        font-size: 15px;
    }
    .popup-details-btn,
    .popup-directions-btn {
        padding: 7px 8px;
        font-size: 11.5px;
    }
}


/* =============================================================================
   DROP-A-PIN DRAWER — bottom-sheet on mobile with a liquid-glass treatment.
   Body composed in pages/map/_index/components/create_panel.py::create_pin_body.
   The same body also mounts inside a dfl tabset on desktop (see
   .create-panel-content below); the rules under .map-create-drawer-* are
   mobile-drawer-specific.
   ============================================================================= */

/* The Drawer "shell" Mantine wraps around the body. Rounded top
   corners read as "bottom sheet"; the soft shadow gives the floating
   surface depth over the map below. */
.map-create-drawer-content-shell {
    border-top-left-radius: 18px !important;
    border-top-right-radius: 18px !important;
    overflow: hidden;
    box-shadow:
        0 -8px 28px rgba(0, 0, 0, 0.22),
        0 -2px 8px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.6);
}

/* Liquid-glass body — translucent gradient + backdrop blur so the map
   peeks through, tuned slightly stronger than the popup card so the
   wizard's longer-lived chrome doesn't read as washed-out.

   ``overflow: hidden`` is load-bearing: the eyebrow band needs to
   stay pinned at the top while only the Stepper scrolls, so we move
   scrolling INTO the dmc.ScrollArea inside the body. Without
   overriding the inherited ``.location-drawer-body { overflow-y: auto }``
   (which the detail drawer needs), the eyebrow band would scroll
   along with the content. */
.map-create-drawer-body {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.86) 0%,
        rgba(255, 255, 255, 0.78) 100%
    ) !important;
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    border-top: 1px solid rgba(255, 255, 255, 0.55);
    overflow: hidden !important;
    height: 100%;
    display: flex;
    flex-direction: column;
}

[data-mantine-color-scheme="dark"] .map-create-drawer-body {
    background: linear-gradient(
        180deg,
        rgba(20, 26, 35, 0.84) 0%,
        rgba(15, 19, 27, 0.76) 100%
    ) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.10);
}

[data-mantine-color-scheme="dark"] .map-create-drawer-content-shell {
    box-shadow:
        0 -8px 28px rgba(0, 0, 0, 0.55),
        0 -2px 8px rgba(0, 0, 0, 0.30),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.06);
}

/* Soften the overlay so the map below is visibly there but not
   dominant. Mantine's default is rgba(0,0,0,0.6) which over-darkens
   the harbor-tile palette. */
.map-create-drawer-overlay {
    background-color: rgba(11, 23, 38, 0.32) !important;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* The wizard inner — eyebrow band on top + ScrollArea below. The flex
   column lets the eyebrow keep its natural height while the scroll
   area grows to fill the remaining space. */
.create-panel-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Pin the eyebrow band so it never scrolls with the form. ``flex: 0
   0 auto`` (the default for non-flex children) plus ``position:
   sticky; top: 0`` is belt-and-suspenders — sticky alone handles the
   case where overflow can't be contained for some reason (e.g. a
   browser quirk inside Mantine's Drawer transitions). */
.create-panel-inner > .detail-eyebrow-band {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-shrink: 0;
}

/* The dmc.ScrollArea wrapper. ``flex: 1`` and ``min-height: 0`` are
   the two lines that make a flex child actually shrink to fit its
   parent's leftover space — without ``min-height: 0`` the child
   defaults to ``min-content`` and overflows the parent. */
.create-panel-scroll {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
}

/* Padding lives on the inner viewport so scrollbar tracks render
   flush against the drawer edge. */
.create-panel-scroll .mantine-ScrollArea-viewport {
    padding: 16px 20px 24px;
}

/* Desktop dfl tab content host — fills the create-tabset pane. */
.create-panel-content {
    height: 100%;
    overflow: hidden;
    background-color: var(--mantine-color-body);
    display: flex;
    flex-direction: column;
}


/* =============================================================================
   ICON PICKER — Iconify-backed marker icon picker.
   Single ScrollArea with sticky category headers; fixed height keeps the
   modal proportions constant whether the user is browsing or searching.
   ============================================================================= */

.loc-icon-modal-body {
    /* Drop the modal's default padding-bottom so the ScrollArea
       hugs the modal edges and feels like a proper chunk of UI
       rather than a card floating in space. */
    padding-bottom: 8px !important;
}

.loc-icon-scroll {
    /* Keep the ScrollArea's contents flush against the left edge —
       padding goes inside the inner Div so the scrollbar track has
       its own column. */
    width: 100%;
    border-radius: var(--mantine-radius-sm);
    background-color: var(--mantine-color-body);
}

.loc-icon-scroll-inner {
    padding: 4px 8px 12px;
}

.loc-icon-category-header {
    /* Sticks to the top of the ScrollArea while a category is in
       view. ``position: sticky`` works inside ``dmc.ScrollArea``'s
       viewport because the viewport itself is the scrolling
       ancestor. The background fade hides icons scrolling behind
       the header. */
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 4px 6px;
    margin-top: 8px;
    background: linear-gradient(
        180deg,
        var(--mantine-color-body) 0%,
        var(--mantine-color-body) 75%,
        rgba(0, 0, 0, 0) 100%
    );
    color: var(--mantine-color-dimmed);
    border-bottom: 1px dashed var(--mantine-color-default-border);
}

.loc-icon-category-header:first-of-type {
    margin-top: 0;
}

[data-mantine-color-scheme="dark"] .loc-icon-category-header {
    background: linear-gradient(
        180deg,
        var(--mantine-color-body) 0%,
        var(--mantine-color-body) 75%,
        rgba(0, 0, 0, 0) 100%
    );
}

.loc-icon-grid {
    margin-top: 6px;
    margin-bottom: 4px;
}

.loc-iconify-result-btn:hover {
    background-color: var(--mantine-color-default-hover);
    transform: translateY(-1px);
}

.loc-iconify-result-btn:active {
    transform: translateY(0);
}


/* =============================================================================
   DETAIL DRAWER — eyebrow band, action shelf, eyebrow-led sections,
   mini-map. Composed in pages/map/index.py::_location_detail_drawer_content.
   ============================================================================= */

/* Drawer body wrapper — kill default Mantine padding so the eyebrow
   band can run flush to the corners. */
.location-drawer-body {
    padding: 0 !important;
    overflow-y: auto;
    overflow-x: hidden;
}

.location-drawer-content {
    width: 100%;
    min-height: 100%;
}

.location-drawer-inner {
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Empty placeholder, shown before any marker is selected. */
.location-drawer-empty {
    padding: 32px 24px;
}

/* --- Eyebrow band ----------------------------------------------- */

.detail-eyebrow-band {
    padding: 28px 24px 18px;
    background: linear-gradient(
        180deg,
        var(--mantine-color-default-hover) 0%,
        var(--mantine-color-body) 100%
    );
    border-bottom: 1px dashed var(--mantine-color-default-border);
}

.detail-eyebrow-text .detail-eyebrow {
    font-family: var(--mantine-font-family-monospace, ui-monospace, monospace);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    color: var(--mantine-color-brass-7);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.detail-eyebrow {
    font-family: var(--mantine-font-family-monospace, ui-monospace, monospace);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    color: var(--mantine-color-brass-7);
    text-transform: uppercase;
    margin-bottom: 6px;
}

[data-mantine-color-scheme="dark"] .detail-eyebrow {
    color: var(--mantine-color-brass-4);
}

/* Hero avatar inside the eyebrow band — keeps the type icon (or
   uploaded image when available) anchored to the left of the
   eyebrow / title / address column. */
.detail-eyebrow-band .mantine-Avatar-root {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

/* --- Action shelf ----------------------------------------------- */

.detail-action-shelf {
    padding: 14px 24px 12px;
    border-bottom: 1px solid var(--mantine-color-default-border);
    background: var(--mantine-color-body);
    position: sticky;
    top: 0;
    z-index: 2;
}

/* --- Sections --------------------------------------------------- */

.detail-sections {
    padding: 20px 24px 36px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.detail-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.detail-section-label {
    font-family: var(--mantine-font-family-monospace, ui-monospace, monospace);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--mantine-color-dimmed);
    /* Underline rule so each section reads as its own block without a
       full Divider eating vertical space. */
    padding-bottom: 6px;
    border-bottom: 1px solid var(--mantine-color-default-border);
}

.detail-section-body {
    /* Mantine Stacks render as block — no extra rule needed; this is
       just a hook for ad-hoc tweaking. */
    line-height: 1.5;
}

/* --- Mini-map --------------------------------------------------- */

.detail-mini-map {
    /* Explicit pixel height + position:relative — the Leaflet child
       needs a definite-sized positioned host to compute its tile grid
       correctly on first paint. ``min-height`` prevents collapse if
       a parent flex container tries to shrink us. */
    position: relative;
    height: 200px;
    min-height: 200px;
    width: 100%;
    border-radius: var(--mantine-radius-md);
    overflow: hidden;
    border: 1px solid var(--mantine-color-default-border);
    background: var(--mantine-color-default);
}

.detail-mini-map .leaflet-container,
.detail-mini-map > div {
    height: 100% !important;
    width: 100% !important;
    background: var(--mantine-color-default);
}

/* --- Mobile (bottom-sheet) -------------------------------------- */

@media (max-width: 768px) {
    .mantine-Drawer-root[data-position="bottom"] .mantine-Drawer-content {
        border-radius: var(--mantine-radius-lg) var(--mantine-radius-lg) 0 0;
        max-height: 88vh;
    }
    .detail-eyebrow-band {
        padding: 22px 18px 14px;
    }
    .detail-action-shelf {
        padding: 12px 18px;
    }
    .detail-sections {
        padding: 18px 18px 28px;
        gap: 18px;
    }
}


/* =============================================================================
   AI CHAT — markdown bubble polish
   ============================================================================= */

.ai-chat-markdown p {
    margin: 0 0 0.5em 0;
}

.ai-chat-markdown p:last-child {
    margin-bottom: 0;
}

.ai-chat-markdown ul,
.ai-chat-markdown ol {
    margin: 0.25em 0 0.5em 1.25em;
    padding: 0;
}

.ai-chat-markdown code {
    background: var(--mantine-color-default-hover);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 90%;
}

.ai-message-bubble {
    /* Carries the harbor accent strip from the inline border-left.
       Animation on render keeps the chat panel feeling alive without
       fighting the Mantine surface tones. */
    animation: chatBubbleIn 0.25s ease forwards;
}

@keyframes chatBubbleIn {
    0% { opacity: 0; transform: translateY(4px); }
    100% { opacity: 1; transform: none; }
}


/* =============================================================================
   FLEXLAYOUT polish — keep the splitter visible without dominating
   ============================================================================= */

.flexlayout__splitter {
    background: var(--mantine-color-default-border) !important;
    transition: background 0.15s ease;
}

.flexlayout__splitter:hover,
.flexlayout__splitter_drag {
    background: var(--mantine-color-harbor-6) !important;
}

.flexlayout__tab {
    background: var(--mantine-color-body) !important;
    color: var(--mantine-color-text) !important;
}

.flexlayout__tabset_tabbar_outer {
    background: var(--mantine-color-default) !important;
}

.flexlayout__tab_button--selected,
.flexlayout__tab_button:hover {
    background: var(--mantine-color-default-hover) !important;
}

.flexlayout__border_top,
.flexlayout__border_bottom,
.flexlayout__border_left,
.flexlayout__border_right {
    background: var(--mantine-color-default) !important;
    border-color: var(--mantine-color-default-border) !important;
}


/* =============================================================================
   DESKTOP DETAIL TAB — sibling of the map panel inside the FlexLayout.
   On mobile (<768px) the location detail opens in a dmc.Drawer instead;
   this surface only shows up on ≥md screens.
   ============================================================================= */

.detail-panel-content {
    height: 100%;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    /* Reuse the drawer's section styles below — same eyebrow band,
       same action shelf, same mini-map. The only thing that changes
       is the host. */
}

/* Hide the close button when the same content is rendered inside
   the FlexLayout tab — the tab bar has its own close affordance, and
   a duplicate ✕ at the top of the inner content reads as noise. */
.detail-panel-content .leaflet-popup-close-button {
    display: none;
}
