/* Peru Local Advisor - Map & Route Styles */

#map-section {
    padding: 1.5rem;
    overflow: hidden;
}

#map-section h2 {
    margin-top: 0;
    color: var(--primary-color);
}

/* ---------- Route summary bar ---------- */
#route-summary {
    background: #f4f7f6;
    border: 1px solid #e2e6e4;
    border-radius: 8px;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1rem;
}

.route-breadcrumb {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    line-height: 1.6;
    word-break: break-word;
}

.route-arrow-sep {
    color: var(--accent-color);
    font-weight: normal;
    margin: 0 0.15rem;
}

.route-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.route-stat {
    display: flex;
    flex-direction: column;
    background: var(--white);
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    border: 1px solid #e2e6e4;
    text-align: center;
}

.route-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-color);
}

.route-stat-label {
    font-size: 0.75rem;
    color: #667;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 0.15rem;
}

/* ---------- Map + fixed info panel layout ---------- */
#map-layout {
    display: flex;
    align-items: stretch;
    gap: 1rem;
}

/* ---------- Map container ---------- */
#map {
    flex: 1 1 62%;
    /* flex-shrink can otherwise collapse this box below its intended pixel
       height on narrow/mobile layouts (a flex item's automatic min-height
       is its content size, and a freshly-created Leaflet map can briefly
       report no intrinsic content size), which is part of what made the
       map appear "missing" on mobile even though `height` below was set.
       Pinning flex-shrink to 0 and mirroring `height` in min-height makes
       the box always take its full intended size regardless of flex math. */
    flex-shrink: 0;
    min-width: 0;
    height: 480px;
    min-height: 480px;
    width: 100%;
    border-radius: 8px;
    border: 1px solid #ddd;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    background-color: #e9e9e9;
}

/* ---------- Custom numbered markers ---------- */
/* Teardrop shape via a 45deg-rotated square; the digit lives in an inner
   <span> that gets counter-rotated -45deg so it reads upright. */
.route-marker {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(45deg);
    background: var(--accent-color, #e67e22);
    border: 2px solid var(--white);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: transform 0.15s ease, background 0.15s ease;
}

.route-marker span {
    display: block;
    transform: rotate(-45deg);
    color: var(--white);
    font-weight: 700;
    font-size: 0.85rem;
}

.route-marker-active {
    background: #c0392b;
    transform: rotate(45deg) scale(1.25);
    z-index: 1000 !important;
}

.leaflet-div-icon {
    background: transparent;
    border: none;
}

/* ---------- Directional arrows along the route ---------- */
.route-arrow {
    color: var(--accent-color, #e67e22);
    font-size: 1rem;
    font-weight: bold;
    text-shadow: 0 0 3px rgba(255,255,255,0.9), 0 0 3px rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* ---------- Fixed information panel (replaces Leaflet popups) ---------- */
/* This panel never moves the map and is never clipped by the map's
   viewport — it's a normal block element laid out beside the map, sized
   and positioned entirely by this stylesheet rather than by Leaflet. */
.map-info-panel {
    flex: 1 1 38%;
    min-width: 240px;
    max-width: 340px;
    background: var(--white);
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 1rem 1.1rem;
    /* Scrolls internally only if its own content overflows — the map
       itself never scrolls or resizes because of this panel. */
    overflow-y: auto;
    max-height: 480px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.map-info-placeholder {
    margin: 0;
    color: #667;
    font-size: 0.9rem;
    font-style: italic;
}

.map-info-day {
    display: inline-block;
    background: #fff6ee;
    color: var(--accent-color, #e67e22);
    border-radius: 4px;
    padding: 0.15rem 0.6rem;
    font-weight: 600;
    font-size: 0.8rem;
    margin: 0 0 0.5rem 0;
}

.map-info-dest {
    margin: 0 0 0.6rem 0;
    color: var(--primary-color, #2c3e50);
    font-size: 1.15rem;
    line-height: 1.3;
}

.map-info-field {
    margin: 0 0 0.5rem 0;
    font-size: 0.88rem;
    line-height: 1.4;
    word-break: break-word;
}

.map-info-activities {
    margin: 0 0 0.5rem 0;
}

.map-info-activities ul {
    margin: 0.2rem 0 0 0;
    padding-left: 1.4rem;
}

.map-info-activities li {
    font-size: 0.88rem;
    line-height: 1.4;
    margin-bottom: 0.15rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    #map { height: 400px; min-height: 400px; }
    .map-info-panel { max-height: 400px; }
}

@media (max-width: 768px) {
    #map-section { padding: 1rem; }
    /* Below tablet width the map and info panel stack vertically instead
       of sitting side by side — the panel appears below the map, but it
       is still the same fixed, non-popup element, never a Leaflet popup. */
    #map-layout { flex-direction: column; }
    #map { height: 320px; min-height: 320px; }
    .map-info-panel { max-width: none; max-height: 260px; }
    .route-stats { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
    .route-breadcrumb { font-size: 0.85rem; }
}

@media (max-width: 480px) {
    #map { height: 260px; min-height: 260px; }
    .map-info-panel { max-height: 220px; }
    .route-stats { grid-template-columns: repeat(2, 1fr); }
}
