/* advteams PWA Styles - Mobile-optimized for handlebar mounting */

/* PWA Bottom Navigation */
.pwa-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--panel);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    padding-bottom: env(safe-area-inset-bottom, 8px);
    z-index: 9000;
}

.pwa-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.75rem;
    border-radius: 8px;
    transition: all 0.2s;
    min-width: 64px;
}

.pwa-nav-item:hover,
.pwa-nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent);
}

.pwa-nav-icon {
    font-size: 1.5rem;
}

/* Large touch targets for glove use */
.touch-target {
    min-height: 56px;
    min-width: 56px;
}

.btn.touch {
    min-height: 56px;
    font-size: 1.1rem;
    padding: 16px 24px;
}

/* Floating action button */
.fab {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    z-index: 8000;
    transition: all 0.2s;
}

.fab:hover {
    transform: scale(1.1);
    background: var(--accent-light);
}

.fab.camera {
    bottom: 180px;
}

/* Active ride overlay */
.ride-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 7000;
    display: flex;
    flex-direction: column;
}

.ride-map-container {
    flex: 1;
    position: relative;
}

.ride-info-panel {
    background: var(--panel);
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.ride-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.ride-info-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.ride-info-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    text-align: center;
}

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

.ride-stat-label {
    font-size: 0.8rem;
    color: var(--muted);
}

/* Notification toast for riding */
.ride-notification {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    background: var(--accent);
    color: #fff;
    padding: 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9500;
    transform: translateY(-150%);
    transition: transform 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.ride-notification.visible {
    transform: translateY(0);
}

.ride-notification.critical {
    background: var(--danger);
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.ride-notification-icon {
    font-size: 2rem;
}

.ride-notification-content {
    flex: 1;
}

.ride-notification-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.ride-notification-message {
    font-size: 0.9rem;
    opacity: 0.9;
}

.ride-notification-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
}

/* Camera capture UI */
.camera-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 10000;
    display: none;
}

.camera-overlay.active {
    display: flex;
    flex-direction: column;
}

.camera-preview {
    flex: 1;
    object-fit: cover;
}

.camera-controls {
    background: rgba(0, 0, 0, 0.8);
    padding: 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.camera-capture-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #fff;
    border: 4px solid var(--accent);
    cursor: pointer;
    transition: transform 0.1s;
}

.camera-capture-btn:active {
    transform: scale(0.95);
}

.camera-close-btn,
.camera-switch-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Check-in QR display */
.qr-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 40px;
}

.qr-fullscreen .qr-code {
    width: 70vmin;
    height: 70vmin;
    max-width: 400px;
    max-height: 400px;
}

.qr-fullscreen .qr-rider-name {
    color: #000;
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 24px;
    text-align: center;
}

.qr-fullscreen .qr-instructions {
    color: #666;
    font-size: 1rem;
    margin-top: 12px;
    text-align: center;
}

.qr-fullscreen .qr-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #000;
    color: #fff;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
}

.qr-fullscreen .qr-ride-title {
    color: #000;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
    opacity: 0.7;
}

.qr-fullscreen .qr-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.qr-fullscreen .qr-actions .btn {
    min-width: 120px;
}

/* Print styles for QR code */
@media print {
    body * {
        visibility: hidden;
    }

    .qr-fullscreen,
    .qr-fullscreen * {
        visibility: visible;
    }

    .qr-fullscreen {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: auto;
        background: #fff;
        padding: 20px;
    }

    .qr-fullscreen .no-print {
        display: none !important;
    }

    .qr-fullscreen .qr-code {
        width: 60mm;
        height: 60mm;
    }
}

/* Rider location marker */
.rider-marker {
    position: relative;
}

.rider-marker-dot {
    width: 16px;
    height: 16px;
    background: var(--accent);
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.rider-marker-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.4;
    animation: marker-pulse 2s infinite;
}

@keyframes marker-pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0.4;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Rider heading arrow for follow mode */
.rider-heading-arrow {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    color: var(--accent);
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
    transition: transform 0.1s ease-out;
}

/* Follow mode button states */
.map-toolbar-btn.follow-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    animation: follow-pulse 2s infinite;
}

@keyframes follow-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.6);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(249, 115, 22, 0);
    }
}

