#map {
    height: 500px;
}

.legend {
    margin-bottom: 20px;
    display: block;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

#metro-scl-container {
    width: 100%;
    overflow-x: auto;
}

.metro-map {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding-bottom: 20px;
}

.line-column {
    border: 1px solid #ccc;
    padding: 10px;
    border-radius: 5px;
    flex: 0 0 300px; /* Increased width to accommodate two tracks */
}

.line-header {
    padding: 10px;
    color: white;
    text-align: center;
    border-radius: 5px;
    margin-bottom: 10px;
    pointer-events: auto;
}

.station-list-container {
    position: relative;
}

.train-debug-info {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px;
    border-radius: 3px;
    font-size: 10px;
    white-space: nowrap;
    z-index: 10;
}

.station-list {
    list-style: none;
    padding: 0;
    width: 100%;
    /* A height of 100% here was causing the container to collapse to 0px,
       as its parent did not have a defined height. This resulted in a totalDistance
       of 0 in the simulation. Removing it allows the list to take its natural height. */
}

.tracks-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.tracks {
    position: absolute;
    top: 0;
    left: 16px; /* Centered tracks */
    width: 32px;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
}

.track-segment {
    position: absolute;
    background-color: #ccc;
    width: 2px;
    z-index: 1;
}

.train-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.train-container-ida,
.train-container-vuelta {
    width: 2px;
    height: 100%;
    background-color: #ddd;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 0, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
    }
}

.train {
    position: absolute;
    z-index: 2;
    width: 16px;
    height: 22px; /* body + arrow */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.train-body {
    width: 8px; /* Thinner train */
    height: 12px;
    background-color: currentColor;
    border-radius: 2px;
    border: 1px solid #333;
}

.train-arrow {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

.train.train-up {
    flex-direction: column-reverse;
}

.train.train-up .train-arrow {
    border-bottom: 6px solid currentColor;
}

.train.train-down .train-arrow {
    border-top: 6px solid currentColor;
}

.train[data-track="ida"] {
    transform: translateX(-50%);
    left: 0;
}

.train[data-track="vuelta"] {
    transform: translateX(-50%);
    left: 100%;
}


.station-item {
    padding: 10px 0 10px 50px; /* Increased padding to make space for tracks */
    position: relative;
    pointer-events: auto;
    z-index: 2; /* Ensure station items are above the track */
}

.station-circle {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
}

@keyframes transfer-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 255, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 255, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 0, 0);
    }
}

.station-circle.transfer-station {
    width: 20px;
    height: 20px;
    left: 32px;
    border: 2px solid yellow;
    animation: transfer-pulse 2s infinite;
}

.transfer-icon {
    height: 1em;
    margin-left: 5px;
    vertical-align: middle;
}

#service-status-banner {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.line-statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.line-status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.line-indicator {
    display: inline-block;
    width: 15px;
    height: 15px;
    border-radius: 50%;
}

