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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #333;
    min-height: 100vh;
    padding: 20px;
}

/* Important stations styling */
.important-station {
    font-weight: 700 !important;
    font-size: 1.1em !important;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #FFCB06 0%, #F5B800 100%);
    color: #000;
    padding: 30px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 4px solid #000;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: bold;
    letter-spacing: 2px;
}

.station-info {
    text-align: right;
}

.station-info h2 {
    font-size: 2rem;
    margin-bottom: 8px;
}

.time-display-group {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.current-time {
    font-size: 1.1rem;
    color: #666;
}

.time-format-toggle-header {
    display: flex;
    align-items: center;
}

.time-format-toggle-header .toggle-switch {
    margin: 0;
}

.time-format-toggle-header .toggle-text {
    font-size: 0.9rem;
}

.controls {
    background: #f8f9fa;
    padding: 20px 40px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.controls-row {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 600;
    color: #555;
    font-size: 0.95rem;
}

.control-group select {
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.control-group select:hover {
    border-color: #FFCB06;
}

.control-group select:focus {
    outline: none;
    border-color: #FFCB06;
    box-shadow: 0 0 0 3px rgba(255, 203, 6, 0.1);
}

.board {
    padding: 30px 40px;
    min-height: 500px;
}

.departures-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1.1rem;
}

.departures-table thead {
    background: #2c3e50;
    color: white;
}

.departures-table th {
    padding: 18px 15px;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.95rem;
}

.departures-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s ease;
}

.departures-table tbody tr:hover {
    background-color: #f8f9fa;
}

.departures-table tbody tr.highlight {
    background-color: #fff9e6;
    font-weight: 600;
}

.departures-table tbody tr.highlight:hover {
    background-color: #fff3cc;
}

.departures-table td {
    padding: 20px 15px;
}

.train-number {
    font-weight: bold;
    color: #2c3e50;
    font-size: 1.3rem;
}

.train-number-text {
    margin-right: 8px;
}

.train-icon-link {
    display: inline-block;
    margin: 0 4px;
    color: #1e3c72;
    text-decoration: none;
    transition: color 0.2s ease, transform 0.2s ease;
    vertical-align: middle;
}

.train-icon-link:hover {
    color: #FFCB06;
    transform: scale(1.15);
}

.train-icon-link svg {
    vertical-align: middle;
}

.time {
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e3c72;
}

.scheduled-time {
    font-size: 0.85rem;
    text-decoration: line-through;
    color: #999;
    font-weight: normal;
    margin-bottom: 4px;
}

.estimated-time {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e3c72;
}

.estimated-time.delayed {
    color: #d32f2f;
    font-weight: bold;
}

.delay-info {
    font-size: 0.8rem;
    color: #d32f2f;
    font-weight: bold;
    margin-top: 2px;
}

.delay-info.propagated {
    color: #f57c00;
    font-style: italic;
}

.relative-time {
    font-size: 0.75rem;
    color: #666;
    margin-top: 3px;
    font-style: italic;
}

.estimated-time.propagated-estimate {
    color: #f57c00;
}

.propagated-note {
    font-size: 0.85rem;
    color: #f57c00;
    font-style: italic;
}

.departed {
    opacity: 0.6;
    background-color: #f5f5f5;
}

.departed-badge {
    display: inline-block;
    background-color: #757575;
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.arrived-badge {
    display: inline-block;
    background-color: #4CAF50;
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.bus-replacement {
    text-decoration: line-through;
    opacity: 0.7;
    background-color: #fff3cd;
}

.bus-replacement-badge {
    display: inline-block;
    background-color: #ff9800;
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.cancelled-badge {
    display: inline-block;
    background-color: #dc2626;
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

tr.cancelled {
    opacity: 0.6;
    background-color: #fee2e2;
}

.station-name {
    color: #555;
}

.equipment-type {
    color: #666;
    font-size: 0.95rem;
    font-family: 'Courier New', monospace;
    font-weight: 500;
}

/* Loading spinner animation */
.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #666;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Equipment code with tooltip */
.equipment-code {
    position: relative;
    cursor: help;
}

.tooltip-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    font-size: 10px;
    font-weight: bold;
    color: #666;
    background-color: #e8e8e8;
    border: 1px solid #ccc;
    border-radius: 50%;
    margin-left: 3px;
    vertical-align: middle;
    font-family: Arial, sans-serif;
    cursor: help;
}

.equipment-code:hover .tooltip-icon {
    color: #333;
    background-color: #d0d0d0;
    border-color: #999;
}

.next-day-badge {
    display: inline-block;
    background-color: #FF9800;
    color: white;
    font-size: 0.7rem;
    padding: 2px 5px;
    border-radius: 3px;
    margin-left: 5px;
    font-weight: bold;
}

.no-trains {
    text-align: center;
    padding: 60px 20px !important;
    color: #999;
    font-style: italic;
    font-size: 1.2rem;
}

/* Station Search Autocomplete */
.station-search-group {
    flex: 2;
}

.station-search-container {
    position: relative;
    display: flex;
    gap: 10px;
}

#station-search {
    flex: 1;
    padding: 10px;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 5px;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 100px;
    background: white;
    border: 2px solid #ddd;
    border-top: none;
    border-radius: 0 0 5px 5px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.autocomplete-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.autocomplete-item:hover {
    background-color: #f0f0f0;
}

.view-all-btn {
    padding: 10px 20px;
    background-color: #1e3c72;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    white-space: nowrap;
}

.view-all-btn:hover {
    background-color: #FFCB06;
    color: #1e3c72;
}

.performance-link {
    display: inline-block;
    padding: 10px 20px;
    background-color: #48bb78;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.performance-link:hover {
    background-color: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(72, 187, 120, 0.3);
}

/* Starred Stations */
.starred-stations {
    display: none;
    width: 100%;
    padding-top: 5px;
    border-top: 1px solid #e0e0e0;
}

.starred-stations label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #555;
    font-size: 0.95rem;
}

.starred-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.starred-station-btn {
    padding: 8px 16px;
    background-color: #FFCB06;
    color: #1e3c72;
    border: 2px solid #1e3c72;
    border-radius: 6px;
    cursor: move;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.9rem;
    user-select: none;
}

.starred-station-btn:hover,
.starred-station-btn.active {
    background-color: #1e3c72;
    color: #FFCB06;
}

.starred-station-btn.drag-over {
    border: 2px dashed #1e3c72;
    background-color: #e0e0e0;
    transform: scale(1.05);
}

.star-btn-compact {
    padding: 10px 15px;
    background-color: white;
    color: #1e3c72;
    border: 2px solid #1e3c72;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 45px;
}

.star-btn-compact:hover {
    background-color: #FFCB06;
    border-color: #FFCB06;
}

.star-btn-compact #star-icon {
    font-size: 1.5rem;
}

.location-btn-compact {
    padding: 10px 15px;
    background-color: white;
    color: #1e3c72;
    border: 2px solid #1e3c72;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 45px;
}

.location-btn-compact:hover {
    background-color: #FFCB06;
    border-color: #FFCB06;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch input[type="checkbox"] {
    display: none;
}

.toggle-label {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
    cursor: pointer;
}

.toggle-inner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #1e3c72;
    border-radius: 30px;
    transition: 0.3s;
}

.toggle-switch input[type="checkbox"]:checked + .toggle-label .toggle-inner {
    background-color: #FFCB06;
}

.toggle-switch-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input[type="checkbox"]:checked + .toggle-label .toggle-switch-slider {
    transform: translateX(30px);
}

.toggle-text {
    font-weight: bold;
    color: #1e3c72;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border: none;
    border-radius: 10px;
    width: 80%;
    max-width: 900px;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #000;
}

.region-group {
    margin-bottom: 30px;
}

.region-group h3 {
    color: #1e3c72;
    border-bottom: 2px solid #FFCB06;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.station-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.station-item {
    padding: 12px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
}

.station-item:hover {
    background-color: #FFCB06;
    border-color: #1e3c72;
    color: #1e3c72;
    font-weight: bold;
}

footer {
    background: #f8f9fa;
    padding: 20px 40px;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    border-top: 2px solid #e0e0e0;
}

footer p {
    margin: 5px 0;
}

/* Train Schedule Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fff;
    margin: 2% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, #f4c430 0%, #e6b800 100%);
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: #000;
    font-size: 1.5rem;
}

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

.close {
    color: #000;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close:hover,
.close:focus {
    color: #666;
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.schedule-table th {
    background-color: #f8f9fa;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 10;
}

.schedule-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e9ecef;
}

.schedule-table tr:hover {
    background-color: #f8f9fa;
}

.schedule-table .station-name {
    font-weight: 500;
}

.schedule-table .estimated-time {
    color: #0066cc;
    font-weight: 500;
}

.current-station-row {
    background-color: #fff3cd !important;
    border-left: 4px solid #f4c430;
}

.current-station-row:hover {
    background-color: #ffe69c !important;
}

.station-completed {
    opacity: 0.6;
    background-color: #f8f9fa;
}

.station-completed:hover {
    opacity: 0.7;
    background-color: #e9ecef;
}

.station-current {
    background-color: #d1ecf1 !important;
    border-left: 4px solid #0c5460;
    font-weight: 500;
}

.station-current:hover {
    background-color: #bee5eb !important;
}

.train-position-indicator {
    background: none !important;
    border: none !important;
}

.train-position-indicator td {
    padding: 0 !important;
    border: none !important;
}

.position-line {
    height: 4px;
    background: linear-gradient(90deg, #f4c430 0%, #e6b800 100%);
    margin: 8px 0;
    position: relative;
    border-radius: 2px;
    box-shadow: 0 2px 4px rgba(244, 196, 48, 0.3);
}

.position-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.modal-footer {
    padding: 16px 24px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    text-align: center;
    border-radius: 0 0 8px 8px;
}

.transitdocs-link {
    display: inline-block;
    padding: 10px 20px;
    background-color: #0066cc;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.transitdocs-link:hover {
    background-color: #0052a3;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.error-message {
    color: #dc3545;
    text-align: center;
    padding: 20px;
}

/* Timezone Abbreviations in Modal */
.schedule-table .timezone-abbr {
    font-size: 0.75rem;
    color: #718096;
    font-weight: 500;
    margin-left: 4px;
    padding: 2px 6px;
    background: #f7fafc;
    border-radius: 3px;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
}

/* Distance Column */
.schedule-table .distance-cell {
    text-align: right;
    font-size: 0.9rem;
    white-space: nowrap;
    color: #2d3748;
    font-weight: 500;
}

.schedule-table .distance-miles {
    font-size: 0.75rem;
    color: #718096;
    font-weight: 400;
}

/* Train Alerts */
.train-alerts {
    margin-bottom: 20px;
}

.alert-box {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-left: 4px solid #ff9800;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 12px;
}

.alert-header {
    font-weight: 600;
    color: #856404;
    margin-bottom: 6px;
    font-size: 1rem;
}

.alert-description {
    color: #856404;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes splitFlapFlip {
    0% {
        transform: perspective(400px) rotateX(0deg);
        opacity: 1;
        box-shadow: 0 0 0 rgba(255, 203, 6, 0);
    }
    49% {
        transform: perspective(400px) rotateX(90deg);
        opacity: 0.3;
        box-shadow: 0 0 15px rgba(255, 203, 6, 0.8), inset 0 0 10px rgba(255, 203, 6, 0.4);
    }
    50% {
        transform: perspective(400px) rotateX(-90deg);
        opacity: 0.3;
        box-shadow: 0 0 15px rgba(255, 203, 6, 0.8), inset 0 0 10px rgba(255, 203, 6, 0.4);
    }
    100% {
        transform: perspective(400px) rotateX(0deg);
        opacity: 1;
        box-shadow: 0 0 0 rgba(255, 203, 6, 0);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(255, 193, 7, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 193, 7, 0.8);
    }
}

.train-position-indicator.position-moved {
    animation: slideDown 0.6s ease-out;
}

.station-completed.newly-completed {
    animation: splitFlapFlip 0.6s ease-in-out;
}

.time-changed {
    animation: splitFlapFlip 0.6s ease-in-out;
    display: inline-block;
    transform-style: preserve-3d;
}

.train-position-indicator .position-label {
    animation: pulseGlow 2s ease-in-out infinite;
}

/* Responsive design */
@media (max-width: 1200px) {
    .departures-table {
        font-size: 1rem;
    }
    
    .train-number {
        font-size: 1.1rem;
    }
    
    .time {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    
    .station-info {
        text-align: center;
        margin-top: 15px;
    }
    
    .logo h1 {
        font-size: 2rem;
    }
    
    .station-info h2 {
        font-size: 1.5rem;
    }
    
    .controls {
        flex-direction: column;
        gap: 15px;
        padding: 20px;
    }
    
    .control-group {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }
    
    .control-group select {
        width: 100%;
    }
    
    .station-search-container {
        flex-wrap: wrap;
    }
    
    #station-search {
        min-width: 0;
        flex: 1 1 100%;
    }
    
    .star-btn-compact,
    .location-btn-compact,
    .view-all-btn {
        flex-shrink: 0;
    }
    
    .view-all-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    .board {
        padding: 20px;
        overflow-x: auto;
    }
    
    .departures-table {
        font-size: 0.9rem;
    }
    
    .departures-table th,
    .departures-table td {
        padding: 12px 8px;
    }
    
    .train-number {
        font-size: 1rem;
    }
    
    .time {
        font-size: 0.9rem;
    }
}

/* Print styles for display screens */
@media print {
    body {
        background: white;
    }
    
    .controls {
        display: none;
    }
    
    .container {
        box-shadow: none;
    }
}
