/* Railway Management System - Complete CSS Styles with Toast Fixes */

/* ===== CSS RESET & BASE STYLES ===== */

/* Hide content until auth check completes */
.auth-loading {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.auth-ready {
    opacity: 1;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== CONTAINER & LAYOUT ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== HEADER STYLES ===== */
.header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 40px 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(30, 60, 114, 0.3);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.03) 10px,
        rgba(255, 255, 255, 0.03) 20px
    );
    animation: headerPattern 20s linear infinite;
}

@keyframes headerPattern {
    0% { transform: translateX(-100px) translateY(-100px); }
    100% { transform: translateX(100px) translateY(100px); }
}

.header h1 {
    font-size: 2.8em;
    margin-bottom: 10px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

.header h2 {
    font-size: 1.3em;
    opacity: 0.9;
    font-weight: 400;
    position: relative;
    z-index: 1;
}

/* ===== NAVIGATION STYLES ===== */
.nav-container {
    margin-bottom: 30px;
}

.nav-tabs {
    display: flex;
    background: white;
    border-radius: 15px;
    padding: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.nav-tab {
    flex: 1;
    padding: 18px 25px;
    text-align: center;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    font-size: 1.05em;
    position: relative;
    overflow: hidden;
    color: #555;
}

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

.nav-tab:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.nav-tab:hover::before {
    left: 100%;
}

.nav-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.nav-tab.active::before {
    display: none;
}

/* ===== CONTENT SECTIONS ===== */
.content-section {
    display: none;
    background: white;
    border-radius: 15px;
    padding: 35px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.content-section.active {
    display: block;
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.content-section h3 {
    font-size: 1.8em;
    margin-bottom: 25px;
    color: #2c3e50;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
    display: inline-block;
}

/* ===== DASHBOARD STYLES ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.card {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-left: 5px solid #667eea;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(30px, -30px);
}

.card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    border-left-color: #764ba2;
}

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

.card-title {
    font-size: 1.4em;
    font-weight: 700;
    color: #2c3e50;
}

.train-count {
    font-size: 3em;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 15px;
    animation: countUp 1s ease-out;
}

@keyframes countUp {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.train-info {
    color: #666;
    font-size: 0.95em;
}

.train-info div {
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #f0f0f0;
}

.train-info div:last-child {
    border-bottom: none;
}

.train-info span {
    font-weight: 600;
    color: #333;
}

/* ===== STATUS INDICATORS ===== */
.status-indicator {
    padding: 6px 14px;
    border-radius: 25px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    display: inline-block;
}

.status-active {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-cancelled {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status-delayed {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border: 1px solid #ffeaa7;
}

.status-indicator:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* ===== FILTER STYLES ===== */
.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

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

.filter-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 0.95em;
}

.filter-group input,
.filter-group select {
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

/* ===== BUTTON STYLES ===== */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-primary::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 ease;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:active {
    transform: translateY(-1px);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.3);
}

/* ===== MANAGEMENT BUTTONS ===== */
.management-buttons {
    margin-bottom: 25px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.management-buttons button {
    flex: 1;
    min-width: 200px;
}

/* ===== TABLE STYLES ===== */
.table-container {
    overflow-x: auto;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    background: white;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th, td {
    padding: 15px 20px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    font-weight: 700;
    color: #495057;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

tr {
    transition: all 0.3s ease;
}

tr:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    transform: scale(1.01);
}

td {
    font-size: 0.95em;
}

/* Table animations */
.table-container tbody tr {
    animation: fadeIn 0.5s ease forwards;
    opacity: 0;
}

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

/* Staggered animation for table rows */
.table-container tbody tr:nth-child(1) { animation-delay: 0.1s; }
.table-container tbody tr:nth-child(2) { animation-delay: 0.2s; }
.table-container tbody tr:nth-child(3) { animation-delay: 0.3s; }
.table-container tbody tr:nth-child(4) { animation-delay: 0.4s; }
.table-container tbody tr:nth-child(5) { animation-delay: 0.5s; }

/* ===== MODAL STYLES ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    animation: modalFadeIn 0.3s ease;
}

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

.modal-content {
    background: white;
    margin: 3% auto;
    padding: 40px;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.close {
    position: absolute;
    right: 25px;
    top: 20px;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close:hover {
    color: #000;
    background: #f0f0f0;
    transform: rotate(90deg);
}

.modal h2 {
    margin-bottom: 30px;
    color: #2c3e50;
    font-size: 1.8em;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

/* ===== FORM STYLES ===== */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 0.95em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    backdrop-filter: blur(5px);
}

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

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

.loading-text {
    font-size: 1.2em;
    color: #495057;
    font-weight: 600;
}

/* ===== TOAST NOTIFICATIONS - CONSOLIDATED AND FIXED ===== */
.toast-container {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    z-index: 10000 !important;
    max-width: 400px !important;
    pointer-events: none !important;
    display: block !important;
    visibility: visible !important;
}

.toast {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 12px 20px !important;
    margin: 8px 0 !important;
    border-radius: 10px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    max-width: 400px !important;
    word-wrap: break-word !important;
    position: relative !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    pointer-events: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: translateX(0) !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 10001 !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    backdrop-filter: blur(10px) !important;
    min-height: 50px !important;
    min-width: 200px !important;
}

.toast.show {
    opacity: 1 !important;
    transform: translateX(0) !important;
    visibility: visible !important;
    animation: toastSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.toast.hide {
    opacity: 0 !important;
    transform: translateX(100%) !important;
    visibility: hidden !important;
    animation: toastSlideOut 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Toast type styling */
.toast.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    color: white !important;
    border-left: 4px solid #20c997 !important;
}

.toast.error {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
    color: white !important;
    border-left: 4px solid #c82333 !important;
}

.toast.warning {
    background: linear-gradient(135deg, #ffc107 0%, #ffb300 100%) !important;
    color: #212529 !important;
    border-left: 4px solid #ffb300 !important;
}

.toast.info {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%) !important;
    color: white !important;
    border-left: 4px solid #138496 !important;
}

.toast.file-upload {
    border-left: 4px solid #667eea !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
}

.toast.duty-roster {
    border-left: 4px solid #28a745 !important;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    color: white !important;
}

.toast.cancellation {
    border-left: 4px solid #dc3545 !important;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
    color: white !important;
}

/* Toast elements */
.toast-icon {
    font-size: 1.2em !important;
    flex-shrink: 0 !important;
}

.toast-message {
    flex: 1 !important;
    line-height: 1.4 !important;
}

.toast-close {
    font-size: 1.1em !important;
    opacity: 0.7 !important;
    flex-shrink: 0 !important;
    cursor: pointer !important;
    transition: opacity 0.2s ease !important;
}

.toast-close:hover {
    opacity: 1 !important;
}

/* Toast stacking */
.toast:not(:last-child) {
    margin-bottom: 10px !important;
}

/* Toast animations */
@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
        visibility: hidden;
    }
    to {
        opacity: 1;
        transform: translateX(0);
        visibility: visible;
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
        visibility: visible;
    }
    to {
        opacity: 0;
        transform: translateX(100%);
        visibility: hidden;
    }
}

/* Toast progress indicator */
.toast.with-progress {
    padding-bottom: 18px !important;
}

.toast.with-progress .toast-progress {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    height: 4px !important;
    background: rgba(255, 255, 255, 0.3) !important;
    border-radius: 0 0 10px 10px !important;
    animation: toastProgress 5s linear !important;
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* Enhanced summary cards grid for 6 cards */
.wheel-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

/* Enhanced table styles for duty hours column */
#wheelMovementTable th:nth-child(4),
#wheelMovementTable td:nth-child(4) {
    background-color: rgba(23, 162, 184, 0.05);
    border-left: 2px solid #17a2b8;
}

#wheelMovementTable th:nth-child(4) {
    background-color: rgba(23, 162, 184, 0.1);
    font-weight: 600;
    color: #17a2b8;
}

/* Enhanced expanded row styles */
.expanded-detail-row {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-left: 4px solid #667eea;
}

/* Daily breakdown card enhancements */
.daily-breakdown-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 3px solid #28a745;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.daily-breakdown-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.daily-breakdown-card.has-cancellations {
    border-left-color: #dc3545;
}

/* Duty hours specific styling */
.duty-hours-value {
    font-weight: 600;
    font-size: 1.1em;
    color: #17a2b8;
}

.wheel-movement-value {
    font-weight: 600;
    font-size: 1.1em;
    color: #28a745;
}

/* Enhanced filter section */
.wheel-filters-section {
    position: relative;
    overflow: hidden;
}

.wheel-filters-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    pointer-events: none;
}

/* Information section styling */
.analysis-info-section {
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #17a2b8;
    padding: 20px;
    margin-top: 20px;
}

.analysis-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    font-size: 0.9em;
}

.info-card {
    background: white;
    padding: 15px;
    border-radius: 6px;
    border-left: 3px solid #17a2b8;
}

/* Animation enhancements */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.summary-card {
    animation: slideInUp 0.6s ease-out;
}

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

/* Enhanced button styles */
.expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    margin-right: 10px;
    transition: all 0.2s ease;
    border-radius: 4px;
    padding: 4px 8px;
}

