/**
 * Routes Management CSS
 * Modern styling for Dominican Republic logistics and accounting system
 */

/* ===== PREMIUM ROUTE CARDS ===== */
.route-card {
    position: relative;
    overflow: visible; /* Changed to visible to allow action buttons to show properly */
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow:
        0 1px 3px 0 rgba(0, 0, 0, 0.1),
        0 1px 2px 0 rgba(0, 0, 0, 0.06);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0) scale(1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding-bottom: 70px; /* Increased space for action buttons */
    margin-bottom: 20px; /* Add margin to prevent overlap with other cards */
}

/* Dark mode route cards - Premium Design */
.dark .route-card {
    background: linear-gradient(135deg, 
        rgba(31, 41, 55, 0.95) 0%, 
        rgba(17, 24, 39, 0.98) 100%);
    border: 1px solid rgba(75, 85, 99, 0.3);
    box-shadow: 
        0 4px 20px -2px rgba(0, 0, 0, 0.4),
        0 2px 8px -2px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Premium gradient border effect */
.route-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, 
        #ef4444 0%, 
        #f97316 25%, 
        #eab308 50%, 
        #22c55e 75%, 
        #3b82f6 100%);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.route-card:hover::before {
    transform: scaleX(1);
}

/* Enhanced hover effects */
.route-card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 
        0 32px 64px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    border-color: rgba(99, 102, 241, 0.3);
}

.dark .route-card:hover {
    background: linear-gradient(135deg, 
        rgba(31, 41, 55, 0.98) 0%, 
        rgba(17, 24, 39, 1) 100%);
    box-shadow: 
        0 32px 64px -12px rgba(0, 0, 0, 0.6),
        0 8px 32px -8px rgba(99, 102, 241, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 0 0 1px rgba(99, 102, 241, 0.3);
}

/* Subtle inner glow effect */
.dark .route-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 0%, 
        rgba(99, 102, 241, 0.03) 0%, 
        transparent 50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.dark .route-card:hover::after {
    opacity: 1;
}

/* Additional sophisticated dark mode enhancements */
.dark .route-card {
    position: relative;
}

/* Animated background pattern for premium feel */
.dark .route-card:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(239, 68, 68, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 60%, rgba(34, 197, 94, 0.05) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
    z-index: 1;
}

.dark .route-card:hover:before {
    opacity: 1;
    animation: backgroundShift 8s ease-in-out infinite;
}

@keyframes backgroundShift {
    0%, 100% {
        background-image: 
            radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
            radial-gradient(circle at 80% 80%, rgba(239, 68, 68, 0.1) 0%, transparent 50%),
            radial-gradient(circle at 40% 60%, rgba(34, 197, 94, 0.05) 0%, transparent 50%);
    }
    33% {
        background-image: 
            radial-gradient(circle at 80% 20%, rgba(239, 68, 68, 0.1) 0%, transparent 50%),
            radial-gradient(circle at 20% 80%, rgba(34, 197, 94, 0.1) 0%, transparent 50%),
            radial-gradient(circle at 60% 40%, rgba(99, 102, 241, 0.05) 0%, transparent 50%);
    }
    66% {
        background-image: 
            radial-gradient(circle at 40% 80%, rgba(34, 197, 94, 0.1) 0%, transparent 50%),
            radial-gradient(circle at 60% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
            radial-gradient(circle at 80% 60%, rgba(239, 68, 68, 0.05) 0%, transparent 50%);
    }
}

/* Enhanced gradient border for dark mode */
.dark .route-card .route-card-border {
    background: linear-gradient(90deg, 
        #ef4444 0%, 
        #f97316 20%, 
        #eab308 40%, 
        #22c55e 60%, 
        #3b82f6 80%, 
        #8b5cf6 100%);
}

/* Enhanced glass morphism effect for dark mode ONLY */
.dark .route-card {
    background: linear-gradient(135deg, 
        rgba(31, 41, 55, 0.9) 0%, 
        rgba(17, 24, 39, 0.95) 50%,
        rgba(31, 41, 55, 0.9) 100%) !important;
    border: 1px solid rgba(75, 85, 99, 0.4) !important;
    box-shadow: 
        0 8px 32px -8px rgba(0, 0, 0, 0.5),
        0 2px 16px -4px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2) !important;
}

/* Premium hover state for dark mode ONLY */
.dark .route-card:hover {
    background: linear-gradient(135deg, 
        rgba(31, 41, 55, 0.95) 0%, 
        rgba(17, 24, 39, 1) 50%,
        rgba(31, 41, 55, 0.95) 100%) !important;
    box-shadow: 
        0 20px 40px -8px rgba(0, 0, 0, 0.7),
        0 8px 32px -8px rgba(99, 102, 241, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(99, 102, 241, 0.4) !important;
    transform: translateY(-16px) scale(1.03) !important;
}

/* Ensure card content appears above animated background */
.dark .route-card > * {
    position: relative;
    z-index: 2;
}

/* ===== LIGHT MODE ROUTE CARDS - Clean & Professional ===== */
.light .route-card,
html:not(.dark) .route-card {
    background: white !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: 
        0 1px 3px 0 rgba(0, 0, 0, 0.1), 
        0 1px 2px 0 rgba(0, 0, 0, 0.06) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.light .route-card:hover,
html:not(.dark) .route-card:hover {
    background: white !important;
    transform: translateY(-8px) scale(1.02) !important;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(99, 102, 241, 0.3) !important;
}

/* Disable animated background for light mode */
.light .route-card:before,
html:not(.dark) .route-card:before {
    display: none !important;
}

/* ===== ENHANCED COMPANY BADGES ===== */
.company-badge {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.company-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.3), 
        transparent);
    transition: left 0.6s ease;
}

.company-badge:hover::before {
    left: 100%;
}

.route-card:hover .company-badge {
    transform: scale(1.05);
}

/* ===== PREMIUM CURRENCY BREAKDOWN ===== */
.currency-breakdown {
    position: relative;
}

.currency-breakdown > div {
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* USD Section - Enhanced */
.currency-breakdown > div:first-child {
    background: linear-gradient(135deg, 
        rgba(34, 197, 94, 0.1) 0%, 
        rgba(22, 163, 74, 0.05) 100%);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.dark .currency-breakdown > div:first-child {
    background: linear-gradient(135deg, 
        rgba(34, 197, 94, 0.15) 0%, 
        rgba(22, 163, 74, 0.08) 100%);
    border: 1px solid rgba(34, 197, 94, 0.3);
    box-shadow: 
        inset 0 1px 0 rgba(34, 197, 94, 0.1),
        0 2px 8px rgba(34, 197, 94, 0.1);
}

/* RD Section - Enhanced */
.currency-breakdown > div:last-child {
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0.1) 0%, 
        rgba(37, 99, 235, 0.05) 100%);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.dark .currency-breakdown > div:last-child {
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0.15) 0%, 
        rgba(37, 99, 235, 0.08) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 
        inset 0 1px 0 rgba(59, 130, 246, 0.1),
        0 2px 8px rgba(59, 130, 246, 0.1);
}

.currency-breakdown > div:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px -8px rgba(0, 0, 0, 0.2);
}

.dark .currency-breakdown > div:hover {
    box-shadow: 0 8px 25px -8px rgba(0, 0, 0, 0.4);
}

/* Light mode currency breakdown */
.light .currency-breakdown > div,
html:not(.dark) .currency-breakdown > div {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.light .currency-breakdown > div:first-child,
html:not(.dark) .currency-breakdown > div:first-child {
    background: linear-gradient(135deg, 
        rgba(34, 197, 94, 0.1) 0%, 
        rgba(22, 163, 74, 0.05) 100%) !important;
    border: 1px solid rgba(34, 197, 94, 0.2) !important;
    box-shadow: none !important;
}

.light .currency-breakdown > div:last-child,
html:not(.dark) .currency-breakdown > div:last-child {
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0.1) 0%, 
        rgba(37, 99, 235, 0.05) 100%) !important;
    border: 1px solid rgba(59, 130, 246, 0.2) !important;
    box-shadow: none !important;
}

