* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.scanner-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    color: #666;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Upload Area */
.upload-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(102, 126, 234, 0.05);
}

.upload-area:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: #764ba2;
}

.upload-area.dragover {
    background: rgba(102, 126, 234, 0.2);
    border-color: #764ba2;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4em;
    margin-bottom: 15px;
}

.upload-text {
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.upload-hint {
    font-size: 0.9em;
    color: #666;
}

.upload-preview {
    text-align: center;
}

.upload-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.upload-preview .btn {
    margin: 5px;
}

/* Search All Toggle */
.search-all-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    padding: 15px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 10px;
}

.toggle-label {
    font-weight: 600;
    color: #333;
    font-size: 1em;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 30px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #667eea;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(30px);
}

/* All Results Container */
.all-results-container {
    margin-top: 20px;
    animation: fadeIn 0.5s ease;
}

.all-results-title {
    color: #333;
    font-size: 1.5em;
    margin-bottom: 20px;
    text-align: center;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.result-item {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.result-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.result-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    gap: 10px;
}

.result-item-header h4 {
    color: #333;
    font-size: 1.1em;
    margin: 0;
    flex: 1;
    word-wrap: break-word;
}

.result-item-header .source-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.result-item-image {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.result-item-image .no-image {
    text-align: center;
    color: #999;
    padding: 20px;
}

.result-item-image .no-image span {
    font-size: 2em;
    display: block;
    margin-bottom: 5px;
}

.camera-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto 20px;
    border-radius: 15px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 4/3;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.scan-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 40%;
    border: 2px solid rgba(255, 255, 255, 0.8);
}

.corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid #4CAF50;
}

.corner.top-left {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
}

.corner.top-right {
    top: -3px;
    right: -3px;
    border-left: none;
    border-bottom: none;
}

.corner.bottom-left {
    bottom: -3px;
    left: -3px;
    border-right: none;
    border-top: none;
}

.corner.bottom-right {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
}

.scan-line {
    position: absolute;
    top: 50%;
    left: 15%;
    width: 70%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #4CAF50, transparent);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0%, 100% {
        transform: translateY(-50%);
    }
    50% {
        transform: translateY(50%);
    }
}

.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.manual-input {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

#barcodeInput {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    transition: border-color 0.3s;
}

#barcodeInput:focus {
    outline: none;
    border-color: #667eea;
}

.result-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.result-card {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.result-header h2 {
    color: #333;
    font-size: 1.8em;
    flex: 1;
}

.source-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    text-transform: uppercase;
}

.product-image-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border-radius: 15px;
    overflow: hidden;
    background: #f5f5f5;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#productImage {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.no-image {
    text-align: center;
    color: #999;
    padding: 40px;
}

.no-image .icon {
    font-size: 4em;
    display: block;
    margin-bottom: 10px;
}

.error-card {
    text-align: center;
    padding: 40px;
    animation: fadeIn 0.5s ease;
}

.error-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

.error-card h3 {
    color: #dc3545;
    margin-bottom: 10px;
    font-size: 1.5em;
}

.error-card p {
    color: #666;
    line-height: 1.6;
}

.status {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: white;
    font-weight: 600;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status.success {
    background: rgba(76, 175, 80, 0.8);
}

.status.error {
    background: rgba(220, 53, 69, 0.8);
}

.icon {
    font-size: 1.2em;
}

@media (max-width: 600px) {
    header h1 {
        font-size: 2em;
    }

    .scanner-section,
    .result-section {
        padding: 20px;
    }

    .controls {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .manual-input {
        flex-direction: column;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }
}

