/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #ffffff 0%, #ffffff 100%, #ffffff 100%, #ffffff 75%, #ffffff 100%);
    background-size: 400% 400%;
    animation: subtleBackgroundShift 20s ease-in-out infinite;
    color: #1e293b;
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

@keyframes subtleBackgroundShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(79, 70, 229, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(14, 165, 233, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(124, 58, 237, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* Dashboard Layout */
.dashboard-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Top Header */
.top-header {
    background: linear-gradient(135deg,
        rgba(255,255,255,0.95) 0%,
        rgba(255,255,255,0.85) 25%,
        rgba(248,250,252,0.9) 50%,
        rgba(255,255,255,0.85) 75%,
        rgba(255,255,255,0.95) 100%);
    background-size: 200% 200%;
    animation: headerShimmer 8s ease-in-out infinite;
    padding: 0 28px;
    height: 82px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1400;
    backdrop-filter: blur(20px) saturate(180%);
    box-shadow:
        0 8px 32px rgba(6,11,34,0.12),
        0 2px 8px rgba(6,11,34,0.08),
        inset 0 -1px 0 rgba(255,255,255,0.1),
        inset 0 1px 0 rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.2);
    position: relative;
    overflow: hidden;
}

@keyframes headerShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.top-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(79,70,229,0.02) 50%,
        transparent 100%);
    animation: headerGlow 12s ease-in-out infinite;
    z-index: -1;
}

@keyframes headerGlow {
    0% { left: -100%; }
    50% { left: 100%; }
    100% { left: -100%; }
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 20px;
}

.rta-logo {
    display: flex;
    align-items: center;
}

.rta-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap; /* keep logo and title on one line */
}

.rta-logo-img {
    height: 37px;
    width: auto;
    background: none; /* remove red background */
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-weight: normal;
    font-size: inherit;
    display: block;
}

.brand-title {
    margin-left: 18px;
    font-size: 18px;
    font-weight: 800;
    color: #04203a;
    display: inline-block;
    align-self: center;
}

.brand-title {
    white-space: nowrap; /* prevent breaking into multiple lines */
    line-height: 1;
    margin-left:30px;
}