/* Responsive Design */
@media (max-width: 768px) {
    .metro-map {
        flex-direction: column;
    }

    .line-column {
        flex: 1 1 100%;
    }

    .legend {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Collapsible Sections */
.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.toggle-btn {
    background: none;
    border: 1px solid white;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 5px;
}

.legend .toggle-btn {
    border: 1px solid #333;
    color: #333;
}

/* Station Details */
.station-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#schematic-view {
    display: none;
}

.station-closed {
    text-decoration: line-through;
    color: #888;
}

.track-switch {
    position: absolute;
    width: 30px;
    height: 4px;
    background-color: #555;
    z-index: 2;
    transform-origin: left center;
}

.closed-station {
    opacity: 0.5;
    pointer-events: none;
}

.closed-station a {
    text-decoration: line-through;
}

.track-segment.closed-segment {
    background-color: #a9a9a9 !important; /* Dark Gray */
    opacity: 0.4;
    border-top: 2px dashed #808080;
    z-index: 0; /* Behind operational tracks if they overlap */
}

.station-navigation {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

#station-lookup-form {
    display: flex;
    align-items: center;
}

.line-emoji {
    height: 1.2em;
    margin-right: 5px;
    vertical-align: middle;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.line-label {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: bold;
    color: #fff;
    background-color: var(--line-color);
    padding: 2px 8px;
    border-radius: 5px;
}

.train-circle {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    top: 50%;
    transform: translateY(-50%);
    border: 1px solid #333;
    z-index: 1000;
}

.accessibility-info.horizontal {
    flex-direction: row;
    align-items: center;
}

.accessibility-item {
    display: flex;
    align-items: center;
    gap: 5px;
    position: relative;
}

.accessibility-icon {
    cursor: pointer;
}

.accessibility-details {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 5px;
    border-radius: 3px;
    font-size: 0.8em;
    white-space: nowrap;
}

.accessibility-icon:hover + .accessibility-details,
.accessibility-item:hover .accessibility-details {
    display: block;
}

.express-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
}

.route-color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.status-circle.green {
    width: 15px;
    height: 15px;
    background-color: #28a745;
    border-radius: 50%;
}

.route-color-indicator.split {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(to right, #D62828 50%, #009E49 50%);
}

i.fas {
    font-size: 1.2rem;
}


.accessibility-details {
    display: none;
}

.fares-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.fare-card {
    background-color: var(--card-bg-color);
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .station-detail-container {
        grid-template-columns: 1fr 1fr;
    }
}

.station-detail-container h1 {
    grid-column: 1 / -1;
}

.station-detail-container p {
    margin: 0;
}

.accessibility-info {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.accessibility-item {
    background-color: #f0f0f0;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9em;
}

.fare-card h3 {
    margin-top: 0;
    color: var(--primary-color);
}

.fare-list {
    list-style: none;
    padding: 0;
}

.fare-list li {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.fare-list li:last-child {
    border-bottom: none;
}

.fare-period {
    font-weight: bold;
}

.fare-value {
    font-family: monospace;
    font-size: 1.1rem;
}

.details-toggle {
    background: none;
    border: 1px solid #ccc;
    color: #333;
    font-size: 1rem;
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.station-details {
    padding-left: 20px;
    margin-top: 10px;
    border-left: 2px solid #eee;
}

/* Traffic Light Status */
.traffic-light-status {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px;
    background-color: #f0f0f0;
    border-radius: 5px;
}

.traffic-light-status .light {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #ccc;
}

.traffic-light-status .light.red { background-color: #ff4d4d; }
.traffic-light-status .light.yellow { background-color: #ffff66; }
.traffic-light-status .light.green { background-color: #66ff66; }

.traffic-light-status .light.active {
    border: 3px solid #333;
    box-shadow: 0 0 10px 2px rgba(0,0,0,0.5);
}

/* Station Circle Hover Effect */
.station-circle:hover {
    transform: translateY(-50%) scale(1.2);
    border-color: #007bff; /* blue */
}

/* Station Name Link Style */
.station-item a {
    text-decoration: none;
    color: var(--text-color);
    transition: color 0.2s;
}

.station-item a:hover {
    color: var(--primary-color);
}


.station-status-popup {
    position: absolute;
    background-color: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    z-index: 100;
    font-size: 0.9rem;
}

.station-lookup-container {
    margin-bottom: 20px;
}

.station-lookup-input {
    width: 100%;
    padding: 10px;
    font-size: 1rem;
}

#station-suggestions {
    position: absolute;
    background-color: white;
    border: 1px solid #ccc;
    z-index: 1000;
    width: calc(100% - 42px);
}

#station-suggestions div {
    padding: 10px;
    cursor: pointer;
}

#station-suggestions div:hover {
    background-color: #f0f0f0;
}

.incident-report-banner {
    background-color: #fff3cd;
    border-left: 5px solid #ffeeba;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}