/* Mobile-First Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c5f8d;
    --secondary-color: #f0ad4e;
    --accent-color: #5cb85c;
    --danger-color: #d9534f;
    --text-color: #333;
    --border-color: #ddd;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --header-height: 120px;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #fafafa;
    color: var(--text-color);
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary-color), #1a3a52);
    color: white;
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.app-header h1 {
    font-size: 24px;
    margin-bottom: 12px;
    text-align: center;
}

.header-nav {
    display: flex;
    gap: 8px;
    justify-content: space-around;
}

.nav-btn {
    flex: 1;
    padding: 10px 8px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
}

.nav-btn:active,
.nav-btn.active {
    background-color: var(--secondary-color);
    color: #333;
    font-weight: bold;
}

/* Main Content */
.main-content {
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

.view {
    display: none;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
}

.view.active {
    display: block;
}

#map-view {
    padding: 0;
}

/* Tours List */
.tours-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 16px;
}

.tour-card {
    background: white;
    border-radius: 8px;
    padding: 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    touch-action: manipulation;
}

.tour-card:active {
    transform: translateY(2px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.tour-card h3 {
    color: var(--primary-color);
    font-size: 18px;
    margin-bottom: 8px;
}

.tour-card p {
    color: #666;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
}

.tour-card .location-count {
    font-size: 12px;
    color: #999;
    font-weight: bold;
}

/* Map Container */
.map-container {
    height: 70vh;
    min-height: 400px;
    width: 100%;
    overflow: hidden;
}

#map {
    height: 100%;
    width: 100%;
}

/* Routing Panel */
.routing-panel {
    background: white;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 500;
    border-top: 1px solid var(--border-color);
    display: none;
    width: 100% !important;
    left: 0;
}

.routing-panel.active {
    display: block;
}

.routing-toggle {
    width: 100% !important;
    padding: 12px 16px;
    background: #f8f9fa;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 16px;
    box-sizing: border-box;
}

.routing-toggle .toggle-icon {
    transition: transform 0.3s ease;
}

.routing-panel.expanded .toggle-icon {
    transform: rotate(180deg);
}

.instructions-content {
    display: none; /* Hide content by default */
    background: white;
    width: 100% !important;
    box-sizing: border-box;
}

.routing-panel.expanded .instructions-content {
    display: block; /* Show when expanded */
    max-height: 40vh;
    overflow-y: auto;
    border-top: 1px solid #eee;
}

/* Override Leaflet Routing Machine default styles to fit our panel */
.leaflet-routing-container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    background: white !important;
    border: none !important;
    box-shadow: none !important;
    font-size: 14px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.leaflet-routing-alt {
    max-height: none !important;
    margin: 0 !important;
    padding: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.leaflet-routing-geocoders {
    display: none !important;
}

/* Ensure routing machine table is full width */
.leaflet-routing-alt table {
    width: 100% !important;
}

/* Nearby Controls */
.nearby-controls {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.distance-control {
    margin-top: 12px;
}

.distance-control label {
    display: block;
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 500;
}

.distance-control input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.distance-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.distance-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

/* Nearby List */
.nearby-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.location-card {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    gap: 12px;
    touch-action: manipulation;
}

.location-card:active {
    transform: translateY(2px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.location-card-image {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    object-fit: cover;
    background: #eee;
    flex-shrink: 0;
}

.location-card-info {
    flex: 1;
}

.location-card h4 {
    font-size: 16px;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.location-card p {
    font-size: 12px;
    color: #999;
}

.distance-badge {
    background: var(--secondary-color);
    color: #333;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    align-self: center;
    flex-shrink: 0;
}

/* Buttons */
.btn {
    padding: 12px 16px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    width: 100%;
}

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

.btn-primary:active {
    background-color: #1a3a52;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: flex-end;
}

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

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-content {
    background: white;
    width: 100%;
    max-height: 80vh;
    border-radius: 16px 16px 0 0;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    animation: slideUp 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#modal-body {
    padding-top: 20px;
}

.modal-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 16px;
}

.modal-section {
    margin-bottom: 16px;
}

.modal-section h2 {
    font-size: 24px;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.modal-section h3 {
    font-size: 16px;
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 8px;
    margin-top: 12px;
}

.modal-section p {
    font-size: 14px;
    line-height: 1.6;
    color: #666;
}

.tour-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tour-badge {
    background-color: #e8f4f8;
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--primary-color);
    display: inline-block;
}

.tour-badge:hover {
    background-color: var(--primary-color);
    color: white;
}

.tour-badge:active {
    transform: scale(0.95);
    background-color: #1a3a52;
}

/* Responsive Design for Tablets and Larger */
@media (min-width: 768px) {
    :root {
        --header-height: 140px;
    }

    .app-header h1 {
        font-size: 28px;
    }

    .nav-btn {
        font-size: 16px;
    }

    .main-content {
        max-width: 1200px;
        margin: 0 auto;
    }

    .modal.active {
        align-items: center;
        justify-content: center;
    }

    .modal-content {
        width: 90%;
        max-width: 600px;
        max-height: 80vh;
        border-radius: 16px;
    }

    .tours-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .nearby-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .location-card {
        flex-direction: column;
    }

    .location-card-image {
        width: 100%;
        height: 120px;
    }

    .distance-badge {
        align-self: flex-start;
    }
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    font-size: 16px;
    color: #999;
}

/* Error State */
.error {
    background-color: #f8d7da;
    color: #721c24;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #f5c6cb;
}

/* Latitude/Longitude Display (for debugging) */
.location-coords {
    font-size: 12px;
    color: #999;
    margin-top: 8px;
    font-family: monospace;
}
