:root {
    --sbb-blue: #2d327d;
    --sbb-red: #eb0000;
    --sbb-white: #ffffff;
    --sbb-dark-grey: #1a1a1a;
    --clock-size: 100px;
    --buffer: 4px;
}

body {
    background-color: var(--sbb-dark-grey);
    color: var(--sbb-white);
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    margin: 0; padding: 20px; display: flex; flex-direction: column; align-items: center; min-height: 100vh;
}

.board {
    background-color: var(--sbb-blue); width: 100%; max-width: 1100px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8); border-radius: 4px; overflow: hidden;
    margin-bottom: 25px; position: relative;
}

.header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 30px; background: rgba(0,0,0,0.15); border-bottom: 2px solid rgba(255,255,255,0.1);
}

#map { height: 250px; width: 100%; border-bottom: 2px solid rgba(255,255,255,0.1); background: #1a1a1a; }

.sbb-logo-text { background: var(--sbb-red); padding: 5px 12px; font-weight: 900; font-size: 1rem; margin-right: 15px; }
.station-container { display: flex; flex-direction: column; }
.station-name { font-size: 2rem; font-weight: bold; }
.temp-header { font-size: 1rem; color: rgba(255,255,255,0.6); margin-top: 4px; }

/* --- CLOCK --- */
.clock-face { width: var(--clock-size); height: var(--clock-size); background-color: var(--sbb-white); border-radius: 50%; position: relative; flex-shrink: 0; }
#markers { position: absolute; width: 100%; height: 100%; }
.marker { position: absolute; left: 50%; background: black; transform-origin: 50% calc(50px - var(--buffer));  }
.marker.hour { width: 4px; height: 12px; margin-left: -2px; top: var(--buffer); }
.marker.min { width: 1.5px; height: 4px; margin-left: -0.75px; top: var(--buffer); }
.hand { position: absolute; left: 50%; top: 50%; background: black; }
.hour-hand { width: 6px; height: 32px; margin-left: -3px; transform: translateY(-25px); transform-origin: 50% 25px; z-index: 2; }
.minute-hand { width: 6px; height: 42px; margin-left: -3px; transform: translateY(-37px); transform-origin: 50% 37px; z-index: 3; }
.second-hand { width: 1.5px; height: 38px; margin-left: -0.75px; background: var(--sbb-red); transform: translateY(-28px); transform-origin: 50% 28px; z-index: 4; }
.second-hand::after { content: ''; position: absolute; top: 0; left: 50%; width: 10px; height: 10px; background: var(--sbb-red); border-radius: 50%; transform: translate(-50%, -5px); }

/* --- TABLE --- */
table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto; /* Changed from fixed */
}

th { text-align: left; padding: 12px 30px; font-size: 0.8rem; color: rgba(255,255,255,0.4); text-transform: uppercase; }
td { padding: 15px 30px; border-bottom: 1px solid rgba(255,255,255,0.05); white-space: nowrap; overflow: hidden; vertical-align: middle; }
#boardBody tr { cursor: pointer; transition: background 0.2s; }
#boardBody tr:hover { background: rgba(255,255,255,0.1); }