.light .currency-breakdown > div:hover,
html:not(.dark) .currency-breakdown > div:hover {
    box-shadow: 0 8px 25px -8px rgba(0, 0, 0, 0.2) !important;
}

/* ===== ENHANCED COMPANY BREAKDOWN ITEMS ===== */
.company-breakdown-item {
    position: relative;
    overflow: hidden;
    background: rgba(249, 250, 251, 0.8);
    border: 1px solid rgba(229, 231, 235, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.dark .company-breakdown-item {
    background: linear-gradient(135deg, 
        rgba(55, 65, 81, 0.7) 0%, 
        rgba(31, 41, 55, 0.9) 100%);
    border: 1px solid rgba(75, 85, 99, 0.5);
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.2);
}

.company-breakdown-item:hover {
    transform: translateX(4px);
    background: rgba(249, 250, 251, 1);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 
        0 4px 12px -2px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(99, 102, 241, 0.1);
}

/* Light mode company breakdown items */
.light .company-breakdown-item,
html:not(.dark) .company-breakdown-item {
    background: rgba(249, 250, 251, 0.8) !important;
    border: 1px solid rgba(229, 231, 235, 0.5) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.light .company-breakdown-item:hover,
html:not(.dark) .company-breakdown-item:hover {
    background: rgba(249, 250, 251, 1) !important;
    border-color: rgba(99, 102, 241, 0.3) !important;
    box-shadow: 
        0 4px 12px -2px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(99, 102, 241, 0.1) !important;
}

.dark .company-breakdown-item:hover {
    background: linear-gradient(135deg, 
        rgba(55, 65, 81, 0.9) 0%, 
        rgba(31, 41, 55, 1) 100%);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 
        0 4px 12px -2px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 0 0 1px rgba(99, 102, 241, 0.2);
}

/* ===== ENHANCED COMPANY PREFIX BADGES ===== */
.company-prefix-badge {
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.company-prefix-badge::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, 
        transparent 30%, 
        rgba(255, 255, 255, 0.3) 50%, 
        transparent 70%);
    transform: rotate(45deg);
    transition: all 0.6s ease;
    opacity: 0;
}

.company-prefix-badge:hover::before {
    animation: shimmer 0.8s ease-in-out;
}

.company-prefix-badge:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

@keyframes shimmer {
    0% { 
        opacity: 0; 
        transform: translateX(-100%) translateY(-100%) rotate(45deg); 
    }
    50% { 
        opacity: 1; 
    }
    100% { 
        opacity: 0; 
        transform: translateX(100%) translateY(100%) rotate(45deg); 
    }
}

/* ===== ENHANCED ROUTE ICONS ===== */
.route-icon {
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 4px 12px rgba(239, 68, 68, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.route-icon::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.3), 
        transparent);
    transition: left 0.6s ease;
}

.route-icon:hover::before {
    left: 100%;
}

