/* Main CSS file */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: #333;
    background-color: #000;
    -webkit-user-select: none;
    -moz-user-select: none;
         user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

* {
    -webkit-user-select: none;
    -moz-user-select: none;
         user-select: none;
    -webkit-touch-callout: none;
}

.canvas-container {
    display: inline-block;
    background-color: #000;
    position: absolute;
    top: 0;
    left: 0;
    transition: transform 0s;
    will-change: transform;
    touch-action: pan-x pan-y;
    -ms-touch-action: pan-x pan-y;
    overflow: visible;
}

/* Prevent zoom on double tap for iOS - but allow pan for canvas container */
body, html, #app, main {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}



main {
    flex: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: block;
    position: relative;
}

.canvas-container {
    display: inline-block;
    background-color: #000;
    position: relative;
    transition: transform 0s;
    will-change: transform;
}

#map-canvas {
    display: block;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    position: relative;
}

/* Cookie banner */
.cookie-banner {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background-color: rgba(20, 20, 20, 0.92);
    color: #fff;
    border-radius: 8px;
    z-index: 2500;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    max-width: min(720px, calc(100% - 24px));
    width: -moz-fit-content;
    width: fit-content;
    overflow-x: auto;
}

.cookie-banner.active {
    display: flex;
}

.cookie-banner-message {
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
    flex: 1;
    white-space: nowrap;
    overflow-wrap: anywhere;
}

.cookie-banner-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.cookie-banner-close:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

/* Station switch banner (always visible when station selected) */
.station-switch-banner {
    position: fixed;
    top: 36px;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 8px 14px;
    background-color: rgba(30, 64, 120, 0.94);
    color: #fff;
    border-radius: 8px;
    z-index: 900;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    font-size: 13px;
    line-height: 1.4;
    white-space: nowrap;
    max-width: min(480px, calc(100% - 24px));
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.station-switch-banner.show {
    opacity: 1;
    visibility: visible;
}

/* Floating Icons */
.floating-icon {
    position: fixed;
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.5);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: background-color 0.2s, transform 0.2s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transform-origin: top right;
}

.floating-icon:hover {
    background-color: rgba(255, 255, 255, 0.7);
}

.floating-icon:active {
    transform: scale(0.95);
}

.floating-icon svg {
    color: #333;
    width: 20px;
    height: 20px;
}

#download-btn {
    top: 16px;
    right: 72px;
}

#settings-btn {
    top: 16px;
    right: 16px;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
    line-height: 1;
    padding: 0;
}

.close-btn:hover {
    background-color: #f0f0f0;
    color: #333;
}

.close-btn:active {
    background-color: #e0e0e0;
}

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

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

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.settings-section select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}

.settings-section select:hover {
    border-color: #3498db;
    background-color: #f8f9fa;
}

.settings-section select:focus {
    outline: none;
    border-color: #3498db;
    background-color: #f8f9fa;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.settings-banner-message {
    padding: 10px 12px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    font-size: 13px;
    color: #333;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.settings-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
    font-size: 12px;
    color: #666;
}

.settings-footer .copyright {
    margin: 0 0 8px 0;
    font-size: 12px;
    color: #666;
}

.settings-footer a {
    color: #666;
    text-decoration: none;
    font-size: 12px;
    transition: color 0.2s;
}

.settings-footer a:hover {
    color: #3498db;
    text-decoration: underline;
}

/* Mobile styles for floating buttons - detect touch devices */
@media (pointer: coarse) {
    .floating-icon {
        width: 48px;
        height: 48px;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    .floating-icon svg {
        width: 24px;
        height: 24px;
    }

    #download-btn {
        top: 16px;
        right: 72px;
    }

    #settings-btn {
        top: 16px;
        right: 16px;
    }

    .station-switch-banner {
        top: 40px;
    }

    /* Modal adjustments for touch devices */
    .modal-content {
        width: 90%;
        max-width: 90%;
        border-radius: 12px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    .modal-header {
        padding: 16px;
        border-bottom: 1px solid #e0e0e0;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .close-btn {
        font-size: 24px;
        width: 32px;
        height: 32px;
        border-radius: 4px;
    }

    .modal-body {
        padding: 16px;
    }

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

    .settings-section label {
        margin-bottom: 8px;
        font-size: 14px;
    }

    .settings-section select {
        padding: 12px;
        border: 1px solid #ddd;
        border-radius: 4px;
        font-size: 16px;
    }

    .settings-footer {
        margin-top: 24px;
        padding-top: 16px;
        font-size: 14px;
    }

    .settings-footer .copyright {
        font-size: 14px;
    }

    .settings-footer a {
        font-size: 14px;
    }
}