.expand-btn:hover {
    background-color: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

/* Tooltip styles for additional information */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8em;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
}

/* Loading state for analysis */
.analysis-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.analysis-loading::after {
    content: '⏳ Analyzing...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    font-weight: 600;
    color: #667eea;
    z-index: 10;
}

/* Color coding for different metrics */
.metric-excellent { color: #28a745; }
.metric-good { color: #17a2b8; }
.metric-warning { color: #ffc107; }
.metric-danger { color: #dc3545; }

/* Enhanced focus states for accessibility */
.filter-group input:focus,
.filter-group select:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.btn-primary:focus {
    outline: 2px solid #495057;
    outline-offset: 2px;
}

/* ===== TRAIN CANCELLATION FORM STYLES ===== */
.cancellation-options .form-row {
    display: grid;
    gap: 20px;
    margin-bottom: 15px;
}

.cancellation-options .form-group {
    display: flex;
    flex-direction: column;
}

.cancellation-options .form-group label {
    color: #495057;
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
    font-size: 0.95em;
}

.cancellation-options .form-group input,
.cancellation-options .form-group select,
.cancellation-options .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

.cancellation-options .form-group input:focus,
.cancellation-options .form-group select:focus,
.cancellation-options .form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.cancellation-options .form-group input[type="file"] {
    padding: 8px;
    border-style: dashed;
    border-width: 2px;
    background: #f8f9fa;
}

.cancellation-options .form-group input[type="file"]:hover {
    background: #e9ecef;
    border-color: #667eea;
}

/* Section specific styling */
.bulk-upload-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid #e67e22;
    transition: all 0.3s ease;
}

.bulk-upload-section:hover {
    box-shadow: 0 4px 15px rgba(230, 126, 34, 0.1);
    transform: translateY(-2px);
}

.single-cancellation-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #dc3545;
    transition: all 0.3s ease;
}

.single-cancellation-section:hover {
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.1);
    transform: translateY(-2px);
}

/* Info boxes styling */
.info-box {
    margin-top: 15px;
    padding: 12px;
    border-radius: 6px;
    font-size: 0.9em;
}

.info-box.warning {
    background: #fff3cd;
    color: #856404;
    border-left: 3px solid #ffc107;
}

.info-box.info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 3px solid #17a2b8;
}

