/* ═══════════════════════════════════════════════════════
   RAG Race Tracker — Styles
   ═══════════════════════════════════════════════════════ */

.rrt-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 100%;
    margin: 1.5em 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0,0,0,.08);
    overflow: hidden;
}

/* ─── Header ────────────────────────────────────────── */
.rrt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
}
.rrt-title {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
    letter-spacing: .02em;
}
.rrt-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .85em;
}
.rrt-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.rrt-dot--loading { background: #f59e0b; animation: rrt-pulse 1.2s infinite; }
.rrt-dot--ok      { background: #22c55e; animation: rrt-pulse 2s infinite; }
.rrt-dot--error   { background: #ef4444; }
.rrt-dot--stale   { background: #f59e0b; }

@keyframes rrt-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

/* ─── Map ───────────────────────────────────────────── */
.rrt-map-container {
    width: 100% !important;
    min-height: 400px !important;
    display: block !important;
    z-index: 1;
    position: relative;
}

/* ─── Dashboard ─────────────────────────────────────── */
.rrt-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0;
    border-top: 1px solid #e5e7eb;
}
.rrt-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border-right: 1px solid #e5e7eb;
}
.rrt-stat:last-child {
    border-right: none;
}
.rrt-stat__label {
    font-size: .7em;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6b7280;
    margin-bottom: 2px;
}
.rrt-stat__value {
    font-size: 1.2em;
    font-weight: 700;
    color: #1a1a2e;
    font-variant-numeric: tabular-nums;
}

/* ─── Legend ─────────────────────────────────────────── */
.rrt-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 10px 20px;
    font-size: .8em;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}
.rrt-legend__item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.rrt-legend__line {
    width: 20px;
    height: 3px;
    border-radius: 2px;
}
.rrt-legend__line--done    { background: #22c55e; }
.rrt-legend__line--planned { background: #f97316; border-top: 2px dashed #f97316; height: 0; }
.rrt-legend__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.rrt-legend__dot--pause { background: #f59e0b; border: 2px solid #d97706; }
.rrt-legend__dot--rider { background: #ef4444; border: 2px solid #fff; box-shadow: 0 0 0 2px #ef4444; }

/* ─── Leaflet custom badges ─────────────────────────── */
.rrt-speed-badge {
    background: rgba(26, 26, 46, .9);
    color: #fff;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-variant-numeric: tabular-nums;
}
.rrt-speed-badge__icon {
    font-size: 11px;
}
.rrt-speed-badge--avg {
    background: rgba(37, 99, 235, .9);
}

/* ─── Pulse marker for current position ──────────── */
.rrt-rider-marker {
    width: 20px;
    height: 20px;
    position: relative;
}
.rrt-rider-marker__dot {
    width: 14px;
    height: 14px;
    background: #ef4444;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 2px #ef4444, 0 2px 8px rgba(0,0,0,.3);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.rrt-rider-marker__pulse {
    width: 40px;
    height: 40px;
    border: 2px solid rgba(239, 68, 68, .5);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: rrt-rider-pulse 2s ease-out infinite;
}
@keyframes rrt-rider-pulse {
    0% { transform: translate(-50%, -50%) scale(.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* ─── Pause popup ───────────────────────────────────── */
.rrt-pause-popup {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    text-align: center;
}
.rrt-pause-popup strong {
    display: block;
    font-size: 1.1em;
    margin-bottom: 2px;
}
.rrt-pause-popup small {
    color: #6b7280;
}

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 600px) {
    .rrt-dashboard {
        grid-template-columns: repeat(3, 1fr);
    }
    .rrt-stat {
        padding: 8px 4px;
    }
    .rrt-stat__value {
        font-size: 1em;
    }
    .rrt-header {
        padding: 10px 14px;
    }
    .rrt-title {
        font-size: .95em;
    }
}

/* ─── Leaflet tile fix (WordPress themes often break tiles) ─── */
.rrt-map-container img {
    max-width: none !important;
    max-height: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
}
.rrt-map-container .leaflet-tile-container {
    pointer-events: none;
}
.rrt-map-container .leaflet-control-zoom a {
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
}