.route-icon:hover {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 
        0 8px 25px rgba(239, 68, 68, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% {
        box-shadow: 
            0 8px 25px rgba(239, 68, 68, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
    50% {
        box-shadow: 
            0 12px 35px rgba(239, 68, 68, 0.6),
            inset 0 1px 0 rgba(255, 255, 255, 0.4),
            0 0 20px rgba(239, 68, 68, 0.3);
    }
}

/* ===== ENHANCED ACTION BUTTONS ===== */
.action-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 30 !important; /* Ensure buttons are always visible */
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Route card action buttons container - properly contained and elevated */
.route-card .flex.gap-1.items-center.flex-wrap {
    position: absolute;
    bottom: -10px; /* Position slightly outside card for better visibility */
    left: 16px;
    right: 16px;
    z-index: 50 !important; /* Higher z-index to ensure visibility above company list */
    pointer-events: auto !important;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 10px;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.15),
        0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Dark mode support for action buttons container */
.dark .route-card .flex.gap-1.items-center.flex-wrap {
    background: rgba(31, 41, 55, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Ensure company list doesn't interfere with action buttons */
.route-card .company-section {
    position: relative;
    z-index: 10 !important;
    margin-bottom: 20px; /* Add space to prevent overlap with action buttons */
}

/* Company list items should have lower z-index than action buttons */
.route-card .company-section .company-item {
    position: relative;
    z-index: 15 !important;
}

/* Ensure action buttons are always clickable and prominent */
.route-card .action-btn {
    position: relative !important;
    z-index: 60 !important; /* Even higher z-index for individual buttons */
    pointer-events: auto !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border-radius: 8px !important;
    font-weight: 500 !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Enhanced hover effects for action buttons */
.route-card .action-btn:hover {
    transform: translateY(-2px) scale(1.05) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.action-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.action-btn:active::after {
    width: 120%;
    height: 120%;
    opacity: 0;
}

.action-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ===== ENHANCED LOADING STATES ===== */
.loading-placeholder {
    background: linear-gradient(90deg, 
        rgba(243, 244, 246, 0.8) 25%, 
        rgba(229, 231, 235, 0.8) 50%, 
        rgba(243, 244, 246, 0.8) 75%);
    background-size: 200% 100%;
    animation: loading-wave 1.5s infinite;
}

.dark .loading-placeholder {
    background: linear-gradient(90deg, 
        rgba(31, 41, 55, 0.8) 25%, 
        rgba(55, 65, 81, 0.8) 50%, 
        rgba(31, 41, 55, 0.8) 75%);
    background-size: 200% 100%;
}

@keyframes loading-wave {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== ENHANCED STATUS INDICATORS ===== */
.status-indicator {
    position: relative;
    overflow: hidden;
}

.status-indicator::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.4), 
        transparent);
    animation: status-pulse 2s infinite;
}

@keyframes status-pulse {
    0%, 100% { left: -100%; opacity: 0; }
    50% { left: 100%; opacity: 1; }
}

/* ===== ENHANCED EXCHANGE RATE INFO ===== */
.exchange-rate-info {
    position: relative;
    padding: 8px 12px;
    border-radius: 8px;
    background: linear-gradient(135deg, 
        rgba(99, 102, 241, 0.1) 0%, 
        rgba(79, 70, 229, 0.05) 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.dark .exchange-rate-info {
    background: linear-gradient(135deg, 
        rgba(99, 102, 241, 0.15) 0%, 
        rgba(79, 70, 229, 0.08) 100%);
    border: 1px solid rgba(99, 102, 241, 0.3);
    box-shadow: 
        inset 0 1px 0 rgba(99, 102, 241, 0.1),
        0 2px 8px rgba(99, 102, 241, 0.1);
}

.exchange-rate-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        transparent 30%, 
        rgba(99, 102, 241, 0.1) 50%, 
        transparent 70%);
    animation: gradient-shift 3s ease-in-out infinite;
    opacity: 0.5;
}

@keyframes gradient-shift {
    0%, 100% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
}

/* ===== ENHANCED FORM ELEMENTS ===== */
.quick-add-form input:focus {
    box-shadow:
        0 0 0 3px rgba(99, 102, 241, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: rgba(99, 102, 241, 0.5);
}

/* Ensure currency inputs stay side by side */
.quick-add-form .grid.grid-cols-2 {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
}

.quick-add-form .grid.grid-cols-2 > div {
    min-width: 0; /* Prevent flex items from overflowing */
}

.quick-add-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.quick-add-form button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ===== ENHANCED MODALS ===== */
.modal {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

@keyframes modal-backdrop-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal > div {
    animation: modal-content-slide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modal-content-slide {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ===== ENHANCED SCROLLBARS ===== */
.overflow-y-auto::-webkit-scrollbar {
    width: 8px;
}

.overflow-y-auto::-webkit-scrollbar-track {
    background: rgba(243, 244, 246, 0.5);
    border-radius: 4px;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.7);
    border-radius: 4px;
}

.overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: rgba(107, 114, 128, 0.9);
}

.dark .overflow-y-auto::-webkit-scrollbar-track {
    background: rgba(31, 41, 55, 0.5);
}

.dark .overflow-y-auto::-webkit-scrollbar-thumb {
    background: rgba(75, 85, 99, 0.7);
}

.dark .overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: rgba(107, 114, 128, 0.9);
}

/* ===== FOCUS AND SELECTION STYLES ===== */
*:focus {
    outline: 2px solid rgba(99, 102, 241, 0.5);
    outline-offset: 2px;
}

::selection {
    background: rgba(99, 102, 241, 0.2);
    color: inherit;
}

.dark ::selection {
    background: rgba(99, 102, 241, 0.3);
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.route-card,
.company-breakdown-item,
.currency-breakdown > div,
.action-btn,
.company-prefix-badge,
.route-icon {
    will-change: transform;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    .route-card,
    .company-breakdown-item,
    .currency-breakdown > div,
    .action-btn,
    .company-prefix-badge,
    .route-icon,
    .loading-placeholder,
    .notification,
    .empty-state {
        animation: none !important;
        transition: none !important;
    }
    
    .route-card:hover {
        transform: none !important;
    }
    
    .loading-placeholder {
        background: rgba(243, 244, 246, 0.8) !important;
    }
}

@media (prefers-contrast: high) {
    .route-card {
        border-width: 2px;
        border-color: #000;
    }
    
    .company-prefix-badge {
        border: 2px solid #000;
    }
    
    .currency-breakdown > div {
        border-width: 2px;
    }
}

/* ===== MODAL Z-INDEX FIXES ===== */
.fixed.inset-0.bg-black {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Ensure modal content is always clickable */
.modal-content,
#route-details-modal .bg-white,
#route-details-modal .dark\\:bg-gray-800,
#add-invoice-modal .bg-white,
#add-invoice-modal .dark\\:bg-gray-800 {
    pointer-events: auto !important;
    position: relative;
}

/* ===== ENHANCED SEARCH STYLES ===== */

/* Search loading animation */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Invoice search result highlighting */
.invoice-search-result {
    border: 2px solid #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
    position: relative;
}

.invoice-search-result::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #3b82f6, #1d4ed8, #3b82f6);
    border-radius: 12px;
    z-index: -1;
    animation: searchGlow 2s ease-in-out infinite alternate;
}

@keyframes searchGlow {
    0% { opacity: 0.3; }
    100% { opacity: 0.6; }
}

/* Invoice found indicator */
.invoice-found-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

/* Enhanced search input styling */
#search-routes:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

/* Search results info styling */
.search-results-info {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border: 1px solid #93c5fd;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    animation: slideInDown 0.3s ease-out;
}

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

/* Dark mode support for search features */
.dark .invoice-search-result {
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1) !important;
}

.dark .invoice-search-result::before {
    background: linear-gradient(45deg, #60a5fa, #3b82f6, #60a5fa);
}

.dark .search-results-info {
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
    border-color: #3b82f6;
    color: white;
}

/* Responsive search indicators */
@media (max-width: 768px) {
    .invoice-found-indicator {
        position: static;
        margin-top: 8px;
    }

    .invoice-search-result::before {
        border-radius: 8px;
    }
}

/* Ensure all modal buttons and interactive elements are clickable */
#route-details-modal button,
#route-details-modal input,
#route-details-modal select,
#route-details-modal textarea,
#route-details-modal a,
#route-details-modal [onclick],
#route-details-modal .action-btn,
#route-details-modal .toggle-btn,
#route-details-modal .fa,
#route-details-modal i,
#add-invoice-modal button,
#add-invoice-modal input,
#add-invoice-modal select,
#add-invoice-modal textarea,
#add-invoice-modal a,
#add-invoice-modal [onclick],
#return-comment-modal button,
#return-comment-modal [onclick] {
    pointer-events: auto !important;
    position: relative;
    z-index: 1;
    cursor: pointer;
}

/* Force modal containers to be clickable */
#route-details-modal,
#route-details-modal > div,
#route-details-modal .p-6,
#route-details-content,
#add-invoice-modal,
#add-invoice-modal > div,
#return-comment-modal,
#return-comment-modal > div,
#add-company-modal,
#add-company-modal > div {
    pointer-events: auto !important;
}

/* Add Company Modal - Higher z-index to appear above route details modal */
#add-company-modal {
    z-index: 20000 !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

#add-company-modal > div {
    z-index: 20001 !important;
    pointer-events: auto !important;
}

#add-company-modal button,
#add-company-modal .add-company-btn,
#add-company-modal .close-modal {
    z-index: 20002 !important;
    position: relative;
    pointer-events: auto !important;
    cursor: pointer;
}

#add-company-modal .add-company-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#add-company-modal .add-company-btn:active {
    transform: translateY(0);
}

/* ===== ENHANCED GRADIENT BUTTONS ===== */
.btn-gradient {
    background: linear-gradient(135deg, 
        #ef4444 0%, 
        #dc2626 50%, 
        #b91c1c 100%);
    box-shadow: 
        0 4px 12px rgba(239, 68, 68, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-gradient::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.2) 0%, 
        transparent 50%, 
        rgba(0, 0, 0, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-gradient:hover::before {
    opacity: 1;
}

.btn-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 25px rgba(239, 68, 68, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-gradient:active {
    transform: translateY(0);
    box-shadow: 
        0 2px 8px rgba(239, 68, 68, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* ===== ENHANCED LOADING SPINNER ===== */
.loading-spinner {
    animation: spin 1s linear infinite;
}

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

/* ===== ENHANCED STATS CARDS ===== */
.stats-card {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.9) 0%, 
        rgba(249, 250, 251, 0.9) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stats-card:hover {
    transform: translateY(-4px);
    box-shadow: 
        0 20px 40px -12px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* ===== ENHANCED FORM INPUTS ===== */
.form-input {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.form-input:focus {
    transform: translateY(-1px);
    box-shadow: 
        0 8px 25px -8px rgba(99, 102, 241, 0.2),
        0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ===== ENHANCED CHECKBOXES ===== */
.form-checkbox:checked {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    box-shadow: 
        0 2px 4px rgba(59, 130, 246, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* ===== ENHANCED SEARCH CONTAINER ===== */
.search-container {
    position: relative;
    overflow: hidden;
}

.search-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(99, 102, 241, 0.05) 0%, 
        rgba(79, 70, 229, 0.02) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.search-container:focus-within::before {
    opacity: 1;
}

/* ===== ENHANCED INVOICE ITEMS ===== */
.invoice-item {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.invoice-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(99, 102, 241, 0.1), 
        transparent);
    transition: left 0.6s ease;
}

.invoice-item:hover::before {
    left: 100%;
}

.invoice-item:hover {
    transform: translateX(4px);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(99, 102, 241, 0.2);
}

/* ===== ENHANCED COMPANY SECTIONS ===== */
.company-section {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.company-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(99, 102, 241, 0.02) 0%, 
        transparent 50%, 
        rgba(79, 70, 229, 0.02) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.company-section:hover::before {
    opacity: 1;
}

/* ===== ENHANCED NOTIFICATIONS ===== */
.notification {
    animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 99999 !important; /* Highest z-index to appear above all modals */
    position: fixed !important;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification.removing {
    animation: slideOutRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 99999 !important;
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ===== ENHANCED EMPTY STATE ===== */
.empty-state {
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== ENHANCED ROUTES GRID ===== */
.routes-grid .route-card {
    animation: fadeInScale 0.6s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.routes-grid .route-card:nth-child(1) { animation-delay: 0.1s; }
.routes-grid .route-card:nth-child(2) { animation-delay: 0.2s; }
.routes-grid .route-card:nth-child(3) { animation-delay: 0.3s; }
.routes-grid .route-card:nth-child(4) { animation-delay: 0.4s; }
.routes-grid .route-card:nth-child(5) { animation-delay: 0.5s; }
.routes-grid .route-card:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(30px) rotateX(15deg);
        filter: blur(10px);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05) translateY(-5px) rotateX(0deg);
        filter: blur(2px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0) rotateX(0deg);
        filter: blur(0px);
    }
}

/* ===== MOBILE RESPONSIVE ENHANCEMENTS ===== */
@media (max-width: 768px) {
    .route-card {
        border-radius: 12px;
    }
    
    .route-card:hover {
        transform: translateY(-4px) scale(1.01);
    }
    
    .stats-card {
        border-radius: 12px;
    }
    
    .company-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    .modal-content {
        margin: 1rem;
        border-radius: 16px;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
}

@media (max-width: 640px) {
    .routes-header {
        padding: 1rem;
        border-radius: 12px;
        margin-bottom: 1rem;
    }
    
    .stats-container {
        gap: 0.75rem;
    }
    
    .action-bar {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .search-filters {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ===== THEME-SPECIFIC OVERRIDES ===== */
@media (prefers-color-scheme: dark) {
    .route-card {
        background: linear-gradient(135deg, 
            rgba(31, 41, 55, 0.95) 0%, 
            rgba(17, 24, 39, 0.98) 100%);
        border-color: rgba(75, 85, 99, 0.3);
    }
    
    .stats-card {
        background: linear-gradient(135deg, 
            rgba(31, 41, 55, 0.9) 0%, 
            rgba(17, 24, 39, 0.9) 100%);
    }
    
    .company-badge {
        box-shadow: 
            0 2px 8px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
}

/* ===== REDUCED MOTION SUPPORT ===== */
@media (prefers-reduced-motion: reduce) {
    .route-card,
    .company-breakdown-item,
    .currency-breakdown > div,
    .action-btn,
    .company-prefix-badge,
    .route-icon,
    .loading-placeholder,
    .notification,
    .empty-state {
        animation: none !important;
        transition: none !important;
    }
    
    .route-card:hover {
        transform: none !important;
    }
    
    .loading-placeholder {
        background: rgba(243, 244, 246, 0.8) !important;
    }
}

/* ===== FOCUS VISIBLE ENHANCEMENTS ===== */
.route-card:focus-visible,
.action-btn:focus-visible,
.company-breakdown-item:focus-visible {
    outline: 2px solid rgba(99, 102, 241, 0.8);
    outline-offset: 2px;
    box-shadow: 
        0 0 0 4px rgba(99, 102, 241, 0.2),
        0 8px 25px rgba(0, 0, 0, 0.15);
}

/* ===== ROUTE ID BADGE STYLING ===== */
.route-id-badge {
    position: relative;
    overflow: hidden;
    animation: badge-glow 2s ease-in-out infinite alternate;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}

.route-id-badge::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, 
        transparent 30%, 
        rgba(255, 255, 255, 0.3) 50%, 
        transparent 70%);
    transform: rotate(45deg);
    transition: all 0.6s ease;
    opacity: 0;
}

.route-id-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.3);
}

.route-id-badge:hover::before {
    animation: shimmer-badge 0.8s ease-in-out;
}

@keyframes badge-glow {
    0% {
        box-shadow: 0 2px 4px rgba(220, 38, 38, 0.2);
    }
    100% {
        box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4), 0 0 12px rgba(220, 38, 38, 0.1);
    }
}

@keyframes shimmer-badge {
    0% { 
        opacity: 0; 
        transform: translateX(-100%) translateY(-100%) rotate(45deg); 
    }
    50% { 
        opacity: 1; 
    }
    100% { 
        opacity: 0; 
        transform: translateX(100%) translateY(100%) rotate(45deg); 
    }
}

/* Dark mode route ID badge */
.dark .route-id-badge {
    box-shadow: 0 2px 4px rgba(248, 113, 113, 0.3);
    backdrop-filter: blur(12px);
    animation: badge-glow-dark 2s ease-in-out infinite alternate;
}

.dark .route-id-badge:hover {
    box-shadow: 0 4px 8px rgba(248, 113, 113, 0.4);
}

@keyframes badge-glow-dark {
    0% {
        box-shadow: 0 2px 4px rgba(248, 113, 113, 0.3);
    }
    100% {
        box-shadow: 0 2px 8px rgba(248, 113, 113, 0.5), 0 0 12px rgba(248, 113, 113, 0.2);
    }
}

/* Accessibility: Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .route-id-badge {
        animation: none;
    }
    
    .route-id-badge:hover {
        transform: none;
    }
}

/* ===== ENHANCED ADD INVOICE MODAL ===== */
#add-invoice-modal {
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
}

#add-invoice-modal .bg-gradient-to-r {
    position: relative;
    overflow: hidden;
}

#add-invoice-modal .bg-gradient-to-r::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        rgba(255, 255, 255, 0.1) 0%, 
        transparent 30%, 
        transparent 70%, 
        rgba(255, 255, 255, 0.1) 100%);
    animation: shimmer-modal 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes shimmer-modal {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
    100% { transform: translateX(100%); }
}

#add-invoice-modal input:focus,
#add-invoice-modal select:focus,
#add-invoice-modal textarea:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
    transform: translateY(-1px);
}

#add-invoice-modal button[type="submit"]:hover {
    box-shadow: 0 8px 25px -5px rgba(34, 197, 94, 0.4) !important;
}

#add-invoice-modal button[type="submit"]:active {
    transform: translateY(1px) !important;
    box-shadow: 0 4px 15px -3px rgba(34, 197, 94, 0.4) !important;
}

/* Dark mode enhancements for add invoice modal */
.dark #add-invoice-modal {
    background: rgba(0, 0, 0, 0.7) !important;
}

.dark #add-invoice-modal .bg-white {
    background: linear-gradient(135deg, 
        rgba(31, 41, 55, 0.95) 0%, 
        rgba(17, 24, 39, 0.98) 100%) !important;
    border: 1px solid rgba(75, 85, 99, 0.3) !important;
    box-shadow: 
        0 20px 40px -8px rgba(0, 0, 0, 0.6),
        0 8px 32px -8px rgba(99, 102, 241, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

.dark #add-invoice-modal input,
.dark #add-invoice-modal select,
.dark #add-invoice-modal textarea {
    background: rgba(55, 65, 81, 0.8) !important;
    border: 1px solid rgba(75, 85, 99, 0.4) !important;
}

.dark #add-invoice-modal input:focus,
.dark #add-invoice-modal select:focus,
.dark #add-invoice-modal textarea:focus {
    background: rgba(55, 65, 81, 1) !important;
    border-color: rgba(99, 102, 241, 0.6) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
}

/* Enhanced clickability styles */
#add-invoice-modal input,
#add-invoice-modal select,
#add-invoice-modal textarea,
#add-invoice-modal button {
    cursor: pointer !important;
    pointer-events: auto !important;
}

#add-invoice-modal input[type="text"],
#add-invoice-modal input[type="number"],
#add-invoice-modal textarea {
    cursor: text !important;
}

/* Loading state for submit button */
#add-invoice-modal button[type="submit"]:disabled {
    opacity: 0.7;
    cursor: not-allowed !important;
    transform: none !important;
}

#add-invoice-modal button[type="submit"] .fa-spinner {
    animation: spin 1s linear infinite;
}

/* Professional Header Styles */
.routes-header {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.9) 100%);
    border-radius: 16px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    padding: 24px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: all 0.3s ease;
    position: relative;
    z-index: 40; /* above route cards (default 0) but below modals (>=50) */
}