/* Upload result styling */
#cancelledUploadResult {
    margin-top: 15px;
    padding: 10px;
    border-radius: 6px;
    font-weight: 500;
    display: none;
}

#cancelledUploadResult.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

#cancelledUploadResult.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* Responsive design for cancellation forms */
@media (max-width: 768px) {
    .cancellation-options .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .bulk-upload-section,
    .single-cancellation-section {
        padding: 15px;
    }
}

/* Toast accessibility */
.toast:focus-visible {
    outline: 2px solid #667eea !important;
    outline-offset: 2px !important;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
    .container {
        padding: 15px;
    }
    
    .nav-tabs {
        flex-wrap: wrap;
    }
    
    .nav-tab {
        min-width: 140px;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 2.2em;
    }
    
    .header h2 {
        font-size: 1.1em;
    }
    
    .nav-tabs {
        flex-direction: column;
        gap: 5px;
    }
    
    .filters-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .management-buttons {
        flex-direction: column;
    }
    
    .management-buttons button {
        min-width: auto;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .modal-content {
        margin: 5% auto;
        padding: 25px;
        width: 95%;
    }
    
    table {
        font-size: 0.85em;
    }
    
    th, td {
        padding: 10px 8px;
    }
    
    .train-count {
        font-size: 2.5em;
    }
    
    .card {
        padding: 20px;
    }
    
    .content-section {
        padding: 20px;
    }
    
    /* Toast responsive */
    .toast-container {
        top: 10px !important;
        right: 10px !important;
        left: 10px !important;
        max-width: calc(100vw - 20px) !important;
    }
    
    .toast {
        max-width: 100% !important;
        font-size: 13px !important;
    }
    
    /* Wheel summary responsive */
    .wheel-summary-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .summary-card {
        padding: 15px !important;
    }
    
    .summary-card div:nth-child(2) {
        font-size: 1.8em !important;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .header {
        padding: 25px 20px;
    }
    
    .header h1 {
        font-size: 1.8em;
    }
    
    .content-section {
        padding: 15px;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .toast-container {
        top: 5px !important;
        right: 5px !important;
        left: 5px !important;
    }
    
    .toast {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
    
    .toast-icon {
        font-size: 1em !important;
    }
    
    /* Wheel summary mobile */
    .wheel-summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .summary-card {
        padding: 12px !important;
    }
    
    .summary-card div:nth-child(2) {
        font-size: 1.5em !important;
    }
}

@media (max-width: 576px) {
    .wheel-filters-section {
        padding: 15px;
    }
    
    .filters-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    .wheel-summary-grid {
        grid-template-columns: 1fr;
    }
    
    .table-container {
        font-size: 0.8em;
    }
    
    .daily-breakdown-card {
        padding: 10px;
    }
    
    .analysis-info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 320px) {
    .toast {
        padding: 6px 10px !important;
        font-size: 11px !important;
    }
    
    .toast-icon {
        font-size: 1em !important;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
    }
    
    .analysis-info-section {
        background: #2c3e50;
        color: #ecf0f1;
    }
    
    .info-card {
        background: #34495e;
        color: #ecf0f1;
    }
    
    .daily-breakdown-card {
        background: #34495e;
        color: #ecf0f1;
    }
    
    .toast {
        box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1) !important;
    }
    
    .toast.warning {
        color: #000 !important;
    }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    .toast {
        border: 2px solid currentColor !important;
        box-shadow: none !important;
    }
    
    .toast.success {
        background: #28a745 !important;
        color: white !important;
    }
    
    .toast.error {
        background: #dc3545 !important;
        color: white !important;
    }
    
    .toast.warning {
        background: #ffc107 !important;
        color: #000 !important;
    }
    
    .toast.info {
        background: #17a2b8 !important;
        color: white !important;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    .toast {
        transition: opacity 0.2s ease !important;
        transform: none !important;
    }
    
    .toast.show {
        opacity: 1 !important;
        transform: none !important;
    }
    
    .toast.hide {
        opacity: 0 !important;
        transform: none !important;
    }
    
    .toast-icon {
        animation: none !important;
    }
    
    .toast.with-progress::before {
        animation: none !important;
    }
    
    .summary-card {
        animation: none !important;
    }
    
    .nav-tab {
        transition: none !important;
    }
    
    .btn-primary {
        transition: none !important;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .nav-container,
    .filters-grid,
    .management-buttons,
    .modal,
    .toast-container,
    .loading-overlay {
        display: none !important;
    }
    
    .content-section {
        display: block !important;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .header {
        background: #333 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    
    .wheel-filters-section,
    .btn-primary,
    .expand-btn {
        display: none !important;
    }
    
    .summary-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .table-container {
        font-size: 0.8em;
    }
    
    .expanded-detail-row {
        break-inside: avoid;
    }
}

/* ===== CUSTOM SCROLLBAR ===== */
.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}
  

/* ADD TO styles.css - Wheel Movement Analysis Enhancements */

/* ===== WHEEL MOVEMENT TABLE STYLES ===== */
.motorman-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  
  .period-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  
  .wheel-movement-display {
    text-align: center;
  }
  
  .wheel-movement-value {
    font-weight: 700;
    font-size: 1.3em;
    color: #28a745;
    margin-bottom: 8px;
  }
  
  .breakdown-summary {
    text-align: left;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 6px;
    border-left: 3px solid #28a745;
  }
  
  .duty-hours-display {
    text-align: center;
  }
  
  .duty-hours-value {
    font-weight: 700;
    font-size: 1.2em;
    color: #17a2b8;
    margin-bottom: 4px;
  }
  
  .action-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
  }
  
  .expand-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.1em;
    transition: all 0.3s ease;
    min-width: 40px;
  }
  
  .expand-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  }
  
  .reassignment-indicator {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.8em;
    margin-left: 8px;
    cursor: help;
  }
  
  /* ===== EXPANDED BREAKDOWN STYLES ===== */
  .expanded-detail-row {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-left: 4px solid #667eea;
    animation: expandIn 0.4s ease-out;
  }
  
  .daily-breakdown-container {
    max-width: 100%;
  }
  
  .daily-summary {
    font-size: 0.95em;
    line-height: 1.4;
  }
  
  .daily-cards-grid {
    scrollbar-width: thin;
    scrollbar-color: #667eea #f1f1f1;
  }
  
  .daily-cards-grid::-webkit-scrollbar {
    width: 6px;
  }
  
  .daily-cards-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
  }
  
  .daily-cards-grid::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
  }
  
  .daily-breakdown-card {
    background: white;
    padding: 16px;
    border-radius: 10px;
    border-left: 4px solid #28a745;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    position: relative;
  }
  
  .daily-breakdown-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  }
  
  .daily-breakdown-card.is-sunday {
    border-left-color: #ffc107;
    background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
  }
  
  .daily-breakdown-card.has-reassignments {
    border-left-color: #667eea;
    background: linear-gradient(135deg, #f0f4ff 0%, #ffffff 100%);
  }
  
  .daily-breakdown-card.has-reassignments::before {
    content: "🔄";
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 1.2em;
    opacity: 0.7;
  }
  
  .breakdown-values {
    font-size: 0.85em;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 4px;
    margin: 8px 0;
  }
  
  /* ===== FADE IN ANIMATION ===== */
  .fade-in-row {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease forwards;
  }
  
  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  @keyframes expandIn {
    from {
      opacity: 0;
      transform: scaleY(0);
    }
    to {
      opacity: 1;
      transform: scaleY(1);
    }
  }
  
  /* ===== SUMMARY CARDS ENHANCEMENTS ===== */
  .wheel-summary-grid .summary-card {
    position: relative;
    overflow: hidden;
  }
  
  .wheel-summary-grid .summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(25px, -25px);
  }
  
  .wheel-summary-grid .summary-card:hover {
    transform: translateY(-5px) scale(1.02);
  }
  
  /* ===== RESPONSIVE IMPROVEMENTS ===== */
  @media (max-width: 768px) {
    .daily-cards-grid {
      grid-template-columns: 1fr;
      gap: 10px;
    }
    
    .daily-breakdown-card {
      padding: 12px;
    }
    
    .breakdown-values {
      grid-template-columns: 1fr;
      gap: 4px;
    }
    
    .action-buttons {
      flex-direction: column;
      gap: 4px;
    }
    
    .expand-btn {
      width: 100%;
      font-size: 1em;
    }
    
    .wheel-movement-value {
      font-size: 1.1em;
    }
    
    .duty-hours-value {
      font-size: 1em;
    }
  }
  
  @media (max-width: 480px) {
    .daily-breakdown-container {
      padding: 10px;
    }
    
    .daily-summary {
      font-size: 0.85em;
      padding: 10px;
    }
    
    .daily-breakdown-card {
      padding: 10px;
      font-size: 0.85em;
    }
    
    .expanded-detail-row td {
      padding: 15px !important;
    }
  }
  
  /* ===== PRINT STYLES ===== */
  @media print {
    .action-buttons {
      display: none !important;
    }
    
    .daily-cards-grid {
      display: block !important;
      max-height: none !important;
      overflow: visible !important;
    }
    
    .daily-breakdown-card {
      break-inside: avoid;
      page-break-inside: avoid;
      margin-bottom: 10px;
      box-shadow: none !important;
      border: 1px solid #ddd !important;
    }
    
    .expanded-detail-row {
      break-inside: avoid;
    }
  }