/**
 * Trip Tracker - Frontend Styles
 */

/* Container */
.trip-tracker-container {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    position: relative;
}

/* Fullscreen mode */
.trip-tracker-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    z-index: 9999;
}

.trip-tracker-fullscreen .trip-tracker-map {
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
}

/* Statistics overlay (inside map) */
.trip-tracker-stats-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
    max-width: calc(100% - 120px);
}

.trip-tracker-stats-overlay .stat-item {
    font-size: 13px;
    color: #495057;
    white-space: nowrap;
}

.trip-tracker-stats-overlay .stat-item strong {
    color: #212529;
}

/* Close button for fullscreen */
.trip-tracker-fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #495057;
    transition: background 0.2s, color 0.2s;
}

.trip-tracker-fullscreen-close:hover {
    background: #fff;
    color: #212529;
}

/* Responsive overlay */
@media (max-width: 600px) {
    .trip-tracker-stats-overlay {
        top: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
        padding: 10px 12px;
        gap: 8px;
    }

    .trip-tracker-stats-overlay .stat-item {
        font-size: 12px;
    }

    .trip-tracker-fullscreen-close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
    }
}

/* Legacy stats bar (for non-fullscreen) */
.trip-tracker-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    border: 1px solid #e9ecef;
    border-bottom: none;
}

.trip-tracker-stats .stat-item {
    font-size: 14px;
    color: #495057;
}

.trip-tracker-stats .stat-item strong {
    color: #212529;
}

.trip-status-live {
    color: #28a745 !important;
    font-weight: bold;
}

.live-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    margin-right: 5px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Map container */
.trip-tracker-map {
    width: 100%;
    min-height: 400px;
    border-radius: 0 0 8px 8px;
    border: 1px solid #e9ecef;
    overflow: hidden;
}

.trip-tracker-container:not(:has(.trip-tracker-stats)) .trip-tracker-map {
    border-radius: 8px;
}

/* Legend for all trips map */
.trip-tracker-legend {
    background: #fff;
    padding: 15px;
    border: 1px solid #e9ecef;
    border-radius: 8px 8px 0 0;
    border-bottom: none;
}

.trip-tracker-legend h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #212529;
}

.trip-tracker-legend ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.trip-tracker-legend li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.trip-tracker-legend .legend-color {
    width: 20px;
    height: 4px;
    border-radius: 2px;
}

.trip-tracker-legend a {
    color: #495057;
    text-decoration: none;
}

.trip-tracker-legend a:hover {
    color: #007bff;
}

.live-badge {
    display: inline-block;
    padding: 2px 6px;
    background: #28a745;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    border-radius: 3px;
    text-transform: uppercase;
}

/* Trip list */
.trip-tracker-list {
    display: grid;
    gap: 20px;
}

.trip-list-item {
    display: flex;
    gap: 20px;
    padding: 20px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    transition: box-shadow 0.2s;
}

.trip-list-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.trip-list-item .trip-thumbnail {
    flex-shrink: 0;
    width: 150px;
    height: 100px;
    overflow: hidden;
    border-radius: 6px;
}

.trip-list-item .trip-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.trip-list-item .trip-info {
    flex: 1;
}

.trip-list-item h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
}

.trip-list-item h3 a {
    color: #212529;
    text-decoration: none;
}

.trip-list-item h3 a:hover {
    color: #007bff;
}

.trip-list-item .trip-date {
    margin: 0 0 5px 0;
    font-size: 13px;
    color: #6c757d;
}

.trip-list-item .trip-stats {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #495057;
}

.trip-list-item .trip-excerpt {
    margin: 0;
    font-size: 14px;
    color: #6c757d;
    line-height: 1.5;
}

/* Photo polaroid style */
.trip-photo-polaroid {
    background: #fff;
    padding: 10px 10px 30px 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    transform: rotate(-2deg);
    max-width: 200px;
}

.trip-photo-polaroid img {
    width: 100%;
    height: auto;
    display: block;
}

.trip-photo-polaroid .photo-caption {
    margin-top: 10px;
    font-size: 12px;
    color: #333;
    text-align: center;
    font-family: 'Comic Sans MS', cursive, sans-serif;
}

.trip-photo-polaroid .photo-date {
    font-size: 10px;
    color: #999;
    text-align: center;
    margin-top: 4px;
}

