/* ============================================================================
   ENHANCED CAMPUS NAVIGATION SYSTEM - FIXED STYLES
   ============================================================================ */

:root {
    --primary: #007bff;
    --primary-dark: #0056b3;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 25px rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
}

/* ============================================================================
   NAVIGATION CONTAINER
   ============================================================================ */

.navigation-container {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

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

#navigation-map {
    width: 100%;
    height: 100%;
    background: #e5e5e5;
}

/* ============================================================================
   SEARCH OVERLAY
   ============================================================================ */

.search-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    right: auto;
    z-index: 2000;
    width: 100%;
    max-width: 450px;
}

.search-input-group {
    position: relative;
    background: white;
    border-radius: 28px;
    box-shadow: var(--shadow-md);
    overflow: visible;
    z-index: 2000;
    cursor: text;
    pointer-events: auto;
    transition: var(--transition);
    width: 100%;
}

.search-input-group:hover {
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.15);
}

.search-input {
    width: 100%;
    padding: 16px 55px 16px 24px;
    border: 2px solid transparent;
    outline: none;
    font-size: 16px;
    background: transparent;
    cursor: text;
    pointer-events: auto;
    transition: var(--transition);
    border-radius: 28px;
    box-sizing: border-box;
}

.search-input:focus {
    background: white;
    border-color: var(--primary);
}

.search-input::placeholder {
    color: #999;
}

.search-icon {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
    font-size: 18px;
    transition: var(--transition);
    z-index: 12;
}

.search-input:focus ~ .search-icon {
    color: var(--primary);
}

.clear-search-btn {
    position: absolute;
    right: 55px;
    top: 50%;
    transform: translateY(-50%);
    background: #f0f0f0;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: var(--transition);
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    z-index: 13;
    pointer-events: auto;
}

.clear-search-btn:hover {
    background: #e0e0e0;
    color: var(--danger);
    transform: translateY(-50%) scale(1.1);
}

.clear-search-btn:active {
    transform: translateY(-50%) scale(0.95);
}

/* ============================================================================
   SEARCH RESULTS
   ============================================================================ */

.search-results {
    background: white;
    border-radius: 0 0 20px 20px;
    box-shadow: var(--shadow-md);
    max-height: 350px;
    overflow-y: auto;
    display: none;
    pointer-events: auto;
    position: relative;
    z-index: 1020;
    margin-top: -20px;
    padding-top: 20px;
    animation: slideDown 0.3s ease-out;
    width: 100%;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: transparent;
}

.search-results::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.search-result-item {
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    pointer-events: auto;
}

.search-result-item:hover {
    background: #f8f9fa;
    padding-left: 28px;
}

.search-result-item.selected {
    background: #e3f2fd;
    border-left: 4px solid var(--primary);
    padding-left: 24px;
}

.search-result-item.no-results {
    cursor: default;
    color: #999;
    font-style: italic;
    text-align: center;
}

