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

:root {
    --primary: #0066cc;
    --primary-dark: #0052a3;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-600: #6c757d;
    --gray-800: #343a40;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--gray-800);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* Sections */
section {
    padding: 30px 40px;
    border-bottom: 1px solid var(--gray-200);
}

section:last-of-type {
    border-bottom: none;
}

section h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--gray-800);
}

/* Collections */
.collections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.collection-card {
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.collection-card:hover {
    background: var(--gray-200);
    transform: translateY(-2px);
}

.collection-info h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.collection-info p {
    font-size: 0.85rem;
    color: var(--gray-600);
}

.collection-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.collection-actions {
    display: flex;
    gap: 8px;
}

.btn-icon-small {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.btn-icon-small:hover {
    opacity: 1;
}

/* Supported Types */
.supported-types {
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
}

.supported-types h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
    margin-bottom: 12px;
}

.supported-types ul {
    list-style: none;
}

.supported-types li {
    padding: 8px 0;
    border-bottom: 1px dashed var(--gray-300);
}

.supported-types li:last-child {
    border-bottom: none;
}

.supported-types li strong {
    color: var(--primary);
}

.supported-types .hint {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-300);
    font-size: 0.85rem;
    color: var(--gray-600);
}

.hint-text {
    display: block;
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--gray-600);
}

input[type="number"],
input[type="text"] {
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
}

input[type="number"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

/* Form */
.upload-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: start;
}

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

.form-group label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--gray-800);
}

/* File Input */
.file-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    background: var(--gray-100);
}

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

.file-label.has-file {
    border-color: var(--success);
    background: #d4edda;
}

.file-icon {
    font-size: 2rem;
}

.file-text {
    font-weight: 500;
}

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

.file-name {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-top: 4px;
}

/* Select */
select {
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 1rem;
    background: white;
    cursor: pointer;
    min-width: 280px;
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}

/* Checkbox */
.checkbox-group {
    margin-top: 28px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 24px;
    height: 24px;
    border: 2px solid var(--gray-300);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.checkmark::after {
    content: '✓';
    color: white;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: var(--danger);
    border-color: var(--danger);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    opacity: 1;
}

.checkbox-text {
    color: var(--danger);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-800);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

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

.btn-danger:hover {
    background: #c82333;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Progress */
.progress {
    margin-top: 20px;
}

.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--info));
    width: 0%;
    animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; margin-left: 0; }
    50% { width: 70%; margin-left: 15%; }
    100% { width: 0%; margin-left: 100%; }
}

.progress-text {
    text-align: center;
    margin-top: 12px;
    color: var(--gray-600);
    font-size: 0.9rem;
}

/* Result */
.result-section {
    background: #d4edda;
}

.result-box {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

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

.stat-item {
    text-align: center;
    padding: 16px;
    background: var(--gray-100);
    border-radius: var(--radius);
}

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

.stat-label {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-top: 4px;
}

.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }

.result-file {
    padding: 12px;
    background: var(--gray-100);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.result-file strong {
    color: var(--primary);
}

.errors-list {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
}

.errors-list h4 {
    color: #721c24;
    margin-bottom: 8px;
}

.errors-list ul {
    margin-left: 20px;
    color: #721c24;
}

.errors-list li {
    margin: 4px 0;
    font-size: 0.9rem;
}

/* Error Section */
.error-section {
    background: #f8d7da;
}

.error-box {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    color: #721c24;
    box-shadow: var(--shadow);
}

/* Preview */
.preview-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.preview-content {
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 20px;
    min-height: 200px;
    max-height: 500px;
    overflow: auto;
}

.placeholder {
    text-align: center;
    color: var(--gray-600);
    padding: 40px;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.preview-table th,
.preview-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-300);
}

.preview-table th {
    background: var(--gray-200);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.preview-table tr:hover {
    background: white;
}

.preview-info {
    padding: 12px;
    background: #cce5ff;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: var(--radius-lg);
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 16px;
}

.modal-content p {
    margin-bottom: 24px;
    color: var(--gray-600);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Footer */
footer {
    background: var(--gray-100);
    padding: 20px 40px;
    text-align: center;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.mongo-status {
    margin-top: 8px;
    font-size: 0.85rem;
}

#db-status.connected {
    color: var(--success);
}

#db-status.error {
    color: var(--danger);
}

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

.loading {
    text-align: center;
    padding: 40px;
    color: var(--gray-600);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header {
        padding: 24px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    section {
        padding: 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .checkbox-group {
        margin-top: 0;
    }
}
