/* ═══ Picos: mapa ═══
   Página /spots/map (templates/spots/map_free.html + static/js/surfmap.js).
   Arquivo próprio para não colidir com a reorganização do style.css (T05);
   o orquestrador decide se funde no style.css. Só tokens (CSS vars) — sem hex. */

/* ── Layout ─────────────────────────────────────────────── */
.sm-card {
    border: 0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.sm-card > .card-header {
    background: var(--surface);
    border: 0;
}

.sm-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.sm-subtitle {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.sm-section-label {
    font-size: .85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary);
    margin: 1.5rem 0 1rem;
}

.sm-field-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: .25rem;
}

.sm-select,
.sm-search {
    font-size: .9rem;
    color: var(--text-secondary);
    background-color: var(--brand-faint);
    border-color: transparent;
}

.sm-select:focus,
.sm-search:focus {
    border-color: var(--brand-light);
    box-shadow: var(--ring-focus);
}

.sm-link-btn {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0;
}

.sm-link-btn:hover,
.sm-link-btn:focus-visible {
    color: var(--text-primary);
}

.sm-divider {
    border-color: var(--border);
    opacity: 1;
}

.sm-scroll {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 5px;
}

@media (min-width: 1200px) {
    .sm-layout {
        height: calc(100vh - 80px);
        overflow: hidden;
    }

    .sm-sidebar {
        height: calc(100vh - 80px);
        overflow-y: auto;
        padding-right: 5px;
        scrollbar-width: thin;
    }

    .sm-sidebar::-webkit-scrollbar {
        width: 6px;
    }

    .sm-sidebar::-webkit-scrollbar-thumb {
        background-color: var(--border);
        border-radius: 10px;
    }
}

/* Mobile: cards da lateral mais compactos, sobra espaço ao mapa */
@media (max-width: 767.98px) {
    .sm-sidebar .sm-card > .card-body {
        padding: 1rem;
    }

    .sm-sidebar .sm-card > .card-header {
        padding-top: 1rem;
    }

    .sm-layout {
        row-gap: 1rem;
    }
}

/* ── Mapa ───────────────────────────────────────────────── */
#map {
    position: relative;
    width: 100%;
    height: 60vh;              /* Mobile: deixa espaço para rolar a página */
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    z-index: 1;
}

@media (min-width: 768px) and (max-width: 1199.98px) {
    #map { height: 70vh; }
}

/* Popups e controles na fonte do site (o Leaflet força Helvetica) */
#map.leaflet-container {
    font-family: inherit;
}

/* Desktop: o mapa ocupa a altura útil da coluna (flex) */
@media (min-width: 1200px) {
    #map {
        height: auto;
        flex: 1 1 auto;
        min-height: 420px;
    }
}

/* Aviso "use dois dedos" (gesture handling no touch) */
.sm-gesture-hint {
    position: absolute;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-align: center;
    font-weight: 700;
    color: var(--surface);
    background: rgba(17, 24, 39, .55);
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
}

.sm-gesture-hint.is-visible {
    opacity: 1;
}

.map-instructions {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin-bottom: 10px;
    font-size: .85rem;
}

/* ── Botão "Adicionar pico" ─────────────────────────────── */
/* T17: visual de .btn-primary (escuro, raio --radius-btn, sem gradiente nem "pulo").
   O JS (surfmap.js) só alterna .add-mode-active e o texto; nada mudou nele. */
#addModeBtn { min-height: 44px; }

/* Estado "Cancelar" (modo adicionar ativo): vira o botão secundário (borda) */
#addModeBtn.add-mode-active {
    --bs-btn-color: var(--text-primary);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--border-hover);
    --bs-btn-hover-color: var(--text-primary);
    --bs-btn-hover-bg: var(--brand-faint);
    --bs-btn-hover-border-color: var(--border-hover);
    --bs-btn-active-color: var(--text-primary);
    --bs-btn-active-bg: var(--brand-faint);
    background: var(--surface);
    border: 1px solid var(--border-hover);
    color: var(--text-primary);
}

#addModeBtn.add-mode-active:hover { background: var(--brand-faint); }

/* ── Painel de confirmação abaixo do mapa ───────────────── */
#spotConfirmBar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    padding: 14px 16px;
    margin-top: 12px;
    animation: smConfirmUp .25s ease;
}

.sm-confirm-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sm-confirm-text {
    font-size: .78rem;
    color: var(--text-secondary);
}

@keyframes smConfirmUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* No modo "adicionar pico", os marcadores existentes não capturam o toque:
   o clique sempre chega ao mapa (mesmo perto de outros picos). */