.brand-tag { display:inline-block; font-size:11px; font-weight:700; color:#475569; margin-left:8px; background:rgba(14,165,233,0.06); padding:4px 8px; border-radius:8px }

/* Animated gradient accent behind header */
.top-header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 6px;
    background: linear-gradient(90deg,#0ea5e9,#7c3aed,#06b6d4);
    filter: blur(8px);
    opacity: 0.75;
    transform-origin: left center;
    animation: hdrSweep 6s linear infinite;
    z-index: 1401;
}

@keyframes hdrSweep { 0% { transform: translateX(-20%)} 50%{ transform: translateX(20%)} 100%{ transform: translateX(-20%)} }

/* CTA and header actions */
.header-actions { display:flex; align-items:center; gap:12px }
.btn-ghost.lang-btn { background: rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.04); padding:8px 10px; border-radius:10px; color:#04203a }
.btn-cta { background: linear-gradient(90deg,#2f31ff,#7c3aed); color:white; padding:10px 14px; border-radius:12px; border:none; font-weight:700; box-shadow:0 10px 30px rgba(47,49,255,0.18); cursor:pointer; transition: transform .18s ease, box-shadow .18s ease }
.btn-cta:hover { transform: translateY(-3px) scale(1.01); box-shadow:0 18px 40px rgba(47,49,255,0.22) }
.btn-icon { background: rgba(255,255,255,0.03); border:1px solid rgba(255,255,255,0.03); padding:8px 10px; border-radius:10px; color:#0f172a }
.btn-icon.notify { position:relative }
.notification-badge { position:absolute; top:-6px; right:-6px; background:#ff4d4f }

/* User avatar emphasis */
.user-trigger { padding:8px 10px; border-radius:10px; background: linear-gradient(90deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01)); border:1px solid rgba(255,255,255,0.03) }

/* responsive tweaks */
@media (max-width: 900px) {
    .brand-title { font-size:16px }
    .btn-cta { padding:8px 12px }
    .header-actions { gap:8px }
}

.ministry-logo {
    display: flex;
    align-items: center;
}

.ministry-logo-img {
    height: 45px;
    width: 45px;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin-right: 700px;
}

.breadcrumb-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #64748b;
    font-weight: 500;
    transition: color 0.2s;
}

.breadcrumb-link:hover {
    color: #4f46e5;
}

.breadcrumb-current {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4f46e5;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    margin-left: -280px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-icon {
    position: relative;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #64748b;
}

.btn-icon:hover {
    background: #f1f5f9;
    color: #475569;
}

.notification-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-dropdown {
    position: relative;
}

.user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-trigger:hover {
    background: #f1f5f9;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
}

/* Filter Bar under Header */
.filter-bar {
    background: linear-gradient(135deg, #ffffff, #ffffff);
    border-bottom: 1px solid #cbd5e1;
    padding: 16px 24px;
    position: sticky;
    top: 70px;
    z-index: 1000;
    box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.08);
}

.filter-bar-content {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

/* Beautiful Filter Dropdown */
.filter-dropdown-container {
    position: relative;
}

.filter-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: red;
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 20px -4px rgba(79, 70, 229, 0.4);
    position: relative;
    overflow: hidden;
}

.filter-dropdown-trigger::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s;
}

.filter-dropdown-trigger:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 35px -5px rgba(79, 70, 229, 0.5);
    background: linear-gradient(135deg, #ff0000, #ef4444, #ef4444);
}

.filter-dropdown-trigger:hover::before {
    left: 100%;
}

.filter-dropdown-trigger:active {
    transform: translateY(-1px) scale(1.01);
}

.filter-arrow {
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 14px;
}

.filter-dropdown-trigger.active {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 12px 30px -3px rgba(79, 70, 229, 0.6);
    background: linear-gradient(135deg, #ff0000, #ef4444, #ef4444);
}

.filter-dropdown-trigger.active .filter-arrow {
    transform: rotate(180deg);
}

.filter-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 900px;
    max-width: 95vw;
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    margin-top: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.filter-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.filter-dropdown-header {
    padding: 28px 28px 20px;
    border-bottom: 2px solid #f1f5f9;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
}

.filter-dropdown-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 6px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.filter-dropdown-header p {
    font-size: 15px;
    color: #64748b;
    margin-bottom: 16px;
    font-weight: 500;
}

.filter-dropdown-content {
    padding: 0 28px;
    overflow: hidden;
}

.filter-section h4 {
    .optimization-summary {
        position: absolute;
        right: 22px;
        top: 22px;
        width: 360px;
        background: rgba(255,255,255,0.96);
        border-radius: 10px;
        box-shadow: 0 8px 30px rgba(10,10,20,0.25);
        padding: 16px;
        transform-origin: top right;
        opacity: 0;
        pointer-events: none;
        /* defensive: ensure overlay is visible above map panes and not clipped */
        z-index: 99999 !important;
        will-change: transform, opacity;
    }
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 16px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
    padding: 0 4px;
}

/* Map legend and popup styles */
.map-legend {
    margin-top: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    position: relative;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: default;
    color: #334155;
    font-weight: 600;
}

.legend-dot {
    width: 12px;
    height: 12px;
    display: inline-block;
    border-radius: 50%;
}
.legend-dot.pre { background:#ff4d4f; }
.legend-dot.post { background:#1e90ff; }
.legend-dot.diff { background:#ff7a18; }

.legend-popup {
    position: absolute;
    top: 36px;
    right: 0;
    width: 220px;
    background: white;
    border: 1px solid #e6eefb;
    box-shadow: 0 10px 20px rgba(16,24,40,0.06);
    border-radius: 10px;
    padding: 10px;
    display: none; /* shown on hover via JS or CSS */
    z-index: 1200;
}

.map-legend:hover .legend-popup { display: block; }

.legend-chips { display:flex; gap:8px; margin-bottom:8px; flex-wrap:wrap; }
.chip { display:flex; gap:8px; align-items:center; padding:4px 6px; border-radius:6px; background:#f8fafc; }
.chip-dot { width:10px; height:10px; border-radius:50%; display:inline-block; }
.chip-dot.pre{ background:#ff4d4f } .chip-dot.post{ background:#1e90ff } .chip-dot.diff{ background:#ff7a18 }

.legend-actions { display:flex; gap:8px; }
.btn-small { padding:6px 8px; border-radius:6px; background:#eef2ff; border:1px solid #e2e8f0; cursor:pointer; font-weight:600; }
.btn-small:hover { background:#e6eaff }

/* pulse animation for diff markers */
.leaflet-interactive.pulse { animation: pulse 900ms ease-out infinite; }
@keyframes pulse { 0% { transform: scale(1); opacity:1 } 70% { transform: scale(1.6); opacity:0.35 } 100% { transform: scale(1.8); opacity:0 } }

/* small adjustments for toolbar added buttons */
.map-toolbar .tool-btn { padding:8px 10px; border-radius:6px; background:#fff; border:1px solid #e6eefb; cursor:pointer; }
.map-toolbar .tool-btn#loadOptimizedBtn { background: #f0f9ff }
.map-toolbar .tool-btn#clearOptimizedBtn { background: #fff0f0; border-color:#ffd7d7 }

/* Bus marker styles */
.bus-marker { display:block; }
.bus-shape { width:20px; height:12px; background: linear-gradient(90deg,#ff7a18,#ff4d4f); border-radius:4px; box-shadow:0 4px 10px rgba(0,0,0,0.2); transform: rotate(0deg); }
.bus-marker .bus-shape::after { content:''; display:block; width:6px; height:6px; background:#fff; border-radius:50%; margin-top:3px; margin-left:2px; opacity:0.9 }

/* Smooth transition for marker movement */
.leaflet-marker-icon { transition: transform 0.08s linear !important; }

/* Optimization summary box */
.optimization-summary {
    /* hidden by default; only visible when .show is added or aria-hidden=false */
    position: absolute;
    top: 14px;
    right: 14px;
    bottom: auto;
    width: 260px;
    z-index: 9999;
    pointer-events: none;
    display: none;
    opacity: 0;
}

.optimization-summary .opt-content {
    background: linear-gradient(90deg,#ffffff,#f8fafc);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(16,24,40,0.12);
    border: 1px solid rgba(99,102,241,0.06);
    padding: 10px 12px;
    transform: translateY(18px) scale(0.98);
    opacity: 0;
    transition: transform 340ms cubic-bezier(.22,.9,.28,1), opacity 340ms ease;
    font-size: 13px;
    position: relative;
    z-index: 10001; /* ensure above Leaflet panes */
    margin-left:-60px
}

/* Strong hero style for AI optimization summary */
.opt-strong {
    width: 360px;
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(245,249,255,0.96));
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 30px 60px rgba(2,6,23,0.18);
    border: 1px solid rgba(14,165,233,0.12);
    transform-origin: top right;
}

.opt-content.opt-strong { transform: translateY(0) scale(1); opacity: 1; }

.opt-top { display:flex; gap:12px; align-items:center }
.opt-ai-badge { width:52px; height:52px; display:flex; align-items:center; justify-content:center; border-radius:12px; background:linear-gradient(90deg,#06b6d4,#0ea5e9); box-shadow:0 12px 30px rgba(14,165,233,0.18); flex-shrink:0 }
/* AI badge SVG styling and animation */
.opt-ai-badge svg { width:44px; height:44px; display:block }
.opt-ai-badge svg text { fill: rgba(255,255,255,0.98); font-weight:800 }
.opt-ai-badge { animation: badgeFloat 4s ease-in-out infinite }
@keyframes badgeFloat { 0% { transform: translateY(0) } 50% { transform: translateY(-4px) } 100% { transform: translateY(0) } }
.opt-title { flex:1; display:flex; align-items:center; justify-content:space-between }
.opt-title-line { font-weight:800; color:#04203a; font-size:15px }
.opt-region { font-size:11px; color:#0ea5e9; margin-left:6px }

.opt-main { display:flex; gap:10px; margin-top:12px }
.opt-metric { flex:1; background:linear-gradient(90deg,#f8fafc,#ffffff); padding:10px; border-radius:10px; text-align:center; }
.opt-metric.small { flex:0.6 }
.metric-label { color:#475569; font-weight:600; font-size:12px }
.metric-value { font-weight:900; font-size:20px; color:#062b49 }

.opt-notes { margin-top:10px; background:#ffffff; border-radius:8px; padding:8px; border:1px solid #eef6fb; font-size:13px; color:#0f172a }
.notes-header { font-weight:700; margin-bottom:6px }
.notes-body { color:#334155 }

.opt-actions { margin-top:10px; display:flex; gap:8px; justify-content:flex-end }
.opt-actions .btn-small { background: linear-gradient(90deg,#0ea5e9,#06b6d4); color:white; border:none; padding:8px 10px; border-radius:8px; box-shadow:0 8px 20px rgba(14,165,233,0.14); }
.opt-actions .btn-small:nth-child(2) { background: white; color:#062b49; border:1px solid #e6eefb }

/* Strong entrance animation */
@keyframes optEntrance { 0% { transform: translateY(-20px) scale(.95); opacity:0 } 60% { transform: translateY(6px) scale(1.02); opacity:1 } 100% { transform: translateY(0) scale(1); } }
.optimization-summary.show { display: block; pointer-events: auto; opacity: 1 }
.optimization-summary.show .opt-content.opt-strong { animation: optEntrance 520ms cubic-bezier(.22,.9,.28,1); }
.optimization-summary.show .opt-content { transform: translateY(0) scale(1); opacity: 1 }

/* When the summary is moved to the document body and positioned fixed, ensure
   it keeps its look and clickability. */
body > .optimization-summary {
    position: fixed !important;
    pointer-events: auto !important;
    display: block !important;
    z-index: 2147483647 !important;
}

.opt-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px }
.opt-header strong { font-size:14px; color:#0f172a }
.opt-close { background:none; border:none; font-size:16px; cursor:pointer }
.opt-body { display:flex; flex-direction:column; gap:6px }
.opt-row { display:flex; justify-content:space-between; align-items:center }
.opt-label { color:#475569; font-weight:600; font-size:12px }
.opt-value { font-weight:800; color:#0f172a; font-size:13px }
.opt-footer { margin-top:10px; display:flex; justify-content:flex-end }

/* strong pulse/glow for values */
.opt-value { position:relative }
.opt-value::after { content:''; position:absolute; inset:-6px; border-radius:8px; background: radial-gradient(circle, rgba(30,144,255,0.12), rgba(30,144,255,0)); opacity:0; transition: opacity 300ms }
.optimization-summary.show .opt-value::after { opacity:1 }

/* make sure map container can host absolute overlays */
#map { position: relative; }

/* Also show when aria-hidden is false (some scripts toggle aria instead of class) */
.optimization-summary[aria-hidden="false"] .opt-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.form-input {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: all 0.2s;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.date-inputs, .time-inputs, .stops-inputs {
    display: flex;
    gap: 8px;
    width: 100%;
}

.date-inputs input, .time-inputs input, .stops-inputs input {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
}

.filter-dropdown-footer {
    padding: 28px;
    border-top: 2px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
}

.btn-secondary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: #f8fafc;
    color: #64748b;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-secondary:hover {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #0e03d4, #7c3aed);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 20px -4px rgba(79, 70, 229, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px -5px rgba(79, 70, 229, 0.5);
    background: linear-gradient(135deg, #5b21b6, #6d28d9);
}

/* Dashboard Content */
.dashboard-content {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Routes Section */
.routes-section {
    background: linear-gradient(135deg,
        rgba(255,255,255,0.98) 0%,
        rgba(248,250,252,0.95) 50%,
        rgba(255,255,255,0.98) 100%);
    background-size: 200% 200%;
    animation: cardShimmer 15s ease-in-out infinite;
    border-radius: 16px;
    padding: 28px;
    box-shadow:
        0 8px 32px rgba(6,11,34,0.08),
        0 2px 8px rgba(6,11,34,0.04),
        inset 0 1px 0 rgba(255,255,255,0.6);
    border: 1px solid rgba(226,232,240,0.8);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

@keyframes cardShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.routes-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #4f46e5, #7c3aed, #0ea5e9, #06b6d4);
    border-radius: 16px 16px 0 0;
    z-index: 1;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 20px;
}

.section-title-area {
    flex: 1;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.section-subtitle {
    font-size: 14px;
    color: #64748b;
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-filter:hover {
    background: #f1f5f9;
    color: #475569;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-container i {
    position: absolute;
    left: 12px;
    color: #9ca3af;
    font-size: 14px;
}

.search-input {
    padding: 8px 12px 8px 36px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    width: 200px;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.data-table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
    color: #1e293b;
}

.data-table tbody tr:hover {
    background: #f8fafc;
    transform: scale(1.01);
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.data-table tbody tr {
    transition: all 0.2s ease;
}

.data-table tbody tr.newly-added {
    animation: slideInFromLeft 0.5s ease forwards;
    background: rgba(59, 130, 246, 0.05);
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.route-name {
    font-weight: 600;
    color: #4f46e5;
}

.direction-up {
    padding: 4px 8px;
    background: #dcfce7;
    color: #166534;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.direction-down {
    padding: 4px 8px;
    background: #fecaca;
    color: #dc2626;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.direction-all {
    padding: 4px 8px;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.summary-row {
    background: #f8fafc;
    border-top: 2px solid #e2e8f0;
}

.summary-row td {
    font-weight: 600;
    color: #1e293b;
}

.summary-row .route-name {
    color: #6b7280;
}

.status-label {
    padding: 4px 8px;
    background: #f3f4f6;
    color: #374151;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Optimization Section */
.optimization-section {
    background: linear-gradient(135deg,
        rgba(255,255,255,0.98) 0%,
        rgba(248,250,252,0.95) 50%,
        rgba(255,255,255,0.98) 100%);
    background-size: 200% 200%;
    animation: cardShimmer 18s ease-in-out infinite;
    border-radius: 16px;
    padding: 28px;
    box-shadow:
        0 8px 32px rgba(6,11,34,0.08),
        0 2px 8px rgba(6,11,34,0.04),
        inset 0 1px 0 rgba(255,255,255,0.6);
    border: 1px solid rgba(226,232,240,0.8);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.optimization-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #7c3aed, #0ea5e9, #06b6d4, #4f46e5);
    border-radius: 16px 16px 0 0;
    z-index: 1;
}

.optimization-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.optimization-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.optimization-actions {
    display: flex;
    gap: 12px;
}

.btn-danger {
    padding: 10px 20px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-light {
    padding: 10px 16px;
    background: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-light:hover {
    background: #f1f5f9;
    color: #475569;
}

.optimization-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.config-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.config-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-card label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.constraints-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.constraint-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    background: #f8fafc;
    transition: all 0.2s;
}

.constraint-card.active {
    border-color: #4f46e5;
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.constraint-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.constraint-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e2e8f0;
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4f46e5;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.constraint-label {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
}

.expand-btn {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.expand-btn:hover {
    background: #f1f5f9;
    color: #475569;
}

.constraint-content {
    display: none;
    gap: 16px;
}

.constraint-content.expanded {
    display: flex;
    flex-direction: column;
}

.range-inputs {
    display: flex;
    gap: 8px;
}

.range-inputs input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.weight-control {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.weight-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.weight-slider:hover {
    opacity: 1;
}

.weight-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4f46e5;
    cursor: pointer;
}

.weight-value {
    font-weight: 600;
    color: #4f46e5;
    min-width: 40px;
}

/* KPIs Section */
.kpis-section {
    background: linear-gradient(135deg,
        rgba(255,255,255,0.98) 0%,
        rgba(248,250,252,0.95) 50%,
        rgba(255,255,255,0.98) 100%);
    background-size: 200% 200%;
    animation: cardShimmer 21s ease-in-out infinite;
    border-radius: 16px;
    padding: 28px;
    box-shadow:
        0 8px 32px rgba(6,11,34,0.08),
        0 2px 8px rgba(6,11,34,0.04),
        inset 0 1px 0 rgba(255,255,255,0.6);
    border: 1px solid rgba(226,232,240,0.8);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.kpis-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #06b6d4, #0ea5e9, #4f46e5, #7c3aed);
    border-radius: 16px 16px 0 0;
    z-index: 1;
}

.kpis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.kpis-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.kpis-tabs {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
}

.kpis-tab {
    padding: 8px 16px;
    background: transparent;
    color: #64748b;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.kpis-tab.active {
    background: white;
    color: #1e293b;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.kpis-content {
    display: flex;
    gap: 24px;
    height: 600px;
}

.stops-panel {
    width: 320px;
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

.stops-header h4 {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.stops-header p {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 20px;
    line-height: 1.4;
}

.trips-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 16px;
    background: #e2e8f0;
    padding: 2px;
    border-radius: 8px;
}

.trip-tab {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    color: #64748b;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.trip-tab.active {
    background: #4f46e5;
    color: white;
}

.trips-subtabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
}

.trip-subtab {
    padding: 6px 12px;
    background: transparent;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.trip-subtab.active {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
}

.stops-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    margin-bottom: 16px;
    padding-right: 8px;
}

.stop-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}

.stop-item:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-color: #cbd5e1;
}

.stop-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.stop-circle.blue {
    background: #3b82f6;
}

.stop-circle.purple {
    background: #8b5cf6;
}

.stop-circle.green {
    background: #10b981;
}

.stop-circle.orange {
    background: #f59e0b;
}

.stop-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stop-name {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    line-height: 1.3;
}

.stop-time {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

.stops-summary {
    border-top: 1px solid #e2e8f0;
    padding-top: 12px;
    text-align: center;
}

.stops-count {
    font-size: 14px;
    font-weight: 600;
    color: #4f46e5;
}

.map-section {
    flex: 1;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.map-toolbar {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.tool-btn {
    width: 36px;
    height: 36px;
    background: white;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tool-btn:hover {
    background: #f8fafc;
    color: #475569;
    border-color: #cbd5e1;
}

.map-container {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #e0f2fe, #f0f9ff);
    position: relative;
    overflow: hidden;
}

/* Map background pattern */
.map-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(rgba(148, 163, 184, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    z-index: 1;
}

.map-legend {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #64748b;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.pre {
    background: #94a3b8;
}

.legend-dot.post {
    background: #3b82f6;
}

/* Add some map-like elements */
.map-container::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 100px;
    background: rgba(79, 70, 229, 0.1);
    border-radius: 20px;
    z-index: 2;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .filter-dropdown-menu {
        width: 750px;
    }
    
    .filter-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
    }
    
    .constraints-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .filter-bar {
        padding: 12px 16px;
    }
    
    .filter-dropdown-menu {
        width: 90vw;
        position: fixed;
        top: 150px;
        left: 5vw;
        transform: none;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .filter-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .filter-dropdown-trigger {
        padding: 12px 20px;
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: row;
        gap: 16px;
        height: auto;
        padding: 8px 0;
    }
    
    .filter-bar {
        padding: 10px 12px;
    }
    
    .filter-dropdown-menu {
        width: 95vw;
        position: fixed;
        top: 140px;
        left: 2.5vw;
        transform: none;
        max-height: 75vh;
        overflow-y: auto;
    }
    
    .filter-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .kpis-content {
        flex-direction: column;
        height: auto;
    }
    
    .stops-panel {
        width: 100%;
    }
    
    .map-section {
        height: 400px;
    }
    
    .logo-container {
        gap: 12px;
    }
    
    .rta-logo-img {
        height: 35px;
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .ministry-logo-img {
        height: 35px;
        width: 35px;
        font-size: 10px;
    }
}

/* Smooth animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.constraint-content.expanded {
    animation: slideIn 0.3s ease;
}

.filter-dropdown-menu.active {
    animation: fadeIn 0.3s ease;
}