/* Checkpoint marker */
.checkpoint-marker {
    width: 32px;
    height: 32px;
    background: var(--panel);
    border: 2px solid var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.checkpoint-marker.start {
    border-color: var(--green);
}

.checkpoint-marker.end {
    border-color: var(--red);
}

.checkpoint-marker.lunch {
    border-color: var(--orange);
}

.checkpoint-marker.checked {
    background: var(--green);
    border-color: var(--green);
    color: #000;
}

/* Pull to refresh indicator */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--panel);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-100%);
    transition: transform 0.2s;
}

.pull-to-refresh.visible {
    transform: translateY(0);
}

/* Swipe actions */
.swipe-action {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.swipe-action-left {
    left: 0;
    background: var(--danger);
}

.swipe-action-right {
    right: 0;
    background: var(--success);
}

/* Install prompt */
.install-prompt {
    position: fixed;
    bottom: 80px;
    left: 20px;
    right: 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 8500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.install-prompt-icon {
    font-size: 2.5rem;
}

.install-prompt-content {
    flex: 1;
}

.install-prompt-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.install-prompt-text {
    font-size: 0.9rem;
    color: var(--muted);
}

.install-prompt-buttons {
    display: flex;
    gap: 8px;
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--warning);
    color: #000;
    padding: 8px;
    text-align: center;
    font-weight: 600;
    z-index: 9999;
    display: none;
}

.offline-indicator.visible {
    display: block;
}

/* Touch-friendly list items */
.touch-list-item {
    padding: 16px;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.touch-list-item:active {
    background: rgba(255, 255, 255, 0.05);
}

/* Safe area handling */
.safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

.safe-area-top {
    padding-top: env(safe-area-inset-top, 20px);
}

/* Haptic feedback visual indicator */
.haptic-trigger:active {
    transform: scale(0.98);
}

/* Hide scrollbars on mobile */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        display: none;
    }

    body {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    /* Larger text for outdoor visibility */
    .ride-stat-value {
        font-size: 2rem;
    }

    /* Extra padding for bottom nav */
    .pwa-page {
        padding-bottom: 80px;
    }
}

/* ==========================================
   Map Control Toolbar
   ========================================== */

.map-toolbar {
    position: absolute;
    top: 60px;
    right: 12px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-toolbar-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: rgba(15, 18, 22, 0.9);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.map-toolbar-btn:hover {
    background: rgba(30, 35, 42, 0.95);
    border-color: var(--accent);
}

.map-toolbar-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.map-toolbar-btn.wake-active {
    animation: wake-pulse 2s infinite;
}

@keyframes wake-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(249, 115, 22, 0);
    }
}

/* ==========================================
   High Contrast Mode
   ========================================== */

.high-contrast-mode {
    filter: saturate(1.4) contrast(1.2);
}

.high-contrast-mode .leaflet-tile-container {
    filter: saturate(0.8) contrast(1.3);
}

/* High contrast checkpoint markers */
.checkpoint-marker.high-contrast {
    transform: scale(1.5);
    border-width: 3px;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8), 0 4px 12px rgba(0, 0, 0, 0.5);
}

.high-contrast-mode .checkpoint-marker {
    transform: scale(1.5);
    border-width: 3px;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8), 0 4px 12px rgba(0, 0, 0, 0.5);
    font-size: 1.4rem;
}

.high-contrast-mode .rider-marker-dot {
    width: 24px;
    height: 24px;
    border-width: 4px;
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.4), 0 4px 12px rgba(0, 0, 0, 0.5);
}

.high-contrast-mode .leaflet-popup-content-wrapper {
    background: #000;
    border: 2px solid #fff;
    font-size: 1.1rem;
    font-weight: 600;
}

/* ==========================================
   Fullscreen Mode
   ========================================== */

#map:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
}

#map:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
}

#map:-webkit-full-screen .map-toolbar {
    top: 20px;
    right: 20px;
}

#map:fullscreen .map-toolbar {
    top: 20px;
    right: 20px;
}

/* Wake Lock Status Indicator */
.wake-lock-indicator {
    position: fixed;
    top: 12px;
    left: 12px;
    background: rgba(34, 197, 94, 0.9);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 1000;
    display: none;
    backdrop-filter: blur(10px);
}

.wake-lock-indicator.visible {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wake-lock-indicator::before {
    content: '☀';
}