/* Performance Tracking Page Styles */

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

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

/* Station links */
.station-link {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s;
}

.station-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* Hide links in exports */
@media print {
    .station-link {
        color: inherit;
        text-decoration: none;
        pointer-events: none;
    }
}

.export-mode .station-link {
    color: inherit;
    text-decoration: none;
    pointer-events: none;
}

/* Current station progress indicator */
.current-station-row {
    border-left: 4px solid #FFCB06;
    background-color: rgba(255, 203, 6, 0.1);
}

.current-station-row td {
    font-weight: 600;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
header {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #2d3748;
}

.subtitle {
    font-size: 1.1rem;
    color: #718096;
    margin-bottom: 20px;
}

nav a {
    display: inline-block;
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

nav a:hover {
    background-color: #f7fafc;
}

/* AI Summary Section */
.ai-summary-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.ai-summary-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.ai-summary-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.ai-summary-text {
    color: white;
    font-size: 1.1rem;
    line-height: 1.5;
    font-weight: 500;
}

/* Statistics Section */
.stats-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.stats-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #2d3748;
}

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

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 25px;
    border-radius: 10px;
    text-align: center;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 8px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.stat-value.updating {
    animation: statPulse 0.6s ease-in-out;
}

@keyframes statPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Stats Toggle */
.stats-toggle {
    display: flex;
    gap: 10px;
    background: #f7fafc;
    padding: 4px;
    border-radius: 8px;
}

.toggle-label {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    color: #4a5568;
}

.toggle-label input[type="radio"] {
    display: none;
}

.toggle-label:hover {
    background: #e2e8f0;
}

.toggle-label input[type="radio"]:checked + span {
    font-weight: 600;
}

.toggle-label:has(input[type="radio"]:checked) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Filters Section */
.filters-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.filters-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #2d3748;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-weight: 500;
    margin-bottom: 8px;
    color: #4a5568;
    font-size: 0.9rem;
}

.filter-group input,
.filter-group select {
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: #667eea;
}

.filter-actions {
    display: flex;
    gap: 10px;
}

.btn-primary,
.btn-secondary,
.btn-details {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-details {
    background: #48bb78;
    color: white;
    padding: 6px 12px;
    font-size: 0.9rem;
}

.btn-details:hover {
    background: #38a169;
}

/* Results Section */
.results-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.results-header h2 {
    font-size: 1.5rem;
    color: #2d3748;
}

.result-count {
    color: #718096;
    font-size: 0.9rem;
}

.export-link {
    color: #718096;
    font-size: 0.85rem;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
}

.export-link:hover {
    color: #1e3c72;
    text-decoration: underline;
}

.export-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    min-width: 120px;
    z-index: 1000;
}

.export-menu a {
    display: block;
    padding: 10px 15px;
    color: #2d3748;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.export-menu a:hover {
    background-color: #f7fafc;
}

.export-menu a i {
    margin-right: 8px;
    width: 16px;
}

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

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

/* Error Message */
.error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 15px;
    border-radius: 6px;
    margin: 20px 0;
}

/* Table */
.journeys-table table,
.station-details-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.journeys-table th,
.journeys-table td,
.station-details-table th,
.station-details-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.journeys-table th,
.station-details-table th {
    background: #f7fafc;
    font-weight: 600;
    color: #4a5568;
    position: sticky;
    top: 0;
}

.journeys-table tbody tr:hover {
    background: #f7fafc;
}

.train-number {
    font-weight: 600;
    color: #667eea;
}

.route {
    color: #4a5568;
}

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

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-badge.completed {
    background: #c6f6d5;
    color: #22543d;
}

.status-badge.in-progress {
    background: #feebc8;
    color: #7c2d12;
}

.status-badge.not-started {
    background: #e2e8f0;
    color: #2d3748;
}

.status-badge.bus-replacement {
    background: #fed7aa;
    color: #9a3412;
}

.status-badge.cancelled {
    background: #fecaca;
    color: #991b1b;
}

/* Delay Indicators */
.delay-ontime {
    color: #22543d;
    font-weight: 500;
}

.delay-slight {
    color: #d69e2e;
    font-weight: 500;
}