#map.adding-spot .spot-board-marker {
    pointer-events: none;
}

/* ── Marcadores ─────────────────────────────────────────── */
.leaflet-marker-icon.spot-board-marker {
    background: transparent;
    border: none;
    color: var(--brand);
}

.spot-board-marker svg {
    display: block;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35));
}

.spot-board-marker .sm-board {
    fill: currentColor;
    stroke: var(--surface);
}

.spot-board-marker .sm-board-line {
    stroke: var(--surface);
}

.leaflet-marker-icon.sm-user-marker {
    background: var(--text-primary);
    border: 2px solid var(--surface);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .3);
}

/* ── Popup do Leaflet no design system ──────────────────── */
.leaflet-popup.spot-popup .leaflet-popup-content-wrapper {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border);
}

.leaflet-popup.spot-popup .leaflet-popup-content {
    margin: 0;
    width: 250px;
    max-width: calc(100vw - 48px);
    line-height: 1.5;
}

.leaflet-container .spot-popup a.leaflet-popup-close-button {
    color: var(--surface);
    right: 6px;
    top: 6px;
    font-size: 22px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .5);
    z-index: 2;
}

.spot-pop .cover {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.spot-pop .cover-fallback {
    height: 70px;
    background: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--surface);
    font-size: 1.6rem;
}

.spot-pop .body {
    padding: 12px 14px 14px;
}

.spot-pop .title {
    font-weight: 800;
    font-size: 1.02rem;
    color: var(--text-primary);
    letter-spacing: -.3px;
    margin: 0;
}

.spot-pop .loc {
    font-size: .78rem;
    color: var(--text-secondary);
    margin: 2px 0 10px;
}

.spot-pop .fc {
    display: flex;
    gap: 14px;
    justify-content: center;
    align-items: center;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--brand-faint);
    border-radius: var(--radius-sm);
    padding: 7px 8px;
    margin-bottom: 10px;
}

.spot-pop .fc .bi-water { color: var(--text-primary); }

.spot-pop .tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.spot-pop .tag {
    font-size: .66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--brand-faint);
    color: var(--text-primary);
}

.spot-pop .btn-detail {
    display: block;
    text-align: center;
    background: var(--text-primary);
    color: var(--surface);
    font-weight: 700;
    font-size: .82rem;
    padding: 9px;
    border-radius: 10px;
    text-decoration: none;
}

.spot-pop .btn-detail:hover,
.spot-pop .btn-detail:focus-visible {
    background: var(--brand-hover);
    color: var(--surface);
}

/* ── Listas da lateral (busca, mais ativos, próximos) ───── */
.sm-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    padding: .5rem;
    margin-bottom: .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    text-align: left;
}

.sm-item-main {
    min-width: 0;
}

.sm-item-name {
    display: block;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.sm-item-name:hover {
    color: var(--brand);
}

.sm-item-meta {
    display: block;
    font-size: .8rem;
    color: var(--text-secondary);
}

.sm-item-tags {
    display: flex;
    gap: .25rem;
    flex-wrap: wrap;
    margin-top: .25rem;
}

.sm-item .btn {
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
}

.sm-empty {
    font-size: .85rem;
    color: var(--text-secondary);
    margin: 0;
}

.sm-nearby {
    max-height: 400px;
    overflow-y: auto;
    background: var(--surface);
    color: var(--text-primary);
}

.sm-nearby-text {
    font-size: .85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.sm-nearby .btn-primary {
    border-radius: 10px;
    padding: 10px;
}

/* ── Modal de cadastro ──────────────────────────────────── */
/* O <form> envolve header/body/footer: precisa participar do layout flex
   para o corpo rolar (modal-dialog-scrollable só vale para filhos diretos). */
#addSpotModal .modal-content > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

#addSpotModal .modal-body {
    overflow-y: auto;
    min-height: 0;
}

.sm-coords {
    font-size: .82rem;
}

.sm-hint {
    font-size: .78rem;
}

.sm-collapse-btn {
    font-size: .9rem;
}

/* ── Modal de sucesso ───────────────────────────────────── */
#spotSuccessModal .modal-content {
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

#spotSuccessModal .sm-success-title {
    color: var(--text-primary);
}

#spotSuccessModal .sm-success-text {
    font-size: .92rem;
    line-height: 1.5;
}

.sm-success-check {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(var(--bs-success-rgb), .12);
    color: var(--bs-success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.6rem;
    animation: smCheckPop .35s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes smCheckPop {
    0%   { transform: scale(.5); opacity: 0; }
    100% { transform: scale(1);  opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    #spotConfirmBar,
    .sm-success-check { animation: none; }
}