/* Debug panel */
.debug-panel {
    position: fixed;
    bottom: 16px;
    left: 16px;
    right: 16px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    z-index: 3000;
    display: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

.debug-panel .debug-line {
    margin: 2px 0;
    word-break: break-all;
}

/* Station tooltip */
.station-tooltip {
    position: fixed;
    min-width: 180px;
    max-width: 280px;
    width: -moz-max-content;
    width: max-content;
    padding: 10px 12px;
    border-radius: 8px;
    background-color: rgba(20, 20, 20, 0.92);
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    z-index: 10000;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}

.station-tooltip.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.station-tooltip .tooltip-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.station-tooltip .tooltip-title-lines {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
}

.station-tooltip .tooltip-line-pill {
    display: inline-block;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: "Arial", "SimHei", sans-serif;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    color: #fff;
    vertical-align: baseline;
}

.station-tooltip .tooltip-line-link {
    text-decoration: none;
    cursor: pointer;
}

.station-tooltip .tooltip-line-pill:last-child {
    margin-right: 0;
}

.station-tooltip .tooltip-path-arrow {
    color: rgba(255, 255, 255, 0.5);
    margin: 0 2px;
}

.station-tooltip .tooltip-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.station-tooltip .tooltip-fare {
    font-weight: 600;
    white-space: nowrap;
}

.station-tooltip .tooltip-row {
    display: block;
    gap: 8px;
    margin: 2px 0;
    align-items: start;
}

.station-tooltip .tooltip-label {
    color: rgba(255, 255, 255, 1);
    white-space: nowrap;
}

.station-tooltip .tooltip-value {
    color: rgba(255, 255, 255, 0.7);
    text-align: left;
    overflow-wrap: anywhere;
}

.station-tooltip .tooltip-note {
    margin-top: 6px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
}

.station-tooltip .tooltip-actions {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.station-tooltip .tooltip-set-start {
    display: block;
    width: 100%;
    padding: 6px 10px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
}

/* When tooltip is hidden, ensure nothing inside receives pointer events */
.station-tooltip:not(.active) {
    pointer-events: none !important;
}

.station-tooltip .tooltip-set-start:hover {
    background: rgba(255, 255, 255, 0.25);
}

@media (pointer: coarse) {
    .debug-panel {
        font-size: 14px;
        padding: 16px;
        bottom: 20px;
        left: 20px;
        right: 20px;
    }
}

/* Fare range filter */
.fare-range-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fare-range-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.fare-range-controls input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
         appearance: none;
}

.fare-range-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    -webkit-transition: background-color 0.2s, transform 0.2s;
    transition: background-color 0.2s, transform 0.2s;
}

.fare-range-controls input[type="range"]::-webkit-slider-thumb:hover {
    background: #2980b9;
    transform: scale(1.1);
}

.fare-range-controls input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    -moz-transition: background-color 0.2s, transform 0.2s;
    transition: background-color 0.2s, transform 0.2s;
}

.fare-range-controls input[type="range"]::-moz-range-thumb:hover {
    background: #2980b9;
    transform: scale(1.1);
}

.fare-range-display {
    text-align: center;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    border: 1px solid #e0e0e0;
}

@media (pointer: coarse) {
    .fare-range-controls input[type="range"] {
        height: 12px;
    }

    .fare-range-controls input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }

    .fare-range-controls input[type="range"]::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }

    .fare-range-display {
        font-size: 16px;
        padding: 12px;
    }
}
