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

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

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5em;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}
.spinner {
    text-align: center;
    margin: 20px 0;
}

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

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

.raw-data-details {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

.raw-data-details summary {
    cursor: pointer;
    font-weight: bold;
    color: #667eea;
    padding: 5px;
}

.raw-data-details summary:hover {
    color: #5568d3;
}

.raw-data-details pre {
    margin-top: 10px;
    padding: 10px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 12px;
    max-height: 400px;
    overflow-y: auto;
}
.header-row h1 {
    margin: 0;
}

.header-row button {
    white-space: nowrap;
}

h2 {
    color: #555;
    margin-bottom: 20px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: bold;
}

.tab-content {
    display: none;
}

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

/* Upload Section */
.upload-section {
    margin-bottom: 30px;
}

#file-input {
    padding: 10px;
    border: 2px dashed #667eea;
    border-radius: 8px;
    width: 100%;
    cursor: pointer;
}

#image-list {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 20px;
}

.image-thumb {
    width: 150px;
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s;
    cursor: pointer;
}

.image-thumb:hover {
    transform: scale(1.05);
    border-color: #667eea;
}

.image-thumb.selected {
    border: 3px solid #667eea;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
    transform: scale(1.05);
}

.image-thumb img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.image-thumb p {
    padding: 8px;
    font-size: 12px;
    text-align: center;
    background: #f5f5f5;
}

/* PDF Page Selection */
.pdf-page-item label {
    transition: all 0.2s;
}

.pdf-page-item label:hover {
    border-color: #667eea !important;
    transform: scale(1.02);
}

.pdf-page-item input[type="checkbox"]:checked + * {
    background: #e8ecfc !important;
}

.pdf-page-item input[type="checkbox"]:checked ~ * {
    border-color: #667eea !important;
}

/* Canvas Section */
.canvas-section {
    margin-top: 30px;
}

.image-selector {
    margin-bottom: 20px;
}

.image-selector label {
    font-weight: bold;
    margin-right: 10px;
}

.image-selector select {
    padding: 8px 16px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 16px;
    min-width: 300px;
}

.canvas-container {
    border: 3px solid #667eea;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
    background: #f9f9f9;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

#drawing-canvas {
    cursor: crosshair;
    max-width: 100%;
    display: block;
}

.canvas-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
}

.box-counter {
    font-weight: bold;
    color: #667eea;
    padding: 10px 20px;
    background: #f0f0f0;
    border-radius: 8px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

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

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

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

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

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

/* Analyze Section */
.analyze-section {
    margin-top: 30px;
    text-align: center;
}

#analyze-status {
    margin-top: 15px;
    padding: 15px;
    border-radius: 8px;
    font-weight: bold;
}

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

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

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

/* Results Section */
.results-summary {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    flex: 1;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    color: white;
}

.stat-card.total {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-card.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.stat-card.failed {
    background: linear-gradient(135deg, #dc3545 0%, #fd7e14 100%);
}

.stat-card h3 {
    font-size: 3em;
    margin-bottom: 10px;
}

.stat-card p {
    font-size: 1.2em;
}

#results-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.result-image {
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.result-image img {
    width: 100%;
    display: block;
}

.result-image p {
    padding: 10px;
    background: #f5f5f5;
    font-weight: bold;
}

/* Review Section */
.review-wizard {
    max-width: 1200px;
    margin: 0 auto;
}

.review-progress {
    margin-bottom: 30px;
    text-align: center;
}

.review-progress h3 {
    color: #667eea;
    margin-bottom: 10px;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s;
}

.review-card {
    border: 3px solid #667eea;
    border-radius: 12px;
    padding: 30px;
    background: #f9f9f9;
}

.part-image {
    text-align: center;
    margin-bottom: 20px;
}

.part-image img {
    max-width: 100%;
    max-height: 300px;
    border: 2px solid #ddd;
    border-radius: 8px;
}

.part-details {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.part-details label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
}

.part-details input,
.part-details select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 15px;
}

.color-selector {
    max-height: 200px;
    overflow-y: auto;
}

.color-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px;
}

.color-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #333;
    flex-shrink: 0;
}

/* Custom Color Dropdown */
.custom-color-dropdown {
    position: relative;
    width: 100%;
}

.color-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.color-dropdown-header:hover {
    border-color: #667eea;
}

.selected-color {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dropdown-arrow {
    color: #667eea;
    font-size: 12px;
}

.color-dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    margin-top: 5px;
    z-index: 1000;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.color-dropdown-list .color-option {
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.color-dropdown-list .color-option:hover {
    background: #f0f0f0;
}

.color-separator {
    padding: 8px 15px;
    background: #667eea;
    color: white;
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 1;
}

.review-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.review-status {
    text-align: center;
    padding: 15px;
    background: #f0f0f0;
    border-radius: 8px;
    border: 2px solid #ddd;
}

.review-status p {
    margin: 5px 0;
    font-weight: bold;
}

/* Export Section */
/* Export Section */
.export-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.unrecognized-section {
    margin-top: 40px;
    padding: 20px;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
}

.unrecognized-section h3 {
    color: #856404;
    margin-bottom: 10px;
}

.unrecognized-section p {
    color: #856404;
    margin-bottom: 20px;
}

.unrecognized-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.unrecognized-part {
    text-align: center;
    padding: 10px;
    background: white;
    border: 2px solid #ffc107;
    border-radius: 8px;
}

.unrecognized-part img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin-bottom: 10px;
}

.unrecognized-part p {
    font-size: 12px;
    color: #333;
    margin: 0;
}

#json-preview {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #ddd;
    max-height: 150px;
    overflow-y: auto;
    margin-top: 20px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
}

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

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

.mb-20 {
    margin-bottom: 20px;
}

.mt-20 {
    margin-top: 20px;
}
