/* ============================
   MAP PAGE STYLES
   Lotus Inmobiliaria
   ============================ */

/* --- Variables --- */
:root {
    --map-sidebar-w: 420px;
    --map-header-h: 72px;
    --map-teal: #263e5d;
    --map-teal-light: #ffd088;
    --map-green: #16A34A;
    --map-amber: #D97706;
    --map-red: #DC2626;
    --map-text: #1E293B;
    --map-text-muted: #64748B;
    --map-border: #E2E8F0;
    --map-bg: #FFFFFF;
    --map-bg-alt: #F8FAFC;
}

/* --- Full-viewport map body --- */
body.map-body {
    overflow: hidden;
    height: 100vh;
}

/* --- Layout --- */
.map-layout {
    display: flex;
    flex-direction: row;
    height: calc(100vh - var(--map-header-h));
    margin-top: var(--map-header-h);
    position: relative;
}

/* ============================
   SIDEBAR
   ============================ */
.map-sidebar {
    width: var(--map-sidebar-w);
    min-width: var(--map-sidebar-w);
    max-width: var(--map-sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--map-bg);
    border-right: 1px solid var(--map-border);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10;
}

/* --- Sidebar hero image --- */
.sidebar-hero {
    position: relative;
    width: 100%;
    min-height: 300px;
    background-size: cover;
    background-position: center;
}

.sidebar-hero__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.15) 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px;
}

.sidebar-hero__title {
    font-family: 'Playfair Display', serif;
    font-size: 1.35rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.25;
    margin: 0;
}

.sidebar-hero__location {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.85);
    margin-top: 4px;
}

.sidebar-hero__location i {
    margin-right: 4px;
}

/* --- Stats strip --- */
.sidebar-stats {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--map-border);
}

.sidebar-stats__item {
    flex: 1;
    text-align: center;
    padding: 12px 6px;
    border-right: 1px solid var(--map-border);
}

.sidebar-stats__item:last-child {
    border-right: none;
}

.sidebar-stats__item--highlight .sidebar-stats__value {
    color: var(--map-green);
}

.sidebar-stats__value {
    display: block;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--map-text);
    line-height: 1.2;
}

.sidebar-stats__value--sm {
    font-size: 0.85rem;
    font-weight: 600;
}

.sidebar-stats__label {
    display: block;
    font-size: 0.68rem;
    color: var(--map-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 2px;
}

/* --- Leaflet zoom controls --- */
/* Push zoom controls below the fixed header */
.leaflet-top.leaflet-left {
    top: 80px !important;
    left: 14px !important;
}

.leaflet-control-zoom {
    border: none !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15) !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 18px !important;
    color: var(--map-teal) !important;
    background: #fff !important;
    border-bottom: 1px solid #eee !important;
}

.leaflet-control-zoom a:hover {
    background: #f5f5f5 !important;
}

/* --- Filters --- */
.sidebar-filters {
    padding: 14px 16px;
    border-bottom: 1px solid var(--map-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--map-bg-alt);
}

.filter-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--map-border);
    border-radius: 6px;
    font-size: 0.82rem;
    font-family: inherit;
    color: var(--map-text);
    background: #fff;
    transition: border-color 0.2s;
}

.filter-input:focus {
    outline: none;
    border-color: var(--map-teal-light);
    box-shadow: 0 0 0 2px rgba(20,184,166,0.15);
}

.filter-input::placeholder {
    color: #94A3B8;
}

.filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-input--half {
    flex: 1;
    min-width: 0;
}

/* --- Status pills --- */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid var(--map-border);
    background: #fff;
    font-size: 0.75rem;
    font-family: inherit;
    color: var(--map-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    opacity: 0.5;
}

.status-pill.active {
    opacity: 1;
}

.status-pill--disponible.active {
    border-color: var(--map-green);
    color: var(--map-green);
    background: rgba(22,163,74,0.07);
}

.status-pill--reservado.active {
    border-color: var(--map-amber);
    color: var(--map-amber);
    background: rgba(217,119,6,0.07);
}

.status-pill--vendido.active {
    border-color: var(--map-red);
    color: var(--map-red);
    background: rgba(220,38,38,0.07);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-pill--disponible .status-dot { background: var(--map-green); }
.status-pill--reservado .status-dot  { background: var(--map-amber); }
.status-pill--vendido .status-dot    { background: var(--map-red); }

/* --- Checkbox filter --- */
.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--map-text-muted);
    cursor: pointer;
}

.filter-checkbox input[type="checkbox"] {
    accent-color: var(--map-teal);
    width: 16px;
    height: 16px;
}

/* --- Lot count --- */
.sidebar-lot-count {
    padding: 10px 16px;
    font-size: 0.75rem;
    color: var(--map-text-muted);
    border-bottom: 1px solid var(--map-border);
    flex-shrink: 0;
    background: var(--map-bg);
}

/* --- Lot list --- */
.sidebar-lot-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px 12px;
}

/* --- Lot card --- */
.lot-card-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid var(--map-border);
    border-left: 4px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    background: #fff;
}