a:link, a:visited { color: #5f5d59; }
a:hover, a:active { color: #eb0000; }

/* ADJUSTED: Width reduced and padding set to bring content closer */
/* Change this value in style.css */

/* 1. Reduce this width to pull everything to the left */
.time-cell {
    font-size: 1.6rem;
    font-weight: bold;
    width: 1%;           /* Forces column to shrink to content size */
    white-space: nowrap; /* Keeps the time on one line */
    padding-right: 60px; /* Adjust this number to get the exact gap you want */
}

.line-badge { display: inline-block; padding: 2px 6px; font-weight: 900; font-size: 1rem; margin-right: 12px; border-radius: 2px; min-width: 40px; text-align: center; }
.line-IR { background: var(--sbb-red); color: white; }
.line-IC { background: white; color: var(--sbb-red); border: 2px solid var(--sbb-red); }
.line-S { background: white; color: var(--sbb-blue); border: 1.5px solid var(--sbb-blue); }

/* ADJUSTED: Padding removed to move text closer to the time */
.dest-cell {
    font-size: 1.6rem;
    font-weight: bold;
    padding-left: -60px; /* Pulls the content even closer */
    vertical-align: top;
}

.via-text { font-size: 0.85rem; color: rgba(255,255,255,0.6); margin-top: 2px; }
.track-box { background: white; color: var(--sbb-blue); padding: 4px 12px; font-weight: 900; font-size: 1.4rem; border-radius: 2px; }
.delay { color: #ff5555; margin-left: 8px; font-size: 1rem; }
.last-updated { padding: 10px 30px; font-size: 0.7rem; color: rgba(255,255,255,0.4); text-align: right; background: rgba(0,0,0,0.1); }

/* --- SEARCH & BUTTONS --- */
.search-container { position: relative; margin-top: auto; width: 100%; max-width: 600px; padding-bottom: 20px; }
.search-box { display: flex; gap: 10px; align-items: center; }
input { flex-grow: 1; padding: 12px; font-size: 1.1rem; border: none; border-radius: 2px; }
button.update-btn, button.util-btn { padding: 12px 20px; background: #eee; color: black; border: none; font-weight: bold; cursor: pointer; border-radius: 2px; transition: 0.2s; }
button.update-btn:hover, button.util-btn:hover { background: var(--sbb-red); color: white; }
.btn-active { background: var(--sbb-red) !important; color: white !important; }
#autocomplete-list { position: absolute; bottom: 100%; left: 0; right: 0; background: white; color: black; z-index: 1000; margin-bottom: 5px; border-radius: 2px; overflow: hidden; }
.autocomplete-item { padding: 10px; cursor: pointer; border-bottom: 1px solid #eee; transition: 0.2s; }
.autocomplete-item:hover { background-color: var(--sbb-red); color: white; }
.copyright { text-align: center; font-size: 0.7rem; color: rgba(255,255,255,0.3); margin-top: 20px; line-height: 1.4; }

/* --- SETTINGS POPUP (SCROLLABLE) --- */
#settingsOverlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 2000; justify-content: center; align-items: center; }

.settings-content {
    background: #222;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 450px;
    border: 1px solid #444;

    /* --- SCROLLBAR FIXES --- */
    max-height: 80vh;           /* Limits height to 80% of the screen */
    overflow-y: auto;           /* Shows scrollbar only when needed */
    overflow-x: hidden;         /* Prevents side-to-side wobbling */

    /* Smooth scrolling for mobile */
    -webkit-overflow-scrolling: touch;
}

.setting-row { margin: 20px 0; display: flex; flex-direction: column; gap: 8px; }

.fav-list {
    background: #333;
    border-radius: 4px;
    padding: 5px;
    max-height: 200px; /* Limits the favorite list specifically */
    overflow-y: auto;
}

.fav-item { padding: 8px; border-bottom: 1px solid #444; display: flex; justify-content: space-between; align-items: center; }
.fav-del { color: var(--sbb-red); font-weight: bold; padding: 0 10px; cursor: pointer; }

/* --- SBB MODAL & HORIZONTAL TIMELINE --- */
.overlay-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 3000; justify-content: center; align-items: center; }
.modal-content-details { background: #222; color: white; width: 95%; max-width: 1000px; padding: 30px; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); max-height: 85vh; overflow-y: hidden; overflow-x: hidden; display: flex; flex-direction: column; }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #444; padding-bottom: 10px; margin-bottom: 15px; }
.modal-header h2 { margin: 0; color: var(--sbb-white); font-size: 1.5rem; }

.modal-status { margin-bottom: 15px; font-size: 0.95rem; background: #333; padding: 10px; border-radius: 4px; }
.text-red { color: #ff5555; font-weight: bold; }

.route-list-wrapper {
    display: inline-flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 0 160px 0;
    position: relative;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    background: none;
    scroll-snap-type: x proximity;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

.horiz-step {
    flex: 0 0 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
}

.horiz-step::after {
    content: '';
    position: absolute;
    top: 62px;
    left: 50%;
    width: 100%;
    height: 6px;
    background-color: var(--sbb-blue);
    z-index: 1;
}

.horiz-step:first-child::before {
    content: '';
    position: absolute;
    top: 62px;
    right: 50%;
    width: 2000px;
    height: 6px;
    background-color: var(--sbb-blue);
    z-index: 1;
}

.horiz-step:last-child {
    flex: 0 0 150px;
}

.horiz-step:last-child::after {
    display: none;
}

.horiz-time {
    font-weight: bold;
    font-size: 1rem;
    height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding-bottom: 5px;
    text-align: center;
    width: 100%;
    position: relative;
    z-index: 3;
}

.horiz-delay {
    font-size: 0.75rem;
    color: #ff5555;
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
}

.horiz-node {
    width: 16px;
    height: 16px;
    background: white;
    border: 4px solid var(--sbb-blue);
    border-radius: 50%;
    box-sizing: border-box;
    margin-top: 12px;
    flex-shrink: 0;
    z-index: 3;
    position: relative;
}

.horiz-step.current-stop .horiz-node {
    background: var(--sbb-red);
    border-color: var(--sbb-red);
    box-shadow: 0 0 10px var(--sbb-red);
    width: 22px;
    height: 22px;
    margin-top: 9px;
}

.horiz-station {
    position: absolute;
    top: 85px;
    left: 50%;
    transform: rotate(45deg);
    transform-origin: top left;
    white-space: nowrap;
    font-size: 1.05rem;
    font-weight: bold;
    width: 250px;
    text-align: left;
}

.horiz-plat {
    position: absolute;
    top: 110px;
    left: 50%;
    transform: rotate(45deg);
    transform-origin: top left;
    white-space: nowrap;
    font-size: 0.85rem;
    color: #aaa;
    font-weight: bold;
    width: 250px;
    text-align: left;
}

.header-version {
    font-size: 0.55rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
    margin-top: 4px;
    text-transform: uppercase;
    font-family: Arial, sans-serif;
}

/* UI Elements */
#modalTrainName { display: flex; align-items: center; gap: 15px; margin: 0; }
.close-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.3); color: var(--sbb-white); background: transparent; cursor: pointer; font-size: 1.2rem; line-height: 1; transition: all 0.2s ease; padding: 0; margin-left: 15px; flex-shrink: 0; }
.close-btn:hover { background: var(--sbb-red); border-color: var(--sbb-red); color: white; transform: scale(1.05); }
#modalTrainName .line-badge { font-size: 1.4rem; padding: 6px 12px; min-width: 60px; border-radius: 4px; margin-right: 5px; }
#modalTrainName span:last-child { font-size: 1.8rem; font-weight: bold; }
#modalTrainStatus { margin-bottom: 20px; padding: 10px; background: rgba(255, 255, 255, 0.05); border-radius: 4px; }
#modalTrainStatus strong { color: var(--sbb-white); }
.train-specs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.spec-item { background: rgba(255, 255, 255, 0.05); padding: 10px; border-radius: 6px; border-left: 3px solid var(--sbb-red); }
.spec-label { display: block; font-size: 0.75rem; color: #888; text-transform: uppercase; letter-spacing: 0.5px; }
.spec-val { font-size: 1rem; font-weight: bold; color: #fff; }
.status-badge { display: inline-block; padding: 5px 12px; border-radius: 4px; font-size: 0.85rem; font-weight: bold; margin-right: 10px; margin-top: 10px; }
.ontime-bg { background: #2d5a27; color: #fff; }
.delay-bg { background: #9b1c1c; color: #fff; }
.track-bg { background: #c2780e; color: #fff; }

/* Custom Scrollbar for Settings and Favorites */
.settings-content::-webkit-scrollbar,
.fav-list::-webkit-scrollbar {
    width: 8px;
}

.settings-content::-webkit-scrollbar-track,
.fav-list::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 4px;
}

.settings-content::-webkit-scrollbar-thumb,
.fav-list::-webkit-scrollbar-thumb {
    background: #444; /* Grey thumb */
    border-radius: 4px;
    border: 2px solid #1a1a1a;
}

.settings-content::-webkit-scrollbar-thumb:hover,
.fav-list::-webkit-scrollbar-thumb:hover {
    background: var(--sbb-red); /* Turns red when you hover/scroll */
}