.result-name {
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.result-type {
    font-size: 0.85em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.result-description {
    font-size: 0.9em;
    color: #888;
    margin-top: 6px;
    line-height: 1.4;
}

mark {
    background-color: #fff3cd;
    color: #856404;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* ============================================================================
   LOCATION CONTROLS
   ============================================================================ */

.location-controls {
    position: absolute;
    top: 30px;
    right: 20px;
    z-index: 1010;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.location-btn {
    width: 54px;
    height: 54px;
    background: white;
    border: none;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 20px;
    color: var(--primary);
    position: relative;
}

.location-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.08);
    box-shadow: var(--shadow-lg);
}

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

.location-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

.location-btn.active::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 2px solid var(--primary);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

/* ============================================================================
   MANUAL LOCATION OVERLAY
   ============================================================================ */

.manual-location-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2500;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.manual-location-card {
    background: white;
    border-radius: 20px;
    padding: 35px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.manual-location-title {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
}

.manual-location-description {
    color: #666;
    margin-bottom: 24px;
    line-height: 1.6;
    font-size: 0.95em;
}

.manual-location-btn {
    background: var(--primary);
    color: white;
    padding: 14px 32px;
    border: none;
    border-radius: 28px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    margin: 6px;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.manual-location-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.manual-location-btn.secondary {
    background: var(--secondary);
}

.manual-location-btn.secondary:hover {
    background: #5a6268;
}

.location-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1500;
    pointer-events: none;
    display: none;
    animation: crosshairPulse 1.5s infinite;
}

@keyframes crosshairPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.7;
    }
}

.crosshair-icon {
    font-size: 36px;
    color: var(--danger);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* ============================================================================
   ROUTE INFO PANEL - COMPLETELY FIXED
   ============================================================================ */

.route-info {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    z-index: 5000 !important;
    max-height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    transform: translateY(0);
    opacity: 1;
    transition: all 0.3s ease;
}

/* Ensure SweetAlert overlays sit above search */
.swal2-container {
    z-index: 5000 !important;
}

.heading-marker {
    width: 30px;
    height: 30px;
    position: relative;
}

.heading-arrow-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.heading-arrow {
    color: #2563eb;
    font-size: 24px;
    filter: drop-shadow(0 0 2px white);
}

.heading-dot {
    width: 8px;
    height: 8px;
    background: white;
    border: 2px solid #2563eb;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.route-info-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.route-info-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: #f8f9fa;
    border: none;
    border-bottom: 1px solid #e9ecef;
    color: #666;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
    border-radius: 20px 20px 0 0;
}

.route-info-handle:hover {
    background: #e9ecef;
}

.route-info-handle i {
    transition: transform 0.3s ease;
}

.route-info.active .route-info-handle i {
    transform: rotate(180deg);
}

.route-info-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    min-height: 0;
    display: block;
}

.route-info:not(.active) .route-info-content {
    display: none;
}

.route-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f0f0f0;
}

.route-stat {
    padding: 12px 8px;
    background: #f8f9fa;
    border-radius: 12px;
    text-align: center;
    transition: var(--transition);
}

.route-stat:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.route-stat-value {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.route-stat-label {
    font-size: 0.8em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.route-instructions h6 {
    margin: 0 0 12px 0;
    color: var(--primary);
    font-size: 0.95em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.instructions-list {
    max-height: 200px;
    overflow-y: auto;
}

.instruction-item {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 10px;
    font-size: 0.9em;
    color: #555;
    transition: var(--transition);
    background: #f8f9fa;
}

.instruction-item:hover {
    background: #e9ecef;
}

.instruction-item.current-instruction {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-left: 4px solid var(--primary);
    font-weight: 600;
    transform: scale(1.02);
    box-shadow: var(--shadow-sm);
}

.instruction-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 0.85em;
    flex-shrink: 0;
}

.instruction-text {
    flex: 1;
    line-height: 1.5;
}

.instruction-distance {
    color: var(--primary);
    font-weight: 700;
    margin-left: 8px;
    font-size: 0.9em;
    background: white;
    padding: 2px 8px;
    border-radius: 12px;
}

/* ============================================================================
   ROUTE CONTROLS - ALWAYS VISIBLE
   ============================================================================ */

.route-controls {
    display: flex !important;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #e9ecef;
    background: white;
    flex-shrink: 0;
    border-radius: 0 0 20px 20px;
    pointer-events: auto;
    visibility: visible !important;
    opacity: 1 !important;
}

.route-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    min-height: 48px;
    white-space: nowrap;
    visibility: visible !important;
    opacity: 1 !important;
}

.route-btn.primary {
    background: var(--success);
    color: white;
}

.route-btn.secondary {
    background: var(--danger);
    color: white;
}

.route-btn.tertiary {
    background: var(--info);
    color: white;
}

.route-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.route-btn:active:not(:disabled) {
    transform: translateY(0);
}

.route-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#start-navigation {
    display: flex !important;
}

#stop-navigation,
#recalculate-route {
    display: none !important;
}

body.is-navigating #start-navigation {
    display: none !important;
}

body.is-navigating #stop-navigation,
body.is-navigating #recalculate-route {
    display: flex !important;
}

/* ============================================================================
   LOADING & NOTIFICATIONS
   ============================================================================ */

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    font-size: 18px;
    color: var(--primary);
    font-weight: 600;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.notification-popup {
    position: absolute;
    top: 100px;
    left: 20px;
    right: 20px;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 1500;
    transform: translateY(-120px);
    opacity: 0;
    transition: var(--transition);
    max-width: 420px;
    overflow: hidden;
}

