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

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    opacity: 0.9;
    font-size: 1.1em;
}

/* Tabs */
.tabs {
    display: flex;
    background: #f5f5f5;
    border-bottom: 2px solid #ddd;
}

.tab-btn {
    flex: 1;
    padding: 18px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 500;
    color: #666;
    transition: all 0.3s;
}

.tab-btn:hover {
    background: #e8e8e8;
}

.tab-btn.active {
    background: white;
    color: #667eea;
    border-bottom: 3px solid #667eea;
}

/* Tab Content */
.tab-content {
    padding: 30px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.3s;
}

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

h2 {
    color: #333;
    margin-bottom: 20px;
}

/* Upload Zone */
.upload-zone {
    border: 3px dashed #ccc;
    border-radius: 8px;
    padding: 60px;
    text-align: center;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-icon {
    font-size: 4em;
    margin-bottom: 15px;
}

.upload-zone p {
    color: #666;
    margin-bottom: 20px;
}

/* Form */
.upload-form {
    margin-top: 30px;
}

.form-group {
    margin-bottom: 20px;
}

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

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
}

/* Upload Queue */
#uploadQueue {
    margin-top: 20px;
}

.upload-item {
    background: #f9f9f9;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.upload-item-name {
    font-weight: 500;
}

.upload-item-status {
    font-size: 0.9em;
    color: #666;
}

.status-success { color: #22c55e; }
.status-error { color: #ef4444; }
.status-processing { color: #f59e0b; }

/* Warehouse */
.warehouse-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.warehouse-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.warehouse-controls select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95em;
}

.count-badge {
    background: #667eea;
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9em;
}

/* Image Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.image-card {
    background: #f9f9f9;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.image-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

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

.image-card-body {
    padding: 15px;
}

.image-card-title {
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-card-category {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 8px;
}

.image-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tag {
    background: #e0e7ff;
    color: #667eea;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75em;
}

/* Search */
.search-box {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.search-box input {
    flex: 1;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
}

.search-examples {
    background: #f0f4ff;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.search-examples p {
    margin-bottom: 10px;
    color: #555;
}

.example-btn {
    background: white;
    border: 1px solid #667eea;
    color: #667eea;
    padding: 8px 16px;
    border-radius: 20px;
    margin: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.example-btn:hover {
    background: #667eea;
    color: white;
}

/* Search Results */
.search-result {
    background: #f9f9f9;
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 8px;
    display: flex;
    gap: 20px;
    position: relative;
}

.search-result img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 6px;
}

.search-result-body {
    flex: 1;
}

.search-result-score {
    background: #22c55e;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    display: inline-block;
    margin-bottom: 10px;
}

.search-result-title {
    font-size: 1.3em;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.search-result-category {
    color: #666;
    margin-bottom: 10px;
}

.search-result-reason {
    color: #555;
    font-style: italic;
    margin-top: 10px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 2em;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #333;
}

.modal img {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Loading & Messages */
.loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state-icon {
    font-size: 4em;
    margin-bottom: 15px;
}

.status-messages {
    margin-top: 20px;
}

.status-message {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.status-message.success {
    background: #d1fae5;
    color: #065f46;
}

.status-message.error {
    background: #fee2e2;
    color: #991b1b;
}

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

    .warehouse-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .search-result {
        flex-direction: column;
    }

    .search-result img {
        width: 100%;
        height: 200px;
    }

    .surface-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* 3D Upload Surface Grid */
.surface-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.surface-slot {
    background: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.surface-slot:hover {
    border-color: #667eea;
    background: #f0f0ff;
}

.surface-slot.has-file {
    border-style: solid;
    border-color: #667eea;
    background: #f0f0ff;
}

.surface-slot-label {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.surface-slot-preview {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 10px;
}

.surface-slot-placeholder {
    width: 100%;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    color: #ddd;
    margin-bottom: 10px;
}

.surface-slot-filename {
    font-size: 0.85em;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.surface-slot input[type="file"] {
    display: none;
}

/* 3D Model Upload Box */
.model-upload-box {
    border: 2px dashed #667eea;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #f9f9ff;
    margin-top: 10px;
}

.model-upload-box:hover {
    background: #f0f0ff;
    border-color: #5568d3;
}

.model-upload-box.has-file {
    border-style: solid;
    background: #e8f5e9;
    border-color: #4caf50;
}

.model-upload-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.model-upload-text strong {
    display: block;
    color: #667eea;
    margin-bottom: 5px;
    font-size: 1.1em;
}

.model-upload-text p {
    color: #999;
    font-size: 0.9em;
    margin: 0;
}

.model-filename {
    margin-top: 10px;
    padding: 10px;
    background: #e8f5e9;
    border-radius: 6px;
    color: #2e7d32;
    font-weight: 600;
    display: none;
}

.model-filename.visible {
    display: block;
}

/* 3D Badge */
.badge-3d {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    z-index: 10;
}

.image-card {
    position: relative;
}

/* Modal Views Grid */
.views-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

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

.view-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #ddd;
}

.view-label {
    margin-top: 8px;
    font-weight: 600;
    color: #667eea;
    text-transform: capitalize;
}

/* Download Button */
.download-section {
    margin: 20px 0;
    padding: 15px;
    background: #f0f0ff;
    border-radius: 8px;
    text-align: center;
}

.download-btn {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
