/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.2rem;
    color: #7f8c8d;
    margin-bottom: 20px;
}

.github-link a {
    display: inline-block;
    background: #24292e;
    color: white;
    padding: 12px 24px;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: background 0.3s ease;
}

.github-link a:hover {
    background: #444d56;
}

/* About Section */
.about-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

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

.about-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 25px;
    border-radius: 10px;
    border-left: 4px solid #3498db;
}

.about-card h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.about-card p {
    color: #555;
    line-height: 1.6;
}

.data-instructions {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.data-instructions h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
}

.instructions-steps {
    display: grid;
    gap: 20px;
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.step-number {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.step-content h4 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.step-content p {
    color: #555;
    line-height: 1.6;
    margin: 0;
}

.step-content a {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
}

.step-content a:hover {
    text-decoration: underline;
}

.privacy-note {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.privacy-note h3 {
    margin-bottom: 10px;
}

.privacy-note p {
    margin: 0;
    opacity: 0.95;
}

/* Upload Section */
.upload-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.upload-description {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #2196f3;
    margin-bottom: 25px;
    color: #1565c0;
    line-height: 1.6;
}

.upload-description a {
    color: #0d47a1;
    font-weight: 500;
    text-decoration: none;
}

.upload-description a:hover {
    text-decoration: underline;
}

.upload-area {
    border: 3px dashed #bdc3c7;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.upload-area:hover {
    border-color: #3498db;
    background-color: #f8f9fa;
}

.upload-area.dragover {
    border-color: #27ae60;
    background-color: #d5f4e6;
}

.sample-data {
    text-align: center;
}

.sample-description {
    color: #666;
    margin-bottom: 15px;
    font-style: italic;
}

.sample-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.sample-data button {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.3s ease;
    flex: 1;
    min-width: 180px;
    max-width: 220px;
}

.sample-data button:hover {
    background: #2980b9;
}

#loadConcordiaData {
    background: #27ae60;
}

#loadConcordiaData:hover {
    background: #229954;
}

#loadKingData {
    background: #e74c3c;
}

#loadKingData:hover {
    background: #c0392b;
}

#loadWoodlawnData {
    background: #9b59b6;
}

#loadWoodlawnData:hover {
    background: #8e44ad;
}

/* Analysis Section */
.analysis-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

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

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.stat-card h3 {
    font-size: 2.5rem;
    margin-bottom: 5px;
}

.stat-card p {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid #ecf0f1;
    margin-bottom: 30px;
    overflow-x: auto;
}

.tab-button {
    background: none;
    border: none;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 1rem;
    color: #7f8c8d;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-button:hover {
    color: #2c3e50;
}

.tab-button.active {
    color: #3498db;
    border-bottom-color: #3498db;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Charts and Tables */
.chart-container {
    margin-bottom: 30px;
    min-height: 400px;
}

.chart-controls {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

.chart-controls label {
    font-weight: 600;
    color: #2c3e50;
    margin-right: 10px;
}

.chart-controls select {
    padding: 8px 12px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    background: white;
    color: #2c3e50;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.chart-controls select:hover {
    border-color: #3498db;
}

.chart-controls select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Table controls */
.table-header-with-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.table-header-with-controls h4 {
    margin: 0;
    color: #2c3e50;
}

.table-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-controls label {
    font-weight: 500;
    color: #2c3e50;
    font-size: 14px;
}

.table-controls select {
    padding: 6px 10px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    background: white;
    color: #2c3e50;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.table-controls select:hover {
    border-color: #3498db;
}

.table-controls select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.15);
}

@media (max-width: 768px) {
    .table-header-with-controls {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Sortable table headers */
.sortable-header {
    position: relative;
    cursor: pointer;
    user-select: none;
    padding-right: 30px !important;
}

.sort-arrows {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.sort-arrow {
    font-size: 10px;
    color: #bdc3c7;
    cursor: pointer;
    line-height: 1;
    padding: 1px 3px;
    border-radius: 2px;
    transition: all 0.2s ease;
}

.sort-arrow:hover {
    color: #3498db;
    background-color: rgba(52, 152, 219, 0.1);
}

.sort-arrow.active {
    color: #3498db;
    background-color: rgba(52, 152, 219, 0.2);
    font-weight: bold;
}

.sortable-header:hover {
    background-color: rgba(52, 152, 219, 0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    position: relative;
    overflow: visible;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
    position: relative;
    overflow: visible;
}

table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

table tr:hover {
    background-color: #f8f9fa;
}

/* AI Section */
.ai-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    border-left: 4px solid #3498db;
}

#generateAIAnalysis {
    background: #27ae60;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s ease;
    margin-bottom: 20px;
}

#generateAIAnalysis:hover {
    background: #229954;
}

#aiContent {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e1e8ed;
    white-space: pre-wrap;
    max-height: 500px;
    overflow-y: auto;
}

/* Methodology */
.methodology {
    background: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.methodology-content ul {
    list-style-type: none;
    padding-left: 0;
}

.methodology-content li {
    padding: 10px 0;
    border-left: 4px solid #3498db;
    padding-left: 20px;
    margin-bottom: 10px;
    background-color: #f8f9fa;
    border-radius: 0 8px 8px 0;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: white;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

footer a {
    color: white;
    text-decoration: none;
    font-weight: 500;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .about-grid {
        grid-template-columns: 1fr;
    }
    
    .about-card {
        padding: 20px;
    }
    
    .step {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .step-number {
        margin-bottom: 10px;
    }
    
    .sample-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .sample-data button {
        width: 100%;
        max-width: 300px;
        margin-bottom: 10px;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab-button {
        flex: 1;
        min-width: 120px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Combined names indicator */
.combined-indicator {
    color: #3498db;
    cursor: help;
    font-size: 0.9em;
    margin-left: 5px;
    display: inline-block;
    position: relative;
}

.combined-indicator:hover {
    color: #2980b9;
    transform: scale(1.1);
    transition: all 0.2s ease;
}

/* Custom tooltip for combined names */
.combined-indicator::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2c3e50;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    max-width: 300px;
    white-space: normal;
    word-wrap: break-word;
}

.combined-indicator::before {
    content: "";
    position: absolute;
    bottom: 90%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #2c3e50;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1001;
}

.combined-indicator:hover::after,
.combined-indicator:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Loading states */
.loading {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

.loading:after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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

/* Alert styles */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    border-left: 4px solid;
}

.alert-success {
    background-color: #d5f4e6;
    border-color: #27ae60;
    color: #186b3a;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #f39c12;
    color: #856404;
}

.alert-danger {
    background-color: #f8d7da;
    border-color: #e74c3c;
    color: #721c24;
}