/* Mapbox popup customization */
.mapboxgl-popup-content {
    padding: 0 !important;
    border-radius: 4px;
    overflow: hidden;
}

.mapboxgl-popup-content .trip-photo-polaroid {
    transform: none;
    box-shadow: none;
}

/* Notice styling */
.trip-tracker-notice {
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    text-align: center;
    color: #6c757d;
}

/* Responsive */
@media (max-width: 768px) {
    .trip-tracker-stats {
        flex-direction: column;
        gap: 8px;
    }

    .trip-list-item {
        flex-direction: column;
    }

    .trip-list-item .trip-thumbnail {
        width: 100%;
        height: 200px;
    }

    .trip-tracker-legend ul {
        flex-direction: column;
        gap: 8px;
    }
}

/* Custom marker styles - 20% larger */
.trip-tracker-marker {
    width: 48px;
    height: 48px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    transition: transform 0.3s ease-out;
    transform-origin: center center;
}

/* Pulsing glow effect for live marker */
.trip-tracker-marker-live {
    filter: drop-shadow(0 0 6px rgba(40, 167, 69, 0.6));
}

.trip-tracker-marker-live::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border-radius: 50%;
    background: rgba(40, 167, 69, 0.3);
    animation: marker-pulse 2s ease-out infinite;
    pointer-events: none;
    z-index: -1;
}

/* When moving, show direction indicator */
.trip-tracker-marker-moving {
    /* Rotation is applied via JS transform */
}

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

/* Photo stack container */
.trip-photo-stack {
    position: relative;
    cursor: pointer;
}

/* Photo marker on map - Polaroid style */
.trip-photo-marker {
    width: 50px;
    height: 60px;
    background: #fff;
    padding: 4px 4px 12px 4px;
    border-radius: 2px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.25s ease-out, box-shadow 0.2s;
    --base-rotation: 0deg;
    --stack-index: 0;
}

/* Single photo hover - grow by 10% */
.trip-photo-stack:not(.is-stacked) .trip-photo-marker:hover {
    transform: rotate(var(--base-rotation)) scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

/* Stacked photos - positioning */
.trip-photo-stack.is-stacked .trip-photo-marker {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotate(var(--base-rotation)) translateY(calc(var(--stack-index) * -3px));
}

/* Stacked photos hover - fan out to reveal 10% of cards below */
.trip-photo-stack.is-stacked:hover .trip-photo-marker {
    transform: rotate(var(--base-rotation)) translateX(calc(var(--stack-index) * 12px)) translateY(calc(var(--stack-index) * -8px));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.trip-photo-stack.is-stacked:hover .trip-photo-marker:hover {
    transform: rotate(var(--base-rotation)) translateX(calc(var(--stack-index) * 12px)) translateY(calc(var(--stack-index) * -8px)) scale(1.1);
    z-index: 100 !important;
}

/* Stack indicator badge */
.trip-photo-stack.is-stacked::after {
    content: attr(data-count);
    position: absolute;
    top: -8px;
    right: -8px;
    background: #007bff;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.trip-photo-marker .polaroid-frame {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.trip-photo-marker .polaroid-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Photo popup - Full polaroid view */
.trip-photo-popup .mapboxgl-popup-content {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.trip-photo-popup .trip-photo-polaroid {
    background: #fff;
    padding: 12px 12px 40px 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    transform: rotate(-1deg);
    max-width: 280px;
}

.trip-photo-popup .trip-photo-polaroid .polaroid-image {
    width: 100%;
    overflow: hidden;
}

.trip-photo-popup .trip-photo-polaroid .polaroid-image img {
    width: 100%;
    height: auto;
    display: block;
}

.trip-photo-popup .trip-photo-polaroid .polaroid-caption {
    margin-top: 12px;
    text-align: center;
}

.trip-photo-popup .trip-photo-polaroid .polaroid-caption .caption-text {
    display: block;
    font-family: 'Patrick Hand', 'Comic Sans MS', cursive, sans-serif;
    font-size: 14px;
    color: #333;
    line-height: 1.4;
}

.trip-photo-popup .trip-photo-polaroid .polaroid-caption .caption-date {
    display: block;
    font-size: 11px;
    color: #888;
    margin-top: 4px;
}