.notification-popup.show {
    transform: translateY(0);
    opacity: 1;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #0056b3 100%);
    color: white;
}

.notification-title {
    font-weight: 700;
    font-size: 1.05em;
}

.notification-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.notification-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.notification-message {
    padding: 20px;
    color: var(--dark);
    line-height: 1.6;
}

/* ============================================================================
   AUTH OVERLAY
   ============================================================================ */

.auth-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.288);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3500;
    backdrop-filter: blur(6px);
}

.auth-card {
    background: white;
    border-radius: 20px;
    padding: 45px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.auth-title {
    font-size: 1.6em;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 18px;
}

.auth-description {
    color: #666;
    margin-bottom: 32px;
    line-height: 1.6;
    font-size: 0.95em;
}

.google-signin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #db4437;
    color: white;
    padding: 14px 32px;
    border-radius: 28px;
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
    margin-bottom: 16px;
    width: 100%;
    font-size: 15px;
}

.google-signin-btn:hover {
    background: #c23321;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.guest-continue-btn {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 12px 32px;
    border-radius: 28px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    width: 100%;
    font-size: 15px;
}

.guest-continue-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

/* ============================================================================
   MAP MARKERS
   ============================================================================ */

.user-location-marker {
    background-color: var(--primary);
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
}

.user-location-marker i {
    color: white;
    font-size: 14px;
}

.heading-indicator {
    background-color: rgba(0, 123, 255, 0.9);
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s ease-out;
    box-shadow: var(--shadow-md);
}

/* Ensure heading arrow icon is white */
.heading-indicator i {
    color: white;
}

.building-marker {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.building-marker-badge {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    border: 2px solid #ffffff;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.building-marker-badge .material-icons {
    color: #ffffff;
    font-size: 18px;
    line-height: 1;
}

.event-marker {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.event-marker-badge {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0dcaf0 0%, #0aa2c0 100%);
    border: 2px solid #ffffff;
    box-shadow: 0 6px 16px rgba(13, 202, 240, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.event-marker-badge i {
    color: #ffffff;
    font-size: 14px;
}

.notification-marker {
    background: var(--warning);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
    .search-overlay {
        left: 1px;
        right: 20px;
        max-width: none;
    }
    
    .location-controls {
        right: 10px;
        gap: 10px;
    }
    
    .location-btn {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
    
    .route-info {
        left: 8px;
        right: 8px;
        bottom: calc(env(safe-area-inset-bottom, 0) + 8px);
        max-height: 60vh;
    }
    
    .route-controls {
        gap: 8px;
        padding: 12px 16px;
    }
    
    .route-btn {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 44px;
    }
    
    .route-stats {
        gap: 8px;
    }
    
    .route-stat {
        padding: 10px 6px;
    }
    .route-info-handle {
        padding: 10px 14px;
    }

    .route-info-content {
        padding: 12px 14px;
    }

    .route-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .route-stat-value {
        font-size: 1.15em;
    }

    .route-stat-label {
        font-size: 0.78em;
    }
}

/* ============================================================================
   DESTINATION CARD AND SEARCH THUMBNAILS
   ============================================================================ */
.selected-destination-card {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}
.dest-card-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.dest-thumb img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}
.dest-details {
    flex: 1;
}
.dest-title {
    font-weight: 700;
    margin-bottom: 4px;
}
.dest-subtitle {
    color: #6c757d;
    font-size: 0.9em;
    margin-bottom: 6px;
}
.dest-meta {
    margin-top: 4px;
    font-size: 0.85em;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 6px;
}
.dest-meta-note {
    font-size: 0.8em;
    color: #6c757d;
}
.dest-desc {
    color: #444;
    font-size: 0.9em;
}

/* Search result thumbnails */
.search-results .search-result-item {
    display: flex;
    gap: 10px;
    align-items: center;
}
.search-results .result-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}
.search-results .result-text {
    flex: 1;
}

@media (max-width: 480px) {
    .route-btn span {
        display: none;
    }
    
    .route-btn {
        padding: 10px;
        min-height: 42px;
    }
    
    .route-btn i {
        margin: 0;
        font-size: 16px;
    }
}

@media (min-width: 769px) {
    .route-info {
        max-width: 500px;
        left: 20px;
        right: auto;
    }
}