/* Mapa Interativo Waytify — estilos escopados ao mapa (não resetar o header Tailwind) */

body.mapa-page {
    overflow: hidden;
}

/* Header Waytify acima do mapa */
body.mapa-page > .waytify-nav { z-index: 1100; }

.map-shell,
.map-shell * {
    box-sizing: border-box;
}

.map-shell {
    display: flex;
    height: calc(100dvh - 4rem);
    margin-top: 4rem;
}

/* Sidebar */
.map-sidebar {
    width: 340px;
    min-width: 280px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    z-index: 400;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.25rem 1.25rem 0.75rem;
    margin: 0;
}

.sidebar-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.sidebar-header p {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 0.25rem;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 1.25rem;
    padding: 0.6rem 0.85rem;
    background: #f1f5f9;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    outline: none;
}

.search-box .material-symbols-outlined { font-size: 1.1rem; color: #94a3b8; }

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 1.25rem 0.5rem;
}

.filter-group.filter-sub { padding-bottom: 0.75rem; }

.filter-btn, .filter-btn-sm {
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.filter-btn-sm { font-size: 0.7rem; padding: 0.25rem 0.6rem; }

.filter-btn.active, .filter-btn-sm.active {
    background: #ff6933;
    border-color: #ff6933;
    color: #fff;
}

.map-stats {
    padding: 0 1.25rem 0.5rem;
    font-size: 0.72rem;
    color: #64748b;
}

.map-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    padding: 0 0.75rem;
    margin: 0;
}

.map-list li button {
    width: 100%;
    text-align: left;
    padding: 0.65rem 0.75rem;
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.map-list li button:hover { background: #f8fafc; }

.map-list strong { font-size: 0.82rem; color: #0f172a; }
.map-list small { font-size: 0.72rem; color: #94a3b8; }

.badge-live {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    color: #e11d48;
    text-transform: uppercase;
}

.sidebar-actions {
    padding: 0.75rem 1.25rem 1rem;
    border-top: 1px solid #e2e8f0;
}

.action-primary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem;
    background: #ff6933;
    color: #fff;
    border: none;
    border-radius: 0.65rem;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
}

.action-primary:disabled { opacity: 0.6; cursor: wait; }

/* Map area */
.map-main {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

.map-toolbar {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.map-toolbar button {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 0.65rem;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-toolbar button.active { background: #ff6933; color: #fff; }

.map-legend {
    position: absolute;
    bottom: 1.5rem;
    left: 1rem;
    z-index: 400;
    background: rgba(255,255,255,0.95);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.legend-item:last-child { margin-bottom: 0; }

.legend-passaporte {
    display: block;
    margin-top: 0.4rem;
    font-weight: 700;
    color: #ff6933;
    text-decoration: none;
    font-size: 0.72rem;
}

.legend-passaporte:hover { text-decoration: underline; }

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-ponto { background: #2563eb; }
.dot-roteiro { background: #ff6933; }
.dot-parceiro { background: #16a34a; }
.dot-live { background: #e11d48; animation: pulse 1.5s infinite; }

.offline-status {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    background: #fef3c7;
    color: #92400e;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.offline-status.hidden { display: none; }

.loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 600;
    background: rgba(248,246,245,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.loading-overlay.hidden { display: none; }

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #ff6933;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Markers */
.waytify-marker div {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    border: 2px solid #fff;
}

.waytify-marker .material-symbols-outlined { font-size: 18px; }

.marker-num {
    font-size: 0.85rem;
    font-weight: 800;
}

.marker-live div {
    animation: pulse-ring 2s infinite;
}

/* Popups */
.leaflet-popup-content-wrapper { border-radius: 0.75rem; }
.leaflet-popup-content { margin: 0.75rem 1rem; font-family: inherit; }

.popup-tag {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #ff6933;
}

.popup h3 {
    font-size: 0.95rem;
    margin: 0.25rem 0;
    color: #0f172a;
}

.popup p { font-size: 0.8rem; color: #475569; line-height: 1.4; }

.popup-meta { font-size: 0.72rem !important; color: #94a3b8 !important; }

.popup-live {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    color: #e11d48;
    margin: 0.25rem 0;
}

.popup-paradas {
    font-size: 0.75rem;
    color: #475569;
    margin: 0.5rem 0;
    line-height: 1.5;
}

.popup-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.65rem;
    flex-wrap: wrap;
}

.popup-link {
    font-size: 0.72rem;
    font-weight: 600;
    color: #fff;
    background: #ff6933;
    padding: 0.35rem 0.65rem;
    border-radius: 0.4rem;
    text-decoration: none;
}

.popup-link.secondary {
    background: #f1f5f9;
    color: #475569;
}

.popup-checkin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.45rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    background: #16a34a;
    border: none;
    border-radius: 0.4rem;
    cursor: pointer;
    font-family: inherit;
}

.popup-checkin.checkin-done { background: #64748b; cursor: default; }
.popup-checkin .material-symbols-outlined { font-size: 1rem; }

/* Fullscreen */
body.mapa-fullscreen .map-sidebar { display: none; }
body.mapa-fullscreen .map-shell { margin-top: 0; height: 100dvh; }
body.mapa-fullscreen > .waytify-nav { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(225,29,72,0.5); }
    70% { box-shadow: 0 0 0 10px rgba(225,29,72,0); }
    100% { box-shadow: 0 0 0 0 rgba(225,29,72,0); }
}

@media (max-width: 768px) {
    .map-shell { flex-direction: column; }
    .map-sidebar {
        width: 100%;
        max-height: 38vh;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    .map-main { flex: 1; min-height: 55vh; }
    .map-legend { display: none; }
}