.dark .routes-header {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.9) 100%);
    border-color: rgba(71, 85, 105, 0.3);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

.routes-header:hover {
    box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.dark .routes-header:hover {
    box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

/* Stats Cards */
.routes-header .bg-white {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(226, 232, 240, 0.6);
    transition: all 0.2s ease;
}

.dark .routes-header .bg-white {
    background: rgba(30, 41, 59, 0.8) !important;
    border-color: rgba(71, 85, 105, 0.4);
}

.routes-header .bg-white:hover {
    background: rgba(255, 255, 255, 0.95) !important;
    border-color: rgba(226, 232, 240, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dark .routes-header .bg-white:hover {
    background: rgba(30, 41, 59, 0.95) !important;
    border-color: rgba(71, 85, 105, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Header Icon */
.routes-header .w-10.h-10 {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
    transition: all 0.3s ease;
}

.routes-header .w-10.h-10:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(239, 68, 68, 0.4);
}

/* Action Buttons Refinement */
.routes-header button,
.routes-header a {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.025em;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.routes-header button:hover,
.routes-header a:hover {
    transform: translateY(-1px);
}

/* Search and Filter Inputs */
.routes-header input,
.routes-header select {
    font-size: 14px;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
}

.dark .routes-header input,
.dark .routes-header select {
    background: rgba(30, 41, 59, 0.9);
}

.routes-header input:focus,
.routes-header select:focus {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}

.dark .routes-header input:focus,
.dark .routes-header select:focus {
    background: rgba(30, 41, 59, 1);
}

/* Status Text */
.routes-header .text-gray-500 {
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.025em;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .routes-header {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .routes-header .grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .routes-header .bg-white {
        padding: 12px;
    }
}

/* Animation for header elements */
.routes-header > * {
    animation: fadeInUp 0.6s ease-out;
}

.routes-header > *:nth-child(1) { animation-delay: 0.1s; }
.routes-header > *:nth-child(2) { animation-delay: 0.2s; }
.routes-header > *:nth-child(3) { animation-delay: 0.3s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Route highlighting for navigation from transactions */
.route-highlighted {
    position: relative;
    animation: route-highlight-pulse 2s ease-in-out;
    border: 3px solid #3b82f6 !important;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4) !important;
    transform: scale(1.02);
    z-index: 10;
}

.dark .route-highlighted {
    border-color: #60a5fa !important;
    box-shadow: 0 0 20px rgba(96, 165, 250, 0.3) !important;
}

.route-highlighted::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: linear-gradient(45deg, #3b82f6, #60a5fa, #3b82f6);
    border-radius: inherit;
    z-index: -1;
    animation: route-highlight-border 2s linear infinite;
}

@keyframes route-highlight-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(59, 130, 246, 0);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
    }
    100% {
        transform: scale(1.02);
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
    }
}

@keyframes route-highlight-border {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.route-highlighted .route-title {
    color: #1d4ed8 !important;
    font-weight: 700 !important;
}

.dark .route-highlighted .route-title {
    color: #60a5fa !important;
}

/* Ensure highlighted route appears above others */
.route-highlighted {
    z-index: 20 !important;
}

/* =============================================================
 * LIGHT MODE HEADER ACTION BUTTONS
 * Ensure primary buttons are visible on bright header background
 * ============================================================= */
html.light .routes-header button.bg-gradient-to-r,
html.light .routes-header a.bg-gradient-to-r {
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
}
html.light .routes-header button.bg-gradient-to-r:hover,
html.light .routes-header a.bg-gradient-to-r:hover {
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.35);
}

/* Refresh button – give it subtle red outline so it stands out */
html.light #refresh-routes-btn {
    background: transparent !important;
    border-color: rgba(220, 38, 38, 0.4) !important;
    color: #dc2626 !important;
}
html.light #refresh-routes-btn:hover {
    background: rgba(220, 38, 38, 0.06) !important;
}

/* =============================================================
 * COMPANY PICKER VISUAL SELECTION (create-route modal)
 * ============================================================= */
.company-checkbox-wrapper label.selected {
    border-color: #dc2626 !important;
    background: rgba(220, 38, 38, 0.05) !important;
}
.company-checkbox-wrapper label.selected .opacity-0 {
    opacity: 1 !important;
}

/* =============================================================
 * ROUTES HEADER – ACTION BUTTON GRADIENT FALLBACKS
 * Some hosting environments strip Tailwind utility classes.  If the
 * bg-gradient-to-r / from-X-500 / to-X-600 classes are missing the buttons
 * end up with a transparent background (white text on white card).
 * We forcibly re-apply the intended gradients here with high specificity.
 * ============================================================= */
.routes-header button#create-route-btn,
.routes-header a[href*="view=reports"],
.routes-header button.bg-gradient-to-r.from-red-500.to-red-600,
.routes-header a.bg-gradient-to-r.from-red-500.to-red-600 {
    background-image: linear-gradient(135deg,#ef4444 0%,#dc2626 100%) !important;
    color:#ffffff !important;
}

.routes-header a[href*="view=reports"],
.routes-header a.bg-gradient-to-r.from-amber-500.to-amber-600 {
    background-image: linear-gradient(135deg,#f59e0b 0%,#d97706 100%) !important;
    color:#ffffff !important;
}

/* Ensure focus & hover states keep solid background */
.routes-header button#create-route-btn:hover,
.routes-header button#create-route-btn:focus,
.routes-header a[href*="view=reports"]:hover,
.routes-header a[href*="view=reports"]:focus {
    filter: brightness(0.9);
}

/* =============================================================
 * HIDE DUPLICATE DELETE BUTTON INSIDE INVOICE LIST
 * Keeps the primary route delete button visible while removing
 * the extra one rendered at invoice level.
 * ============================================================= */
.company-section .delete-route-btn {
    display: none !important;
}

/* ===== CONTAINER NUMBER ENHANCEMENTS ===== */

/* Container info styling in route cards */
.container-info .inline-flex {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.route-card:hover .container-info .inline-flex {
    transform: scale(1.05);
    box-shadow: 
        0 4px 8px rgba(59, 130, 246, 0.15),
        0 0 0 1px rgba(59, 130, 246, 0.1);
}

.dark .route-card:hover .container-info .inline-flex {
    box-shadow: 
        0 4px 8px rgba(96, 165, 250, 0.2),
        0 0 0 1px rgba(96, 165, 250, 0.15);
}

/* Container number auto-generation button */
#generate-container-btn {
    position: relative;
    overflow: hidden;
}

#generate-container-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

#generate-container-btn:hover::before {
    left: 100%;
}

/* Container input enhancements */
#container_number {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#container_number:focus {
    transform: scale(1.01);
    box-shadow: 
        0 0 0 3px rgba(59, 130, 246, 0.1),
        0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Container display in route details modal */
.container-display-enhanced {
    animation: containerFadeIn 0.5s ease-out;
}

@keyframes containerFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Container search highlighting */
.route-card[data-container-match="true"] .container-info {
    animation: containerHighlight 2s ease-in-out;
}

@keyframes containerHighlight {
    0%, 100% {
        background: transparent;
    }
    50% {
        background: rgba(59, 130, 246, 0.1);
        border-radius: 8px;
    }
}

/* Enhanced container copy button */
.container-copy-btn {
    transition: all 0.2s ease;
}

.container-copy-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

/* ===== DESKTOP OPTIMIZATION FOR ROUTE CARDS ===== */

/* Enhanced responsive grid and card optimizations */
@media (min-width: 768px) {
    /* Optimize route cards for better desktop stacking */
    .route-card {
        min-height: 400px;
        max-height: 480px;
        border-radius: 12px;
        transform: translateY(0) scale(1);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .route-card:hover {
        transform: translateY(-6px) scale(1.015);
        box-shadow: 
            0 16px 24px -4px rgba(0, 0, 0, 0.12),
            0 8px 16px -4px rgba(0, 0, 0, 0.08);
    }
    
    .dark .route-card:hover {
        transform: translateY(-6px) scale(1.015);
        box-shadow: 
            0 16px 24px -4px rgba(0, 0, 0, 0.4),
            0 8px 16px -4px rgba(0, 0, 0, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
    
    /* More compact padding for desktop */
    .route-card .p-6 {
        padding: 1.25rem;
    }
    
    /* Optimize currency breakdown for side-by-side layout */
    .currency-breakdown {
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .currency-breakdown > div {
        padding: 0.75rem;
        border-radius: 8px;
    }
    
    /* Company breakdown optimizations */
    .company-breakdown-item {
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.5rem;
        border-radius: 6px;
        font-size: 0.875rem;
    }
    
    /* Compact route header */
    .route-card .route-icon {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    /* Optimize font sizes for desktop density */
    .route-card .route-title {
        font-size: 1rem;
        line-height: 1.4;
    }
    
    .route-card .route-subtitle {
        font-size: 0.75rem;
    }
    
    .route-card .currency-amount {
        font-size: 1rem;
        font-weight: 700;
        line-height: 1.2;
    }
}

/* Large screens - FIXED 2-column layout only */
@media (min-width: 1024px) {
    .route-card {
        min-height: 420px;
        max-height: 500px;
    }
    
    /* FIXED: Ensure exactly 2 columns, no more */
    #routes-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem;
    }
    
    /* Status badge optimizations */
    .route-card .px-3.py-1 {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }
    
    /* Route ID badge optimizations */
    .route-id-badge {
        padding: 0.25rem 0.5rem;
        font-size: 0.625rem;
    }
    
    /* Company prefix badge optimizations */
    .company-prefix-badge {
        width: 1.25rem;
        height: 1.25rem;
        font-size: 0.625rem;
    }
    
    /* Exchange rate and info optimizations */
    .exchange-rate-info,
    .initial-loan-info,
    .truck-rent-info {
        margin-top: 0.5rem;
    }
    
    .exchange-rate-info span,
    .initial-loan-info span,
    .truck-rent-info span {
        font-size: 0.625rem;
    }
}

/* Extra large screens - MAINTAIN 2-column layout */
@media (min-width: 1280px) {
    .route-card {
        min-height: 420px;
        max-height: 500px;
    }
    
    /* ENSURE 2 columns stay at all larger breakpoints */
    #routes-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem;
    }
    
    /* Slightly larger but still compact */
    .route-card .route-title {
        font-size: 1.1rem;
    }
    
    .route-card .currency-amount {
        font-size: 1.1rem;
    }
}

/* Ultra-wide screens - MAINTAIN 2-column layout */
@media (min-width: 1536px) {
    .route-card {
        min-height: 420px;
        max-height: 500px;
    }
    
    /* ENSURE 2 columns even on ultra-wide */
    #routes-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 2rem;
    }
    
    /* Maintain good proportions on ultra-wide */
    .currency-breakdown {
        gap: 1rem;
    }
    
    .currency-breakdown > div {
        padding: 1rem;
    }
}

/* Optimize spacing and visual hierarchy */
@media (min-width: 1024px) {
    .route-card .flex.items-center.gap-3 {
        gap: 0.75rem;
    }
    
    .route-card .flex.items-center.gap-4 {
        gap: 0.75rem;
    }
    
    .route-card .flex.items-center.gap-2 {
        gap: 0.5rem;
    }
    
    /* Optimize margins between sections */
    .route-card .mb-4 {
        margin-bottom: 0.75rem;
    }
}

/* Company breakdown scroll optimization for desktop */
@media (min-width: 1024px) {
    .company-breakdown-container {
        max-height: 140px;
        overflow-y: auto;
        padding-right: 4px;
    }
    
    .company-breakdown-container::-webkit-scrollbar {
        width: 4px;
    }
    
    .company-breakdown-container::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
        border-radius: 2px;
    }
    
    .company-breakdown-container::-webkit-scrollbar-thumb {
        background: rgba(156, 163, 175, 0.4);
        border-radius: 2px;
    }
    
    .dark .company-breakdown-container::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .dark .company-breakdown-container::-webkit-scrollbar-thumb {
        background: rgba(75, 85, 99, 0.6);
    }
}

/* Ensure proper card flex layout for consistent heights */
@media (min-width: 1024px) {
    .route-card {
        display: flex;
        flex-direction: column;
        height: fit-content;
    }
    
    .route-card > div:first-child {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    /* Currency breakdown takes appropriate space */
    .currency-breakdown {
        flex-shrink: 0;
    }
}

/* Text optimizations for better readability in compact mode */
@media (min-width: 1024px) {
    .route-card .text-lg {
        font-size: 1rem;
        line-height: 1.4;
    }
    
    .route-card .text-sm {
        font-size: 0.75rem;
        line-height: 1.3;
    }
    
    .route-card .text-xs {
        font-size: 0.625rem;
        line-height: 1.2;
    }
}

/* Action buttons optimization */
@media (min-width: 1024px) {
    .route-card .action-btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
        border-radius: 6px;
    }
}

/* Container width optimization for better card distribution */
@media (min-width: 1280px) {
    .routes-management-container {
        max-width: none;
        padding: 0 2rem;
    }
}

@media (min-width: 1536px) {
    .routes-management-container {
        padding: 0 3rem;
    }
}

/* Container Management Styles - Z-index fixes */
#container-filter-dropdown {
    z-index: 9999 !important;
    position: fixed !important;
    transform: translateZ(0);
}

.container-option {
    position: relative;
    z-index: 10000;
}

#container-picker-modal {
    z-index: 10001 !important;
    backdrop-filter: blur(8px);
}

#add-container-modal {
    z-index: 10001 !important;
    backdrop-filter: blur(8px);
}

/* Container display in route cards */
.container-info .inline-flex {
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.route-card:hover .container-info .inline-flex {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.dark .route-card:hover .container-info .inline-flex {
    background: rgba(96, 165, 250, 0.2);
    border-color: rgba(96, 165, 250, 0.4);
    box-shadow: 0 2px 8px rgba(96, 165, 250, 0.3);
}

/* Container picker enhancements */
.containers-list .container-item {
    transition: all 0.2s ease;
    cursor: pointer;
}

.containers-list .container-item:hover {
    background: rgba(59, 130, 246, 0.05);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dark .containers-list .container-item:hover {
    background: rgba(96, 165, 250, 0.1);
}

/* --- STATUS TOGGLE SWITCH --- */
#status-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 44px;
    height: 24px;
    background: #e5e7eb;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
    outline: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
#status-toggle[data-status="open"] {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
#status-toggle[data-status="closed"] {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}
#status-toggle-indicator {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.10);
    transition: left 0.3s cubic-bezier(0.4,0,0.2,1), background 0.3s;
    z-index: 1;
}
#status-toggle[data-status="open"] #status-toggle-indicator {
    left: 2px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
}
#status-toggle[data-status="closed"] #status-toggle-indicator {
    left: 22px;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}
#status-toggle:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
#status-toggle[aria-checked="true"] {
    box-shadow: 0 0 0 2px #10b98133;
}
#status-toggle[aria-checked="false"] {
    box-shadow: 0 0 0 2px #ef444433;
}
/* Dark mode */
html.dark #status-toggle {
    background: #374151;
}
html.dark #status-toggle[data-status="open"] {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}
html.dark #status-toggle[data-status="closed"] {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}
html.dark #status-toggle-indicator {
    background: #f9fafb;
}
html.dark #status-toggle[data-status="open"] #status-toggle-indicator {
    background: linear-gradient(135deg, #f9fafb 0%, #ecfdf5 100%);
}
html.dark #status-toggle[data-status="closed"] #status-toggle-indicator {
    background: linear-gradient(135deg, #f9fafb 0%, #fef2f2 100%);
}
/* Accessibility: focus ring */
#status-toggle:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Ensure routes header overlays route cards for dropdown visibility */
.routes-header {
    position: relative;
    z-index: 40;
}
