/**
 * CrewMap custom styles
 * M3E/Blueprint aesthetic for crew location markers
 *
 * @author CrewTrack Team
 * @since WEB-008
 */

/* ==========================================================================
   Crew Markers - Status-based circular markers with initials
   ========================================================================== */

.crew-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.crew-marker:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.crew-marker__initials {
    font-size: 14px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    user-select: none;
}

/* On Site - Green (active, at job location) */
.crew-marker--on-site {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    border-color: #15803d;
}

/* In Transit - Amber (moving between locations) */
.crew-marker--in-transit {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: #b45309;
}

/* Tracking - Cyan (sending locations but not clocked in) */
.crew-marker--tracking {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    border-color: #0e7490;
}

/* Offline - Gray (no recent location, not clocked in) */
.crew-marker--offline {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    border-color: #374151;
}

/* Unknown - Red (stale location data, potential issue) */
.crew-marker--unknown {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-color: #b91c1c;
}

/* Pulsing animation for active/on-site markers */
.crew-marker--on-site::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #22c55e;
    animation: marker-pulse 2s ease-out infinite;
}

@keyframes marker-pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* ==========================================================================
   Popup Styles
   ========================================================================== */

.crew-popup {
    font-family: system-ui, -apple-system, sans-serif;
    padding: 4px;
    min-width: 150px;
}

.crew-popup__name {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.crew-popup__status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
}

.crew-popup__status--on-site {
    background-color: #dcfce7;
    color: #166534;
}

.crew-popup__status--in-transit {
    background-color: #fef3c7;
    color: #92400e;
}

.crew-popup__status--tracking {
    background-color: #cffafe;
    color: #0e7490;
}

.crew-popup__status--offline {
    background-color: #f3f4f6;
    color: #4b5563;
}

.crew-popup__status--unknown {
    background-color: #fee2e2;
    color: #991b1b;
}

.crew-popup__job-site {
    font-size: 13px;
    color: #475569;
    margin-bottom: 4px;
}

.crew-popup__job-site::before {
    content: '\F3C5'; /* Bootstrap Icons bi-geo-alt */
    font-family: 'bootstrap-icons';
    margin-right: 4px;
    color: #64748b;
}

.crew-popup__update {
    font-size: 11px;
    color: #94a3b8;
}

/* ==========================================================================
   Map Container
   ========================================================================== */

.crew-map-container {
    width: 100%;
    height: 100%;
    min-height: 400px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Override Leaflet default styles for blueprint aesthetic */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-tip {
    box-shadow: none;
}

/* Geofence circle tooltip */
.leaflet-tooltip {
    background: rgba(26, 54, 93, 0.9);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
}

.leaflet-tooltip-left::before,
.leaflet-tooltip-right::before,
.leaflet-tooltip-top::before,
.leaflet-tooltip-bottom::before {
    border-color: transparent;
}

/* ==========================================================================
   Connection Status Bar
   ========================================================================== */

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}

.connection-status--connected {
    background-color: #dcfce7;
    color: #166534;
}

.connection-status--connecting,
.connection-status--reconnecting {
    background-color: #fef3c7;
    color: #92400e;
}

.connection-status--disconnected,
.connection-status--polling {
    background-color: #fee2e2;
    color: #991b1b;
}

.connection-status__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
}

.connection-status--connecting .connection-status__dot,
.connection-status--reconnecting .connection-status__dot {
    animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* ==========================================================================
   Movement Trail Styles
   ========================================================================== */

/* Trail polyline (styled via Leaflet options, this is for reference) */
.crew-trail {
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Trail waypoint markers */
.trail-marker {
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.trail-marker--start {
    background-color: #22c55e; /* Green - start of day */
    width: 12px !important;
    height: 12px !important;
}

.trail-marker--end {
    background-color: #0891b2; /* Cyan - current/end position */
    width: 12px !important;
    height: 12px !important;
}

.trail-marker--waypoint {
    background-color: #94a3b8; /* Gray - intermediate points */
    width: 8px !important;
    height: 8px !important;
    opacity: 0.8;
}

/* Trail time tooltips */
.trail-tooltip {
    background: rgba(15, 23, 42, 0.9) !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    white-space: nowrap;
}

.trail-tooltip::before {
    border-top-color: rgba(15, 23, 42, 0.9) !important;
}

/* Trail info banner (shown when viewing a trail) */
.trail-info-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
    color: white;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}

.trail-info-banner__text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trail-info-banner__close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 4px;
    padding: 4px 12px;
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.trail-info-banner__close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.trail-info-banner__controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.trail-date-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
}

.trail-date-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
}

.trail-date-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.trail-date-input {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 2px 8px;
    color: white;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    color-scheme: dark;
}

.trail-date-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

.trail-time-input {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 2px 6px;
    color: white;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    color-scheme: dark;
    width: 100px;
}

.trail-time-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

.trail-time-separator {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    margin: 0 4px;
}

.trail-time-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    margin: 0 2px;
}

/* ==========================================================================
   Playback Marker (MAP-005) - Animated pulsing dot for trail replay
   ========================================================================== */

.playback-marker {
    background: none !important;
    border: none !important;
}

.playback-marker__dot {
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e11d48;
    border: 3px solid white;
    box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
    animation: playback-pulse 1.5s ease-in-out infinite;
}

@keyframes playback-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(225, 29, 72, 0), 0 2px 6px rgba(0, 0, 0, 0.3); }
}

.playback-tooltip {
    background: #1e293b;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.playback-tooltip::before {
    border-top-color: #1e293b;
}