.lot-card-item:hover {
    background: var(--map-bg-alt);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.lot-card-item--disponible { border-left-color: var(--map-green); }
.lot-card-item--reservado  { border-left-color: var(--map-amber); }
.lot-card-item--vendido    { border-left-color: var(--map-red); }

.lot-card-item.is-selected {
    background: rgba(15,118,110,0.06);
    border-left-color: var(--map-teal) !important;
    box-shadow: 0 0 0 2px rgba(38,62,93,0.15);
}

.lot-card-item__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
    margin-right: 4px;
}

.lot-card-item__dot--disponible { background: var(--map-green); }
.lot-card-item__dot--reservado  { background: var(--map-amber); }
.lot-card-item__dot--vendido    { background: var(--map-red); }

.lot-card-item__body {
    flex: 1;
    min-width: 0;
}

.lot-card-item__name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--map-text);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lot-card-item__meta {
    font-size: 0.7rem;
    color: var(--map-text-muted);
    margin-top: 1px;
}

.lot-card-item__price {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--map-teal);
    margin-top: 3px;
}


/* ============================
   MAP CONTAINER
   ============================ */
.map-container {
    flex: 1;
    min-width: 0;
    position: relative;
}

/* Force Leaflet to fill */
#map {
    width: 100%;
    height: 100%;
}

/* ============================
   MAP LEGEND
   ============================ */
.map-legend {
    position: absolute;
    bottom: 100px;
    right: 16px;
    z-index: 500;
    background: rgba(255,255,255,0.94);
    border-radius: 8px;
    padding: 8px 14px;
    display: flex;
    gap: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    font-size: 0.73rem;
    color: var(--map-text-muted);
}

.map-legend__item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.map-legend__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.map-legend__dot--disponible { background: var(--map-green); }
.map-legend__dot--reservado  { background: var(--map-amber); }
.map-legend__dot--vendido    { background: var(--map-red); }


/* ============================
   LEAFLET POPUP CUSTOM
   ============================ */
.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    padding: 0 !important;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18) !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    min-width: 260px;
    max-width: 300px;
}

.leaflet-popup-tip {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12) !important;
}

/* --- Custom popup card --- */
.lot-popup {
    font-family: 'Inter', sans-serif;
}

.lot-popup__header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--map-border);
}

.lot-popup__badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}

.lot-popup__badge--disponible { background: rgba(22,163,74,0.12); color: var(--map-green); }
.lot-popup__badge--reservado  { background: rgba(217,119,6,0.12); color: var(--map-amber); }
.lot-popup__badge--vendido    { background: rgba(220,38,38,0.12); color: var(--map-red); }

.lot-popup__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--map-text);
    margin: 0;
    line-height: 1.25;
}

.lot-popup__fraccion {
    font-size: 0.75rem;
    color: var(--map-text-muted);
    margin-top: 2px;
}

.lot-popup__body {
    padding: 10px 16px 14px;
}

.lot-popup__info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
    margin-bottom: 12px;
}

.lot-popup__info-item {
    font-size: 0.75rem;
}

.lot-popup__info-label {
    color: var(--map-text-muted);
    display: block;
    font-size: 0.67rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.lot-popup__info-value {
    color: var(--map-text);
    font-weight: 600;
}

.lot-popup__actions {
    display: flex;
    gap: 8px;
}

.lot-popup__btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
    line-height: 1.2;
}

.lot-popup__btn:hover {
    opacity: 0.85;
}

.lot-popup__btn--whatsapp {
    background: #25D366;
    color: #fff;
}

.lot-popup__btn--detail {
    background: var(--map-teal);
    color: #fff;
}


/* ============================
   MOBILE TOGGLE BUTTON
   ============================ */
.mobile-map-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 600;
    padding: 12px 24px;
    border-radius: 28px;
    border: none;
    background: var(--map-teal);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    box-shadow: 0 4px 16px rgba(15,118,110,0.35);
    cursor: pointer;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.mobile-map-toggle i {
    font-size: 1rem;
}


/* ============================
   RESPONSIVE
   ============================ */

/* Tablet */
@media (max-width: 1024px) {
    :root {
        --map-sidebar-w: 340px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    body.map-body {
        overflow-y: auto;
        height: auto;
    }

    .map-layout {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - var(--map-header-h));
    }

    .map-sidebar {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        height: auto;
        overflow-y: visible;
        position: relative;
        z-index: 20;
        transition: none;
    }

    .map-sidebar.is-hidden {
        display: none;
    }

    .map-container {
        width: 100%;
        height: 60vh;
        min-height: 350px;
        position: relative;
    }

    .map-container.is-fullscreen {
        position: fixed;
        inset: 0;
        height: 100vh;
        z-index: 30;
        margin-top: var(--map-header-h);
    }

    .mobile-map-toggle {
        display: flex;
    }

    .map-legend {
        bottom: 72px;
        right: 8px;
        font-size: 0.68rem;
        gap: 10px;
        padding: 6px 10px;
    }

    .sidebar-hero {
        height: 180px;
    }
}