.delay-major {
    color: #c53030;
    font-weight: 500;
}

/* 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;
}

.alert-timestamp {
    color: #856404;
    font-size: 0.8rem;
    font-style: italic;
    margin-top: 8px;
    opacity: 0.8;
    margin-right: 20px;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 40px;
    color: #718096;
    font-size: 1.1rem;
}

/* Timezone Abbreviations */
.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;
}

/* 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);
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s;
}

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

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

.modal-header h2 {
    font-size: 1.5rem;
    color: #2d3748;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-download {
    padding: 8px 16px;
    background-color: #FFCB06;
    color: #1e3c72;
    border: 2px solid #1e3c72;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-download:hover {
    background-color: #1e3c72;
    color: #FFCB06;
    transform: translateY(-2px);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #a0aec0;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #4a5568;
}

.train-selector-btn {
    padding: 10px 15px;
    background-color: #FFCB06;
    color: #1e3c72;
    border: 2px solid #1e3c72;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.train-selector-btn:hover {
    background-color: #1e3c72;
    color: #FFCB06;
    transform: translateY(-2px);
}

.train-selector-row:hover {
    background-color: #e6f2ff !important;
}

.modal-body {
    padding: 30px;
    max-height: 60vh;
    overflow-y: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .filters {
        grid-template-columns: 1fr;
    }
    
    .filter-actions {
        flex-direction: column;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .journeys-table {
        overflow-x: auto;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    header,
    .stats-section,
    .filters-section,
    .results-section {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-value {
        font-size: 2rem;
    }
}

/* Trip Replay Controls */
.replay-controls {
    background: #2d3748;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.replay-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

.replay-btn {
    background: #4299e1;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.replay-btn:hover {
    background: #3182ce;
}

.btn-replay {
    background: #9f7aea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    margin-right: 10px;
    transition: background 0.2s;
}

.btn-replay:hover {
    background: #805ad5;
}

.replay-select {
    background: #1a202c;
    color: white;
    border: 1px solid #4a5568;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.replay-info {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    color: #e2e8f0;
    font-size: 14px;
}

.replay-info span {
    padding: 8px 12px;
    background: #1a202c;
    border-radius: 4px;
}

.replay-timeline {
    margin-top: 10px;
}

.replay-slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #4a5568;
    outline: none;
    -webkit-appearance: none;
}

.replay-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4299e1;
    cursor: pointer;
}

.replay-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4299e1;
    cursor: pointer;
    border: none;
}

.train-marker {
    font-size: 24px;
    text-align: center;
    line-height: 30px;
    transition: transform 0.5s linear !important;
}

/* Smooth movement for Leaflet marker */
.leaflet-marker-icon {
    transition: transform 0.5s linear, margin-left 0.5s linear, margin-top 0.5s linear !important;
}

/* Column Toggle */
.column-toggle-wrapper {
    position: relative;
    display: inline-block;
}

.btn-columns {
    padding: 6px 14px;
    background: #f7fafc;
    color: #4a5568;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-columns:hover {
    border-color: #667eea;
    color: #667eea;
}

.btn-columns.active {
    border-color: #667eea;
    background: #ebf0ff;
    color: #667eea;
}

.column-toggle-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    z-index: 1000;
    padding: 8px 0;
}

.column-toggle-menu label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.88rem;
    color: #2d3748;
    transition: background 0.15s;
    user-select: none;
}

.column-toggle-menu label:hover {
    background: #f7fafc;
}

.column-toggle-menu label input[type="checkbox"] {
    accent-color: #667eea;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.column-toggle-menu .toggle-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 4px 0;
}

.column-toggle-menu .toggle-header {
    padding: 6px 16px 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Time column styling */
.col-time {
    font-size: 0.88rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.col-time .time-date {
    font-size: 0.75rem;
    color: #a0aec0;
    display: block;
    margin-top: 1px;
}

/* Direct replay button in actions column */
.btn-replay-direct {
    background: #9f7aea;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    margin-left: 8px;
    transition: background 0.2s;
    vertical-align: middle;
}

.btn-replay-direct:hover {
    background: #805ad5;
    transform: scale(1.05);
}
