/* ============================================
   Global Styles & Reset
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    --bec-color: #3b82f6;
    --nhcd-color: #8b5cf6;
    --bef-color: #ec4899;
    --gov-color: #14b8a6;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================
   Header Styles
   ============================================ */
.header {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
}

.header-content {
    text-align: center;
    position: relative;
}

.header-icon {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 15px;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.header h1 {
    font-size: 2.5rem;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 10px;
}

.header-actions {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
}

/* ============================================
   Info Card
   ============================================ */
.info-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.info-card i {
    font-size: 32px;
    margin-top: 5px;
}

.info-card h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.info-card p {
    opacity: 0.95;
    line-height: 1.8;
}

/* ============================================
   File Upload Styles
   ============================================ */
.file-upload-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.file-upload-box {
    border: 2px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.file-upload-box:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.file-upload-header {
    background: linear-gradient(135deg, var(--primary-color), #1d4ed8);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.file-upload-header.special {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.file-upload-header i {
    font-size: 28px;
}

.file-upload-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
}

.file-upload-content {
    padding: 25px;
}

.file-input-wrapper {
    margin-bottom: 25px;
}

input[type="file"] {
    display: none;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    border: 3px dashed var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-light);
}

.file-label:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.file-label i {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.file-label-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.file-format {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.file-name {
    margin-top: 15px;
    padding: 12px;
    background: #dcfce7;
    border-left: 4px solid var(--success-color);
    border-radius: 5px;
    color: #166534;
    font-weight: 500;
    display: none;
}

.file-name.active {
    display: block;
}

.expected-columns {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 8px;
}

.expected-columns h4 {
    color: var(--text-primary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.expected-columns ul {
    list-style: none;
    padding-left: 0;
}

.expected-columns li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.expected-columns li:last-child {
    border-bottom: none;
}

.expected-columns li:before {
    content: "•";
    color: var(--primary-color);
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-right: 8px;
}

/* ============================================
   Button Styles
   ============================================ */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.btn {
    padding: 14px 32px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #1d4ed8);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-info {
    background: var(--info-color);
    color: white;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   Progress Section
   ============================================ */
.progress-section {
    margin-top: 30px;
    padding: 25px;
    background: var(--bg-light);
    border-radius: 10px;
}

.progress-bar-container {
    width: 100%;
    height: 30px;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #8b5cf6);
    width: 0%;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    animation: progress-animation 1.5s infinite;
}

@keyframes progress-animation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.progress-text {
    text-align: center;
    margin-top: 15px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================
   Error Message
   ============================================ */
.error-message {
    margin-top: 20px;
    padding: 15px 20px;
    background: #fef2f2;
    border-left: 4px solid var(--danger-color);
    border-radius: 5px;
    color: #991b1b;
    display: flex;
    align-items: center;
    gap: 12px;
}

.error-message i {
    font-size: 24px;
}

/* ============================================
   Features Section
   ============================================ */
.features-section {
    margin-top: 50px;
}

.features-section h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-primary);
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.feature-card {
    padding: 30px;
    background: var(--bg-light);
    border-radius: 10px;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.feature-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.feature-card i {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 20px;
    display: block;
}

.feature-card h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.feature-card p {
    color: var(--text-secondary);
    line-height: 1.8;
}

/* ============================================
   Results Page - Summary Statistics
   ============================================ */
.summary-section {
    margin-bottom: 40px;
}

.summary-section h2 {
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 20px;
    border-left: 5px solid var(--primary-color);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card.primary { border-left-color: var(--primary-color); }
.stat-card.success { border-left-color: var(--success-color); }
.stat-card.info { border-left-color: var(--info-color); }
.stat-card.warning { border-left-color: var(--warning-color); }

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
}

.stat-icon i {
    font-size: 30px;
    color: var(--primary-color);
}

.stat-content h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-weight: 500;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ============================================
   Distribution Section
   ============================================ */
.distribution-section {
    margin: 40px 0;
}

.distribution-section h3 {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.distribution-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.distribution-card {
    padding: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
    text-align: center;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.distribution-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.distribution-card.bec {
    background: linear-gradient(135deg, var(--bec-color), #2563eb);
}

.distribution-card.nhcd {
    background: linear-gradient(135deg, var(--nhcd-color), #7c3aed);
}

.distribution-card.bef {
    background: linear-gradient(135deg, var(--bef-color), #db2777);
}

.distribution-card i {
    font-size: 40px;
    margin-bottom: 15px;
    display: block;
}

.distribution-card h4 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    opacity: 0.95;
}

.distribution-number {
    font-size: 3rem;
    font-weight: 700;
    display: block;
    margin-bottom: 10px;
}

.distribution-percentage {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* ============================================
   Average Distances
   ============================================ */
.average-distances {
    margin: 40px 0;
}

.average-distances h3 {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.avg-distance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.avg-card {
    padding: 25px;
    background: var(--bg-light);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.avg-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-3px);
}

.avg-label {
    font-size: 1rem;
    color: var(--text-secondary);
    text-align: center;
}

.avg-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* ============================================
   Charts Section
   ============================================ */
.charts-section {
    margin: 40px 0;
}

.charts-section h3 {
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}

.chart-container {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
}

/* ============================================
   Map Section
   ============================================ */
.map-section {
    margin: 40px 0;
}

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

.section-header h2 {
    display: flex;
    align-items: center;
    gap: 12px;
}

.map-controls {
    display: flex;
    gap: 10px;
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 15px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-marker {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.legend-marker.gov { background: var(--gov-color); }
.legend-marker.bec { background: var(--bec-color); }
.legend-marker.nhcd { background: var(--nhcd-color); }
.legend-marker.bef { background: var(--bef-color); }

#map {
    height: 600px;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--border-color);
}

/* ============================================
   Table Section
   ============================================ */
.table-section {
    margin: 40px 0;
}

.table-controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 250px;
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-select {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.table-container {
    overflow-x: auto;
    margin-top: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
}

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

thead {
    background: linear-gradient(135deg, var(--primary-color), #1d4ed8);
    color: white;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

tbody tr {
    transition: all 0.2s ease;
}

tbody tr:hover {
    background: var(--bg-light);
}

.school-name {
    font-weight: 600;
    color: var(--text-primary);
}

.distance {
    font-weight: 600;
    color: var(--primary-color);
}

.badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

.badge-bec {
    background: #dbeafe;
    color: #1e40af;
}

.badge-nhcd {
    background: #ede9fe;
    color: #6b21a8;
}

.badge-bef {
    background: #fce7f3;
    color: #9f1239;
}

.badge-none {
    background: #f1f5f9;
    color: #64748b;
}

.count-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-block;
    transition: all 0.3s ease;
}

.count-badge.bec {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.count-badge.nhcd {
    background: #ede9fe;
    color: #6b21a8;
    border: 1px solid #c4b5fd;
}

.count-badge.bef {
    background: #fce7f3;
    color: #9f1239;
    border: 1px solid #fbcfe8;
}

.text-muted {
    color: var(--text-secondary);
    font-style: italic;
}

/* ============================================
   Modal
   ============================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    padding: 25px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 25px;
}

.detail-section {
    margin-bottom: 25px;
}

.detail-section h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.detail-item {
    padding: 12px;
    background: var(--bg-light);
    border-radius: 6px;
}

.detail-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.detail-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   Footer
   ============================================ */
.footer {
    text-align: center;
    padding: 20px;
    color: white;
    margin-top: 30px;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1024px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .file-upload-container {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .header-actions {
        position: static;
        transform: none;
        margin-top: 20px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .distribution-grid {
        grid-template-columns: 1fr;
    }
    
    .avg-distance-grid {
        grid-template-columns: 1fr;
    }
    
    .table-controls {
        flex-direction: column;
    }
    
    .search-input {
        width: 100%;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    #map {
        height: 400px;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .file-upload-content {
        padding: 15px;
    }
    
    table {
        font-size: 0.85rem;
    }
    
    th, td {
        padding: 10px;
    }
    
    .modal-content {
        width: 95%;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    body {
        background: white;
    }
    
    .header-actions,
    .map-controls,
    .table-controls,
    .btn,
    .footer {
        display: none !important;
    }
    
    .container {
        max-width: 100%;
    }
    
    .main-content {
        box-shadow: none;
    }
}

/* ============================================
   Loading Animation
   ============================================ */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.hidden { display: none; }

/* ============================================
   Loading Overlay for Progressive Updates
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 30px;
    border: 5px solid #f3f4f6;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-content h2 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 1.8rem;
}

.loading-message {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 1.1rem;
}

.progress-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 25px;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 10px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.loading-progress-bar {
    width: 100%;
    height: 10px;
    background: #f3f4f6;
    border-radius: 5px;
    overflow: hidden;
}

.loading-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #8b5cf6);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 5px;
}
