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

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

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

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
    animation: slideDown 0.6s ease;
}

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

header h1 {
    font-size: 2.8rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 300;
}

/* Upload section */
.upload-section {
    background: white;
    border-radius: 16px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    text-align: center;
    animation: fadeIn 0.8s ease 0.2s backwards;
}

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

.upload-area {
    border: 3px dashed #e0e7ff;
    border-radius: 12px;
    padding: 50px 40px;
    margin-bottom: 25px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    background: linear-gradient(135deg, #f8fafb 0%, #f0f4ff 100%);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #667eea;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8ecff 100%);
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.15);
}

.upload-icon {
    width: 64px;
    height: 64px;
    color: #667eea;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

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

.upload-content p {
    font-size: 1.1rem;
    color: #5a6b7a;
    margin-bottom: 10px;
    font-weight: 500;
}

/* Buttons */
.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-secondary:hover {
    box-shadow: 0 8px 25px rgba(245, 87, 108, 0.4);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 8px 25px rgba(250, 112, 154, 0.4);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-success:hover {
    box-shadow: 0 8px 25px rgba(79, 172, 254, 0.4);
    transform: translateY(-2px);
}

.btn-outline {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    box-shadow: none;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    transform: translateY(-2px);
}

/* Data section */
.data-section {
    background: white;
    border-radius: 16px;
    padding: 35px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: fadeIn 0.8s ease 0.3s backwards;
}

.data-info {
    margin-bottom: 35px;
    margin-left: -35px;
    margin-right: -35px;
    margin-top: -35px;
    padding: 35px;
    background: linear-gradient(135deg, #f8fafb 0%, #e8ecf1 100%);
    border-radius: 16px 16px 0 0;
}

.data-info h2 {
    margin-bottom: 25px;
    color: #2c3e50;
    font-size: 1.6rem;
    font-weight: 600;
}

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

.stat {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    color: white;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
    transition: all 0.3s ease;
}

.stat:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.3);
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-value {
    display: block;
    font-size: 2.2rem;
    font-weight: 700;
}

/* Table */
.table-container {
    overflow-x: auto;
    overflow-y: hidden;
    margin-bottom: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
    -webkit-overflow-scrolling: touch;
}

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

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e8ecf1;
    font-size: 0.95rem;
}

th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    font-size: 0.9rem;
}

tr:hover {
    background: #f8fafb;
}

.missing-cell {
    background: linear-gradient(135deg, #fffacd 0%, #fff8dc 100%) !important;
    border-left: 2px solid #ffc107;
    font-weight: 400;
    color: #9d5d00;
    opacity: 0.85;
}

/* Imputation section */
.imputation-section {
    background: linear-gradient(135deg, #f8fafb 0%, #e8ecf1 100%);
    border-radius: 12px;
    padding: 35px;
    margin-top: 30px;
    animation: fadeIn 0.8s ease 0.4s backwards;
}

.imputation-section h3 {
    margin-bottom: 25px;
    color: #2c3e50;
    font-size: 1.4rem;
    font-weight: 600;
}

.column-selection {
    margin-bottom: 25px;
}

.column-selection label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95rem;
}

#columnSelect {
    width: 100%;
    max-width: 350px;
    padding: 12px 16px;
    border: 2px solid #e0e7ff;
    border-radius: 8px;
    font-size: 1rem;
    color: #2c3e50;
    background: white;
    transition: all 0.3s ease;
}

#columnSelect:hover,
#columnSelect:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.imputation-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.option-group h4 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.imputation-btn {
    width: 100%;
    margin-bottom: 10px;
}

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

/* Loading and messages */
.loading {
    text-align: center;
    padding: 50px 40px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

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

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

.message {
    padding: 16px 20px;
    border-radius: 10px;
    margin: 20px 0;
    text-align: center;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

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

.message.success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-left: 4px solid #28a745;
}

.message.error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-left: 4px solid #dc3545;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    header p {
        font-size: 1rem;
    }

    .upload-section,
    .data-section,
    .imputation-section {
        padding: 25px;
    }

    .upload-area {
        padding: 35px 25px;
    }

    .stats {
        grid-template-columns: 1fr;
    }

    .imputation-options {
        grid-template-columns: 1fr;
    }

    .actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: 10px 12px;
    }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 25px;
    flex-wrap: wrap;
    padding: 20px 0;
}

.pagination button {
    padding: 10px 14px;
    border: 2px solid #e0e7ff;
    border-radius: 8px;
    background-color: white;
    color: #2c3e50;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.pagination button:hover:not(:disabled) {
    background-color: #f0f4ff;
    border-color: #667eea;
}

.pagination button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-info {
    text-align: center;
    color: #5a6b7a;
    font-size: 14px;
    width: 100%;
    font-weight: 500;
}

/* Imputation section collapsed state */
.imputation-section.collapsed {
    max-width: 320px;
    margin: 30px auto;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 30px;
}

.imputation-section.collapsed .column-selection,
.imputation-section.collapsed .imputation-options,
.imputation-section.collapsed h3 {
    display: none;
}

.imputation-section.collapsed .actions {
    justify-content: center;
}

.imputation-section.collapsed .actions button,
.imputation-section.collapsed .actions label {
    margin: 8px;
}
