* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
    color: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Disclaimer Notice in Header */
.disclaimer-notice {
    margin-top: 15px;
    padding: 10px 20px;
    background-color: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    font-size: 0.95rem;
    backdrop-filter: blur(10px);
}

.disclaimer-notice strong {
    color: #fef3c7;
}

/* Disclaimer Link */
.disclaimer-link {
    color: #fef3c7;
    text-decoration: underline;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-right: 5px;
}

.disclaimer-link:hover {
    color: white;
    text-decoration: none;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Search Section */
.search-section {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.search-methods {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.divider {
    color: var(--text-secondary);
    font-weight: 500;
}

.manual-search,
.address-search {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 500px;
}

.address-search input {
    direction: rtl;
    text-align: right;
}

input[type="text"] {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background-color: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-secondary:hover {
    background-color: #475569;
}

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

/* Status Message */
.status-message {
    margin-top: 20px;
    padding: 12px 16px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
}

.status-message.info {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-message.error {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-message.success {
    background-color: #d1fae5;
    color: #065f46;
}

/* Map Section */
.map-section {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    min-height: 600px;
}

/* View Toggle Buttons */
.view-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.view-btn {
    padding: 8px 16px;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
    font-weight: 500;
}

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

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

/* Content Container */
.content-container {
    display: flex;
    gap: 20px;
    height: 600px;
    position: relative;
}

/* View Modes */
.content-container.list-only .nearby-stops-panel {
    width: 100%;
}

.content-container.map-only .map-container {
    width: 100%;
}

.content-container.split-view {
    display: flex;
}

.content-container.split-view .nearby-stops-panel {
    width: 35%;
    min-width: 300px;
}

.content-container.split-view .map-container {
    flex: 1;
}

/* Nearby Stops Panel */
.nearby-stops-panel {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 8px;
    overflow-y: auto;
    height: 100%;
}

.nearby-stops-panel h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.3rem;
    text-align: center;
}

.distance-filter {
    margin-bottom: 20px;
    padding: 15px;
    background-color: var(--bg-color);
    border-radius: 8px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.distance-filter label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
}

#distanceValue {
    color: var(--primary-color);
    font-weight: 700;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
}

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

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

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

.stop-item {
    padding: 16px;
    background-color: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.stop-item:hover {
    border-color: var(--primary-color);
    transform: translateX(-4px);
    box-shadow: var(--shadow);
}

.stop-item.highlighted {
    background-color: #fef3c7;
    border-color: var(--warning-color);
    animation: highlight-pulse 2s ease-in-out;
}

@keyframes highlight-pulse {
    0%, 100% { background-color: var(--bg-color); }
    50% { background-color: #fef3c7; }
}

.stop-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.stop-item-name {
    font-weight: 600;
    color: var(--text-primary);
}

.stop-item-distance {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stop-item-code {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stop-item-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.stop-item-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 8px;
}

.stop-item-status.compliant {
    background-color: #d1fae5;
    color: #065f46;
}

.stop-item-status.violation {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Stop Details Section */
.stop-details-section {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.stop-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.stop-header h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.stop-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stop-code {
    background-color: var(--bg-color);
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    color: var(--text-secondary);
}

.stop-distance {
    color: var(--text-secondary);
}

/* Compliance Status */
.compliance-status {
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    font-weight: 600;
    text-align: center;
    font-size: 1.1rem;
}

.compliance-status.compliant {
    background-color: #d1fae5;
    color: #065f46;
}

.compliance-status.violation {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.info-card {
    background-color: var(--bg-color);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.info-card h3 {
    margin-bottom: 8px;
    color: var(--text-primary);
}

.card-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.service-list, .violations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.service-item, .violation-item {
    padding: 12px;
    background-color: white;
    border-radius: 6px;
    border-right: 4px solid var(--primary-color);
}

.violation-item {
    border-right-color: var(--danger-color);
}

.service-route {
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.service-time {
    font-weight: 600;
    color: var(--text-primary);
}

.service-headsign {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.service-agency {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 4px;
}

.empty-message {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

footer p {
    margin: 5px 0;
}

/* Footer Disclaimer */
.footer-disclaimer {
    margin: 20px auto;
    padding: 20px;
    background-color: #fef3c7;
    border: 2px solid #f59e0b;
    border-radius: 8px;
    max-width: 800px;
}

.footer-disclaimer p {
    margin: 8px 0;
    color: #92400e;
    line-height: 1.6;
}

.footer-disclaimer p:first-child {
    font-size: 1.1rem;
    color: #78350f;
    margin-bottom: 12px;
}

/* Terms Button */
.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    text-decoration: underline;
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
    margin-top: 10px;
    transition: color 0.3s;
}

.btn-link:hover {
    color: #1d4ed8;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 800px;
    max-height: 90vh;
    width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.3s;
}

.modal-close:hover {
    background-color: var(--bg-color);
    color: var(--danger-color);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

.modal-body h3 {
    color: var(--danger-color);
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.modal-body h4 {
    color: var(--text-primary);
    margin-top: 25px;
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.modal-body p {
    margin-bottom: 12px;
    line-height: 1.6;
    color: var(--text-primary);
}

.modal-body ul {
    margin: 10px 0 20px 30px;
    line-height: 1.8;
}

.modal-body ul li {
    color: var(--text-secondary);
}

.modal-body strong {
    color: var(--danger-color);
    font-weight: 700;
}

.terms-acceptance {
    margin-top: 30px;
    padding: 20px;
    background-color: #fef3c7;
    border-radius: 8px;
    border: 2px solid #f59e0b;
}

.terms-acceptance p {
    margin: 0;
    color: #92400e;
    font-weight: 600;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 2px solid var(--border-color);
    display: flex;
    justify-content: center;
}

#acceptTermsBtn {
    min-width: 200px;
}

.data-update-info {
    background-color: var(--bg-color);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 15px !important;
    display: inline-block;
}

/* Map Container and Controls */
.map-container {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
}

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

/* Map Controls */
.map-controls {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-control-btn {
    width: 36px;
    height: 36px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.map-control-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.1);
}

/* Map Markers */
.user-marker-container {
    z-index: 1000 !important;
}

.user-location-marker {
    width: 20px;
    height: 20px;
    background: #3b82f6;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    position: relative;
}

.user-location-marker .pulse {
    width: 40px;
    height: 40px;
    background: rgba(59, 130, 246, 0.4);
    border-radius: 50%;
    position: absolute;
    top: -10px;
    left: -10px;
    animation: pulse 2s infinite;
}

.user-location-marker .inner-dot {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 6px;
    left: 6px;
}

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

/* Stop Markers */
.stop-marker-container {
    z-index: 500 !important;
}

.stop-marker {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    position: relative;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.stop-marker:hover {
    transform: rotate(-45deg) scale(1.2);
}

.stop-marker .marker-icon {
    transform: rotate(45deg);
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.marker-compliant {
    background: #10b981;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.marker-violation {
    background: #ef4444;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.marker-highlight {
    animation: bounce 0.5s ease-in-out 3;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0) rotate(-45deg);
    }
    50% {
        transform: translateY(-10px) rotate(-45deg);
    }
}

/* Marker Clusters */
.marker-cluster {
    background-clip: padding-box;
    border-radius: 20px;
}

.marker-cluster div {
    width: 30px;
    height: 30px;
    margin-left: 5px;
    margin-top: 5px;
    text-align: center;
    border-radius: 15px;
    font: 12px Arial, Helvetica, sans-serif;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Cluster size classes */
.marker-cluster-small {
    width: 40px;
    height: 40px;
}

.marker-cluster-medium {
    width: 50px;
    height: 50px;
}

.marker-cluster-medium div {
    width: 40px;
    height: 40px;
}

.marker-cluster-large {
    width: 60px;
    height: 60px;
}

.marker-cluster-large div {
    width: 50px;
    height: 50px;
}

/* Cluster color classes based on compliance */
.marker-cluster.cluster-compliant {
    background-color: rgba(16, 185, 129, 0.6);
}

.marker-cluster.cluster-compliant div {
    background-color: rgba(16, 185, 129, 0.9);
}

.marker-cluster.cluster-violation {
    background-color: rgba(239, 68, 68, 0.6);
}

.marker-cluster.cluster-violation div {
    background-color: rgba(239, 68, 68, 0.9);
}

.marker-cluster.cluster-mostly-violation {
    background-color: rgba(251, 146, 60, 0.6);
}

.marker-cluster.cluster-mostly-violation div {
    background-color: rgba(251, 146, 60, 0.9);
}

.marker-cluster.cluster-mixed {
    background-color: rgba(250, 204, 21, 0.6);
}

.marker-cluster.cluster-mixed div {
    background-color: rgba(250, 204, 21, 0.9);
}

.marker-cluster.cluster-default {
    background-color: rgba(148, 163, 184, 0.6);
}

.marker-cluster.cluster-default div {
    background-color: rgba(148, 163, 184, 0.9);
}

/* Cluster hover effect */
.marker-cluster:hover {
    transform: scale(1.1);
    transition: transform 0.2s;
}

/* Map Popup */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.map-popup {
    min-width: 200px;
    text-align: right;
    padding: 5px;
}

.map-popup h4 {
    margin: 0 0 10px 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.map-popup p {
    margin: 5px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.map-popup .compliance-status {
    font-weight: bold;
    margin: 10px 0;
    padding: 5px 10px;
    border-radius: 6px;
    display: inline-block;
}

.map-popup .compliance-status.compliant {
    background: #d1fae5;
    color: #065f46;
}

.map-popup .compliance-status.violation {
    background: #fee2e2;
    color: #991b1b;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .search-section {
        padding: 20px;
    }

    .manual-search,
    .address-search {
        flex-direction: column;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .stop-meta {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Mobile map adjustments */
    .map-section {
        padding: 10px;
    }
    
    .view-toggle {
        flex-wrap: wrap;
    }
    
    .content-container {
        height: 500px;
    }
    
    .content-container.split-view {
        flex-direction: column;
        height: auto;
    }
    
    .content-container.split-view .nearby-stops-panel {
        width: 100%;
        height: 250px;
        margin-bottom: 10px;
    }
    
    .content-container.split-view .map-container {
        width: 100%;
        height: 400px;
    }
    
    .map-controls {
        top: 5px;
        left: 5px;
    }
    
    .map-control-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}

/* Modal responsive */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 95vh;
        margin: 10px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-header h2 {
        font-size: 1.2rem;
    }
    
    .footer-disclaimer {
        padding: 15px;
        margin: 15px 0;
    }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 1024px) {
    .content-container.split-view .nearby-stops-panel {
        width: 40%;
    }
}

/* User location marker variations for stop-as-location */
.user-location-marker.stop-as-location {
    background-color: #10b981;
    border-color: white;
}

.user-location-marker.stop-as-location .pulse {
    background-color: rgba(16, 185, 129, 0.4);
    animation: pulse-green 2s infinite;
}

.user-location-marker.stop-as-location .inner-dot {
    background-color: white;
}

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

/* Status message for stop location */
.status-message.stop-location {
    background-color: #d1fae5;
    color: #065f46;
    font-weight: 600;
}