/* ==========================================================================
   Main map page (Default.aspx): layout, floating tools, side panels, ArcGIS popup content.
   ========================================================================== */
.app-shell { display: grid; grid-template-rows: auto 1fr; height: 100dvh; }

.map-area { position: relative; overflow: hidden; min-height: 0; }
.map-canvas { position: absolute; inset: 0; background: #dfe5ea; }

/* ----- tool bar (left column on desktop, scrolling row at the bottom on phones) */
.map-toolbar {
    position: absolute; z-index: 10; top: 12px; left: 12px;
    display: flex; flex-direction: column; gap: 6px; padding: 6px;
    background: rgba(255, 255, 255, .96); border-radius: 14px; box-shadow: var(--shadow);
    max-height: calc(100% - 24px); overflow-y: auto;
}
.tool-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    width: 58px; min-height: 54px; padding: 4px; border: 1px solid transparent; border-radius: 10px;
    background: none; font: inherit; font-size: .68rem; color: var(--ink); cursor: pointer;
}
.tool-btn img { width: 24px; height: 24px; object-fit: contain; }
.tool-btn:hover { background: #f1f2f5; }
.tool-btn.active { background: var(--brand-tint); border-color: var(--brand); color: var(--brand-dark); font-weight: 700; }
.map-basemap { position: absolute; z-index: 10; top: 12px; right: 12px; }
.map-basemap select { width: auto; min-height: 40px; padding: .3rem .6rem; box-shadow: var(--shadow); }

.map-zoom { position: absolute; z-index: 10; right: 12px; bottom: 44px; display: flex; flex-direction: column; box-shadow: var(--shadow); border-radius: 10px; overflow: hidden; }
.map-zoom button { width: 44px; height: 44px; border: 0; background: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; }
.map-zoom button + button { border-top: 1px solid var(--line); }
.map-zoom button:hover { background: #f1f2f5; }

.map-status {
    position: absolute; z-index: 5; bottom: 0; right: 0; display: flex; gap: .8rem; padding: 2px 8px;
    background: rgba(255, 255, 255, .8); font-size: .72rem; color: #333; pointer-events: none;
}

.map-loading, .map-chip, .toast {
    position: absolute; z-index: 30; left: 50%; transform: translateX(-50%); padding: .45rem .9rem;
    border-radius: 999px; background: rgba(31, 36, 48, .92); color: #fff; box-shadow: var(--shadow); font-size: .85rem; max-width: 92%;
}
.map-loading { top: 12px; display: flex; align-items: center; gap: .5rem; }
.map-chip { bottom: 40px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; text-align: center; }
.toast { top: 60px; background: #7b1f1f; border-radius: 12px; }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- side panels (legend on the left, my points on the right) */
.side-panel {
    position: absolute; z-index: 20; top: 0; bottom: 0; width: 340px; max-width: 100%;
    display: flex; flex-direction: column; background: var(--card); box-shadow: var(--shadow);
    visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s;
}
.side-panel.left { left: 0; transform: translateX(-102%); }
.side-panel.right { right: 0; transform: translateX(102%); }
.side-panel.open { visibility: visible; transform: none; transition: transform .22s ease; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: .6rem .8rem; border-bottom: 1px solid var(--line); background: #fafafb; }
.side-panel .panel-body { flex: 1; }

/* ----- phones: tools become a scrolling bar at the bottom, panels become bottom sheets */
@media (max-width: 720px) {
    .map-toolbar {
        top: auto; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
        flex-direction: row; overflow-x: auto; overflow-y: visible; max-height: none; scrollbar-width: none;
    }
    .tool-btn { flex: none; width: 54px; }
    .map-zoom { bottom: 96px; }
    .map-status { display: none; }
    .map-chip { bottom: 84px; }
    .side-panel, .side-panel.left, .side-panel.right {
        top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 68dvh;
        border-radius: 16px 16px 0 0; transform: translateY(102%); padding-bottom: env(safe-area-inset-bottom);
    }
    .side-panel.open { transform: none; }
}

/* ----- ArcGIS popup content (templates come from wwwroot/config/popups.*.json) */
/* Popup width: 328px (change here). */
.esri-popup__main-container, .esri-popup .esri-popup__main-container { width: 328px !important; max-width: calc(100vw - 24px); }

.site-popup { --pk-bg: color-mix(in srgb, var(--brand) 11%, #fff); --pk-ink: var(--brand-dark); font-size: 13px; width: 100%; box-sizing: border-box; }
.site-popup table { width: 100%; border-collapse: separate; border-spacing: 0 2px; }
.site-popup td { padding: 3px 8px; vertical-align: top; overflow-wrap: anywhere; }
.site-popup .infoTitle {
    font-weight: 700; font-size: 14px; color: #fff; background: var(--brand); border-radius: 6px; padding: 5px 10px; margin-bottom: 2px;
}
/* Key column (first cell of each row, including the un-classed header table) and value column */
.site-popup tr:not(:first-child) > td:first-child:not(:only-child), .site-popup .iL {
    width: 38%; white-space: normal; font-weight: 600; color: var(--pk-ink); background: var(--pk-bg); border-radius: 5px 0 0 5px;
}
.site-popup td:last-child:not(:only-child), .site-popup .iR { white-space: normal; color: #1f2937; background: #f8f9fb; border-radius: 0 5px 5px 0; }
.site-popup .iP { font-weight: 700; color: var(--brand-dark); }
/* The scrolling details box: inline styles in the templates, hence !important */
.site-popup div[style*="overflow"] {
    /* The templates wrap the detail rows in a fixed-height scroll box; show them in full, right below the other rows. */
    height: auto !important; max-height: none !important; overflow: visible !important; white-space: normal !important;
    border: 0 !important; padding: 0; margin: 2px 0 0 !important; max-width: 100%;
}
/* Link-only rows (Printable Site Information, Request More Information, Property Management Link): plain, no background */
.site-popup td:only-child:not(.infoTitle) { background: none; font-weight: 400; padding: 3px 2px; }
.site-popup a { color: var(--brand-dark); text-decoration: none; border-bottom: 1px dotted currentColor; }

/* ----- small maps on server-rendered pages */
.site-map { position: relative; width: 100%; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #dfe5ea; }
.map-error { padding: 1rem; color: var(--danger); }
.competitor-page { max-width: 1000px; margin: 0 auto; padding: 1rem; }
.competitor-map { position: relative; margin-bottom: 1rem; }
.map-overlay-check { position: absolute; z-index: 5; top: 8px; right: 8px; display: flex; gap: .4rem; align-items: center; padding: .3rem .6rem; background: #fffbd1; border: 1px solid #333; border-radius: 6px; font-size: .85rem; }

/* Drawn by js/core/map-chrome.js */
.map-attribution {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; padding: 2px 8px; font-size: .68rem; line-height: 1.3;
    color: #333; background: rgba(255, 255, 255, .75); pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.map-zoom-simple { position: absolute; top: 12px; left: 12px; z-index: 5; display: flex; flex-direction: column; gap: 1px; }
.map-zoom-simple button {
    width: 36px; height: 36px; border: 0; background: #fff; color: #333; font-size: 1.3rem; cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.map-zoom-simple button:first-child { border-radius: 6px 6px 0 0; }
.map-zoom-simple button:last-child { border-radius: 0 0 6px 6px; }

/* Full-map loading screen (removed by home.js once the layers have drawn) */
.map-splash {
    position: absolute; inset: 0; z-index: 30; display: grid; place-items: center;
    background: rgba(245, 246, 250, .92); backdrop-filter: blur(2px); transition: opacity .35s ease;
}
.map-splash.is-hidden { opacity: 0; pointer-events: none; }
.map-splash-card { display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center; color: var(--ink); }
.map-splash-card small { color: var(--muted); }
.spinner-lg {
    width: 44px; height: 44px; border: 4px solid var(--brand-tint); border-top-color: var(--brand); border-radius: 50%;
    animation: spin .8s linear infinite;
}

.result-list button + button { border-top: 1px solid var(--line); }
.result-list button:hover { background: var(--brand-tint); }
.result-list.flush { margin: 0; }

/* Highlight on the My Points tool (new feature): warm gold fill, strong outline and a gentle pulsing glow until it is opened */
.tool-btn { position: relative; }
.tool-btn.tool-new {
    border: 2px solid #e09a00; background: linear-gradient(#fff4cf, #ffdf85); color: #5b3b00; font-weight: 700;
    animation: new-glow 1.8s ease-in-out infinite;
}
.tool-btn.tool-new:hover { background: linear-gradient(#fff8e0, #ffd966); }
@keyframes new-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(224, 154, 0, .6); }
    50% { box-shadow: 0 0 0 8px rgba(224, 154, 0, 0); }
}
@media (prefers-reduced-motion: reduce) { .tool-btn.tool-new { animation: none; box-shadow: 0 0 0 3px rgba(224, 154, 0, .45); } }
