/**
 * CTA Train Tracker - Frontend Styles
 */

/* CSS Custom Properties for easy theming */
:root {
    --cta-red: #c60c30;
    --cta-blue: #00a1de;
    --cta-brown: #62361b;
    --cta-green: #009b3a;
    --cta-orange: #f9461c;
    --cta-purple: #522398;
    --cta-pink: #e27ea6;
    --cta-yellow: #f9e300;
    --cta-gray: #565a5c;
    --cta-light-gray: #f5f5f5;
    --cta-border: #ddd;
    --cta-text: #333;
    --cta-text-light: #666;
    --cta-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Main container */
.cta-train-tracker {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--cta-shadow);
    overflow: hidden;
    max-width: 500px;
    margin: 20px 0;
}

/* Header */
.cta-tracker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
}

.cta-tracker-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cta-tracker-title::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.cta-tracker-refresh-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cta-tracker-refresh-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.cta-tracker-refresh-btn.loading svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Content area */
.cta-tracker-content {
    min-height: 100px;
}

/* Loading state */
.cta-tracker-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--cta-text-light);
    gap: 15px;
}

.cta-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--cta-light-gray);
    border-top-color: var(--cta-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Error state */
.cta-tracker-error {
    padding: 20px;
    background: #fef2f2;
    color: #dc2626;
    text-align: center;
    border-left: 4px solid #dc2626;
    margin: 10px;
    border-radius: 4px;
}

/* No arrivals */
.cta-tracker-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--cta-text-light);
}

.cta-tracker-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Arrivals list */
.cta-arrivals-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cta-arrival-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--cta-border);
    transition: background 0.2s ease;
}

.cta-arrival-item:last-child {
    border-bottom: none;
}

.cta-arrival-item:hover {
    background: var(--cta-light-gray);
}

/* Route indicator */
.cta-route-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    margin-right: 15px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.cta-route-indicator.route-red { background: var(--cta-red); }
.cta-route-indicator.route-blue { background: var(--cta-blue); }
.cta-route-indicator.route-brn { background: var(--cta-brown); }
.cta-route-indicator.route-g { background: var(--cta-green); }
.cta-route-indicator.route-org { background: var(--cta-orange); }
.cta-route-indicator.route-p { background: var(--cta-purple); }
.cta-route-indicator.route-pink { background: var(--cta-pink); }
.cta-route-indicator.route-y { 
    background: var(--cta-yellow); 
    color: #333;
}

/* Train info */
.cta-train-info {
    flex: 1;
    min-width: 0;
}

.cta-train-destination {
    font-weight: 600;
    color: var(--cta-text);
    margin: 0 0 4px 0;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cta-train-details {
    font-size: 13px;
    color: var(--cta-text-light);
    margin: 0;
}

.cta-train-details span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cta-train-details span::before {
    content: '•';
    margin: 0 6px;
}

.cta-train-details span:first-child::before {
    display: none;
}

/* Arrival time */
.cta-arrival-time {
    text-align: right;
    margin-left: 15px;
    flex-shrink: 0;
}

.cta-time-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--cta-text);
    line-height: 1;
}

.cta-time-value.approaching {
    color: var(--cta-green);
}

.cta-time-value.delayed {
    color: var(--cta-red);
}

.cta-time-unit {
    font-size: 12px;
    color: var(--cta-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cta-arrival-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cta-arrival-status.due {
    background: #dcfce7;
    color: #16a34a;
}

.cta-arrival-status.approaching {
    background: #fef3c7;
    color: #d97706;
}

.cta-arrival-status.delayed {
    background: #fef2f2;
    color: #dc2626;
}

.cta-arrival-status.scheduled {
    background: #e0e7ff;
    color: #4f46e5;
}

/* Footer */
.cta-tracker-footer {
    padding: 10px 20px;
    background: var(--cta-light-gray);
    border-top: 1px solid var(--cta-border);
    font-size: 12px;
    color: var(--cta-text-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cta-tracker-updated {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Station Selector Styles */
.cta-station-selector {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    max-width: 500px;
    margin: 20px 0;
}

.cta-selector-controls {
    margin-bottom: 20px;
}

.cta-selector-controls label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--cta-text);
}

.cta-station-select {
    width: 100%;
    padding: 12px 15px;
    font-size: 15px;
    border: 2px solid var(--cta-border);
    border-radius: 8px;
    background: #fff;
    color: var(--cta-text);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.cta-station-select:hover,
.cta-station-select:focus {
    border-color: var(--cta-blue);
    outline: none;
}

.cta-station-select optgroup {
    font-weight: 700;
    color: var(--cta-text);
}

.cta-select-prompt {
    padding: 40px 20px;
    text-align: center;
    color: var(--cta-text-light);
    background: var(--cta-light-gray);
    border-radius: 8px;
    border: 2px dashed var(--cta-border);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .cta-tracker-header {
        padding: 12px 15px;
    }
    
    .cta-tracker-title {
        font-size: 16px;
    }
    
    .cta-arrival-item {
        padding: 12px 15px;
    }
    
    .cta-route-indicator {
        width: 35px;
        height: 35px;
        font-size: 12px;
        margin-right: 12px;
    }
    
    .cta-time-value {
        font-size: 20px;
    }
    
    .cta-train-destination {
        font-size: 14px;
    }
    
    .cta-train-details {
        font-size: 12px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .cta-train-tracker {
        background: #1f2937;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .cta-arrival-item {
        border-bottom-color: #374151;
    }
    
    .cta-arrival-item:hover {
        background: #374151;
    }
    
    .cta-train-destination,
    .cta-time-value {
        color: #f3f4f6;
    }
    
    .cta-train-details,
    .cta-time-unit {
        color: #9ca3af;
    }
    
    .cta-tracker-footer {
        background: #111827;
        border-top-color: #374151;
        color: #9ca3af;
    }
    
    .cta-station-select {
        background: #1f2937;
        border-color: #374151;
        color: #f3f4f6;
    }
    
    .cta-select-prompt {
        background: #1f2937;
        border-color: #374151;
        color: #9ca3af;
    }
}

/* Print styles */
@media print {
    .cta-tracker-refresh-btn {
        display: none;
    }
    
    .cta-train-tracker {
        box-shadow: none;
        border: 1px solid #000;
    }
}
