:root {
    --primary: #007bff;
    --primary-dark: #0056b3;
    --accent: #ff9800;
    --bg-light: #f4f7f6;
    --bg-dark: #121212;
    --card-light: #ffffff;
    --card-dark: #1e1e1e;
    --text-light: #333333;
    --text-dark: #e0e0e0;
    --glass: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --bg-body: var(--bg-dark);
    --card-bg: var(--card-dark);
    --text-main: var(--text-dark);
    --input-bg: #2d2d2d;
    --border-color: #333;
}

[data-theme="light"] {
    --bg-body: var(--bg-light);
    --card-bg: var(--card-light);
    --text-main: var(--text-light);
    --input-bg: #fff;
    --border-color: #ddd;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: var(--transition);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
}

a {
    text-decoration: none;
    color: var(--primary);
    transition: var(--transition);
}

a:hover {
    color: var(--accent);
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header/Nav */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 2rem;
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(var(--bg-body), 0.8);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
}

.theme-toggle:hover {
    background-color: var(--glass);
}

/* Cards & Glassmorphism */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.glass-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Forms - Premium Inputs */
.search-box {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.input-group {
    display: flex;
    gap: 10px;
}

input[type="text"], input[type="number"] {
    width: 100%;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-main);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.1);
}

.btn {
    padding: 1rem 2rem;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:hover {
    filter: brightness(1.1);
    transform: scale(1.02);
}

.btn-secondary {
    background: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 0;
    background: radial-gradient(circle at center, rgba(0, 123, 255, 0.1) 0%, transparent 70%);
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-main);
    opacity: 0.8;
    margin-bottom: 2rem;
}

/* Train Status & Route */
.status-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
}

.status-ontime { background: rgba(40, 167, 69, 0.2); color: #28a745; }
.status-delayed { background: rgba(255, 152, 0, 0.2); color: #ff9800; }
.status-ended { background: rgba(220, 53, 69, 0.2); color: #dc3545; }

.station-list {
    list-style: none;
    position: relative;
    padding-left: 2rem;
}

.station-list::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.station-item {
    position: relative;
    padding-bottom: 2rem;
}

.station-item::after {
    content: '';
    position: absolute;
    left: -2.35rem; /* adjusted for padding */
    top: 5px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 3px solid var(--border-color);
    transition: var(--transition);
}

.station-item.active::after {
    border-color: var(--primary);
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.2);
}

.station-item.passed::after {
    border-color: var(--primary);
    background: var(--primary);
}

/* Map Display */
#map {
    height: 500px;
    width: 100%;
    border-radius: 16px;
    z-index: 1;
}

/* Loading Animation */
.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--border-color);
    border-bottom-color: var(--primary);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    margin: 2rem auto;
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* NEW ADDITIONS - Ticket Style & Progress */
.ticket-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 1.5rem;
    border-radius: 16px 16px 0 0;
    position: relative;
    overflow: hidden;
}

.ticket-header::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    right: 0;
    height: 20px;
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
}

.ticket-body {
    padding: 2rem;
    background: var(--card-bg);
    border-radius: 0 0 16px 16px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
    border-top: none;
}

.meta-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-type { background: rgba(255,255,255,0.2); color: white; }
.badge-class { background: var(--bg-light); color: var(--text-main); border: 1px solid var(--border-color); }

.progress-track {
    position: relative;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    margin: 2rem 0;
}
.progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--accent);
    border-radius: 4px;
    width: 0%; /* JS will animate */
    transition: width 1s ease;
}

.weather-box {
    text-align: right;
    background: rgba(255,255,255,0.2);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
}

/* PULSE ANIMATION & MAP POPUP (Restored) */
.pulse-icon {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pulse-ring {
    position: absolute;
    width: 60px;
    height: 60px;
    background: rgba(255, 152, 0, 0.4);
    border-radius: 50%;
    animation: pulse 2s infinite;
    z-index: -1;
}

@keyframes pulse {
    0% { transform: scale(0.5); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

.leaflet-popup-content-wrapper {
    background: var(--card-bg) !important;
    color: var(--text-main) !important;
    border-radius: 12px !important;
    box-shadow: var(--shadow) !important;
    padding: 0 !important;
    overflow: hidden;
}
.leaflet-popup-tip {
    background: var(--card-bg) !important;
}
.leaflet-popup-content {
    margin: 0 !important;
    padding: 1rem !important;
    font-family: 'Outfit', sans-serif !important;
}

/* --- PRELOADER (New) --- */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-body);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    transition: opacity 0.6s ease-out, visibility 0.6s ease-out;
}

.loader-content {
    text-align: center;
    position: relative;
}

.train-track-loader {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
}

.track-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 4px solid var(--border-color);
    border-radius: 50%;
    opacity: 0.3;
}

.train-spinner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spinTrack 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.train-icon-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    color: var(--accent);
    animation: bounceTrain 1s ease-in-out infinite alternate;
}

.loader-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

@keyframes spinTrack { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes bounceTrain { 0% { transform: translate(-50%, -45%); } 100% { transform: translate(-50%, -55%); } }

/* Admin Panel Specifics */
.admin-login-box {
    max-width: 400px;
    margin: 100px auto;
}
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}
.form-group {
    margin-bottom: 1.5rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}
.form-group textarea, .form-group input {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-main);
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .hero h1 {
        font-size: 2rem;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 1rem; }


/* PNR Card Styles */
.pnr-card {
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: 20px;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}
.pnr-header small {
    font-weight: 700;
    opacity: 0.6;
    letter-spacing: 1px;
}
.passenger-row:last-child {
    border-bottom: none !important;
}

/* Route Arrow Header */
.route-arrow-header {
    display: inline-flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.9;
    background: rgba(0,0,0,0.05);
    padding: 4px 10px;
    border-radius: 20px;
}
[data-theme='dark'] .route-arrow-header {
    background: rgba(255,255,255,0.1);
}
