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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
}

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

.subtitle {
    color: #7f8c8d;
    font-size: 1rem;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card h2 {
    font-size: 1.25rem;
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ecf0f1;
}

.hidden {
    display: none !important;
}

/* Upload area */
.upload-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.file-input label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: #2c3e50;
}

.dropzone {
    border: 2px dashed #bdc3c7;
    border-radius: 8px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: #3498db;
    background-color: #f0f7ff;
}

.dropzone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone-text {
    color: #7f8c8d;
    display: block;
}

.file-name {
    color: #27ae60;
    font-weight: 500;
    display: block;
    margin-top: 8px;
}

/* Form elements */
.form-row {
    display: flex;
    align-items: flex-end;
    gap: 20px;
}

.form-group {
    flex: 1;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: #2c3e50;
}

input[type="number"],
select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #dce0e4;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #3498db;
}

/* Buttons */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #2980b9;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background-color: #219a52;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #7f8c8d;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: #c0392b;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.875rem;
}

/* Progress */
.progress-container {
    padding: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #ecf0f1;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    margin-bottom: 15px;
    color: #7f8c8d;
}

#progress-percent {
    font-weight: 600;
    color: #3498db;
}

#stop-btn {
    display: block;
    margin: 0 auto;
}

/* Stats bar */
.stats-bar {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.stat {
    flex: 1;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}

.stat.linked {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}

.stat.needs-review {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
}

.stat.not-linked {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}

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

.stat.linked .stat-value { color: #155724; }
.stat.needs-review .stat-value { color: #856404; }
.stat.not-linked .stat-value { color: #721c24; }

.stat-label {
    color: #666;
    font-size: 0.875rem;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.filters {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid #dce0e4;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: #3498db;
}

.filter-btn.active {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

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

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
    position: sticky;
    top: 0;
}

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

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-linked {
    background-color: #d4edda;
    color: #155724;
}

.status-needs_review {
    background-color: #fff3cd;
    color: #856404;
}

.status-not_linked {
    background-color: #f8d7da;
    color: #721c24;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 8px;
}

/* Diff highlighting */
.diff-remove {
    background-color: #ffcccc;
    color: #c00;
    padding: 1px 2px;
    border-radius: 2px;
}

.diff-add {
    background-color: #ccffcc;
    color: #060;
    padding: 1px 2px;
    border-radius: 2px;
}

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

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #ecf0f1;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #7f8c8d;
}

.modal-close:hover {
    color: #2c3e50;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

#code-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #dce0e4;
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 16px;
}

#code-input:focus {
    outline: none;
    border-color: #3498db;
}

#save-code-btn {
    width: 100%;
}

/* Responsive */
@media (max-width: 768px) {
    .upload-area {
        grid-template-columns: 1fr;
    }

    .form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .stats-bar {
        flex-direction: column;
    }

    .toolbar {
        flex-direction: column;
        gap: 16px;
    }

    .filters {
        flex-wrap: wrap;
    }
}
