:root {
    --primary-color: #007aff;
    --primary-hover: #0056b3;
    --secondary-color: #6c757d;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-color: #212529;
    --subtle-text: #6c757d;
    --border-color: #dee2e6;
    --shadow-light: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-medium: 0 4px 8px rgba(0,0,0,0.1);
    --border-radius: 12px;
    --transition-speed: 0.3s;
    --accent-color: #3A7D44;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--text-color);
}

.nav-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 1rem;
    transition: color var(--transition-speed);
}

.nav-link:hover {
    color: var(--primary-color);
}

.card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: box-shadow var(--transition-speed);
}

.card:hover {
    box-shadow: var(--shadow-medium);
}

.card-header {
    text-align: center;
    margin-bottom: 2rem;
}

.card-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.card-header p {
    color: var(--subtle-text);
    font-size: 1.1rem;
}

#reader {
    width: 100%;
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.input-field {
    flex-grow: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,122,255,0.25);
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--transition-speed), transform var(--transition-speed);
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.results-container {
    margin-top: 2rem;
}

.result-card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.product-header {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.product-image {
    width: 100px;
    height: 100px;
    border-radius: var(--border-radius);
    object-fit: cover;
    background-color: #f0f0f0;
}

.product-info {
    flex-grow: 1;
}

.product-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.product-barcode {
    color: var(--subtle-text);
    font-size: 0.9rem;
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
}

.product-reviews-container {
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
}

.product-reviews {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.review-stars {
    color: #FFB800;
    font-size: 1.1rem;
    letter-spacing: 2px;
}

.review-score {
    font-weight: 600;
    color: var(--text-primary);
}

.review-count {
    color: var(--subtle-text);
    font-size: 0.9rem;
}

.product-description {
    color: var(--subtle-text);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.specifications-section {
    margin-top: 5rem;
    width: 100%;
}

.specifications-section .result-card {
    background: var(--background);
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.specifications-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-color);
}

/* Grid-based specifications layout */
.specifications-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    width: 100%;
}

.spec-card {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    transition: box-shadow 0.2s ease;
}

.spec-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.spec-card .spec-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--subtle-text);
    text-transform: capitalize;
    margin-bottom: 0.5rem;
    display: block;
}

.spec-card .spec-value {
    font-size: 0.95rem;
    color: var(--text-color);
    font-weight: 400;
    line-height: 1.5;
    word-wrap: break-word;
}

/* Fallback table layout (legacy) */
.specifications-table {
    width: 100%;
    border-collapse: collapse;
    display: none; /* Hidden by default, grid is primary */
}

.specifications-table tbody tr {
    border-bottom: 1px solid var(--border-color);
}

.specifications-table tbody tr:nth-child(even) {
    background-color: rgba(127, 176, 105, 0.08);
}

.specifications-table tbody tr:nth-child(odd) {
    background-color: rgba(127, 176, 105, 0.03);
}

.specifications-table tbody tr:last-child {
    border-bottom: none;
}

.specifications-table td {
    padding: 0.5rem 0;
    font-size: 0.9rem;
}

.specifications-table .spec-label {
    color: var(--subtle-text);
    font-weight: 500;
    width: 45%;
    padding-right: 1rem;
}

.specifications-table .spec-value {
    color: var(--text-color);
    font-weight: 400;
}

/* Container for images and specifications preview (side by side) */
.product-images-specs-container {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    margin-top: 1rem;
}

/* Specifications Preview (next to product images) */
.specifications-preview {
    flex: 1;
    min-width: 250px;
    background: var(--background);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.specifications-preview-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 0.75rem 0;
}

.specifications-preview-table {
    width: 100%;
    border-collapse: collapse;
}

.specifications-preview-table tr {
    border-bottom: 1px solid var(--border-color);
}

.specifications-preview-table tr:last-child {
    border-bottom: none;
}

.specifications-preview-table td {
    padding: 0.75rem;
    font-size: 0.85rem;
}

.specifications-preview-table .spec-label {
    color: var(--subtle-text);
    font-weight: 500;
    width: 45%;
}

.specifications-preview-table .spec-value {
    color: var(--text-color);
    font-weight: 400;
}

.offers-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.offers-table th, .offers-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.offers-table th {
    color: var(--subtle-text);
    font-weight: 500;
}

.offers-table .price {
    font-weight: 600;
    color: var(--primary-color);
}

.offers-table tbody tr:first-child {
    background-color: rgba(0, 122, 255, 0.05);
}

.offers-table tbody tr:hover {
    background-color: rgba(0, 122, 255, 0.1);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.offers-table-container {
    overflow-x: auto;
}

.loading-message {
    text-align: center;
    color: var(--subtle-text);
    font-style: italic;
}

.setting-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
    transition: opacity var(--transition-speed);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #e0e0e0;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.hidden {
    display: none;
}

@media (max-width: 600px) {
    .app-container {
        padding: 1rem 0.5rem;
    }

    .card {
        padding: 1.5rem;
    }

    .input-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* Mascot Loading Indicator */
.mascot-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 30px;
    background: linear-gradient(135deg, #e3f2fd 0%, #fff5f5 50%, #fef3ff 100%);
    border-radius: 25px;
    box-shadow: 0 8px 32px rgba(135, 206, 235, 0.2), 0 4px 16px rgba(255, 105, 180, 0.1);
    position: relative;
    overflow: hidden;
    min-height: 280px;
}

.mascot-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 182, 193, 0.1), transparent);
    animation: sparkle 3s linear infinite;
}

.mascot-image {
    width: 150px;
    height: auto;
    animation: bounce 2s ease-in-out infinite, wiggle 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(255, 105, 180, 0.3));
    z-index: 1;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.mascot-message {
    margin-top: 20px;
    font-size: 1.2rem;
    color: #ff69b4;
    font-weight: 500;
    animation: pulse 1.5s ease-in-out infinite;
    z-index: 1;
}

/* Kawaii sparkles */
.mascot-container::after {
    content: '✨';
    position: absolute;
    font-size: 24px;
    animation: sparkle-rotate 4s linear infinite;
    top: 20px;
    right: 20px;
}

@keyframes bounce {
    0%, 100% { 
        transform: translateY(0) scale(1) rotate(0deg); 
    }
    25% { 
        transform: translateY(-20px) scale(1.1) rotate(-3deg); 
    }
    50% { 
        transform: translateY(-10px) scale(1.05) rotate(0deg); 
    }
    75% { 
        transform: translateY(-15px) scale(1.08) rotate(3deg); 
    }
}

@keyframes wiggle {
    0%, 100% { 
        transform: rotate(0deg); 
    }
    25% { 
        transform: rotate(-5deg); 
    }
    75% { 
        transform: rotate(5deg); 
    }
}

@keyframes pulse {
    0%, 100% { 
        opacity: 0.8; 
    }
    50% { 
        opacity: 1; 
    }
}

@keyframes sparkle {
    0% { 
        transform: translate(-100%, -100%) rotate(0deg); 
    }
    100% { 
        transform: translate(100%, 100%) rotate(360deg); 
    }
}

@keyframes sparkle-rotate {
    0% { 
        transform: rotate(0deg) scale(1); 
        opacity: 1;
    }
    50% { 
        transform: rotate(180deg) scale(1.2); 
        opacity: 0.6;
    }
    100% { 
        transform: rotate(360deg) scale(1); 
        opacity: 1;
    }
}

/* Kawaii stars */
.kawaii-stars {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.star {
    position: absolute;
    font-size: 20px;
    animation: twinkle 3s ease-in-out infinite;
}

.star-1 {
    top: 10px;
    left: 20px;
    animation-delay: 0s;
}

.star-2 {
    top: 30px;
    right: 30px;
    animation-delay: 1s;
    font-size: 16px;
}

.star-3 {
    bottom: 40px;
    left: 40px;
    animation-delay: 2s;
    font-size: 24px;
}

@keyframes twinkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 0.3;
    }
    50% {
        transform: scale(1.3) rotate(180deg);
        opacity: 1;
    }
}

/* Cloud decorations */
.cloud-decorations {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.cloud {
    position: absolute;
    font-size: 30px;
    opacity: 0.3;
    animation: float-cloud 20s ease-in-out infinite;
}

.cloud-1 {
    top: 20%;
    left: -10%;
    animation-delay: 0s;
    animation-duration: 18s;
}

.cloud-2 {
    top: 60%;
    right: -10%;
    animation-delay: 7s;
    animation-duration: 22s;
    font-size: 25px;
}

.cloud-3 {
    top: 40%;
    left: -10%;
    animation-delay: 14s;
    animation-duration: 25s;
    font-size: 35px;
}

@keyframes float-cloud {
    0% {
        transform: translateX(0) translateY(0);
    }
    100% {
        transform: translateX(calc(100vw + 100px)) translateY(-20px);
    }
}

/* Loading dots */
.loading-dots {
    margin-top: 10px;
    display: flex;
    gap: 5px;
    justify-content: center;
    z-index: 1;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ff69b4;
    animation: dot-bounce 1.4s ease-in-out infinite;
}

.dot-1 {
    animation-delay: -0.32s;
}

.dot-2 {
    animation-delay: -0.16s;
}

.dot-3 {
    animation-delay: 0s;
}

@keyframes dot-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Text Search Results Styles */
.search-results-grid {
    padding: 2rem;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.product-card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-light);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
}

.product-card-image {
    width: 100%;
    height: 200px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 1rem;
}

.product-card-content {
    padding: 1rem;
}

.product-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    background: var(--background-color);
    border-radius: 2rem;
    font-size: 0.8rem;
}

.source-name {
    font-weight: 500;
    color: var(--subtle-text);
    text-transform: capitalize;
}

.source-price {
    font-weight: 600;
    color: var(--accent-color);
}

.multiple-sources-indicator {
    font-size: 0.8rem;
    color: var(--accent-color);
    font-weight: 500;
}

/* Thumbnail Gallery Navigation */
.thumbnail-gallery-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.thumbnail-images-container {
    display: flex;
    gap: 0.5rem;
    overflow: hidden;
    flex: 1;
}

.thumbnail-nav-arrow {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-speed), transform var(--transition-speed);
    flex-shrink: 0;
}

.thumbnail-nav-arrow:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.thumbnail-nav-arrow:active {
    transform: scale(0.95);
}

.thumbnail-nav-left {
    margin-right: 0.25rem;
}

.thumbnail-nav-right {
    margin-left: 0.25rem;
}

.product-thumbnails {
    margin-top: 1rem;
}

.product-thumbnails .product-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    flex-shrink: 0;
}

.product-thumbnails .product-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}
    }
}

/* =====================================================
   SKU IMAGE GALLERY - HORIZONTAL FLEXBOX LAYOUT
   New approach: flexbox with wrap for guaranteed horizontal display
   ===================================================== */

/* Main gallery container - uses flexbox for reliability */
.sku-gallery {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 20px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 20px !important;
    box-sizing: border-box !important;
    justify-content: center !important;
    background: transparent !important;
}

/* Each image cell - 150px as requested */
.gallery-cell {
    flex: 0 0 150px !important;
    width: 150px !important;
    height: 150px !important;
    min-width: 150px !important;
    min-height: 150px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    cursor: pointer !important;
    background: white !important;
    transition: transform 0.2s, box-shadow 0.2s !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    margin: 0 !important;
}

.gallery-cell:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15) !important;
}

/* Image styling - add padding inside the cell */
.gallery-photo {
    width: calc(100% - 20px) !important;
    height: calc(100% - 20px) !important;
    max-width: 130px !important;
    max-height: 130px !important;
    object-fit: contain !important;
    padding: 0 !important;
    margin: 10px !important;
}

/* Mobile: smaller images, centered */
@media (max-width: 640px) {
    .sku-gallery {
        gap: 16px !important;
        padding: 16px !important;
        justify-content: center !important;
    }

    .gallery-cell {
        flex: 0 0 100px !important;
        width: 100px !important;
        height: 100px !important;
        min-width: 100px !important;
        min-height: 100px !important;
    }

    .gallery-photo {
        width: calc(100% - 16px) !important;
        height: calc(100% - 16px) !important;
        max-width: 84px !important;
        max-height: 84px !important;
        margin: 8px !important;
    }

    .product-images-specs-container {
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
}

/* Tablet: medium sized images */
@media (min-width: 641px) and (max-width: 1024px) {
    .sku-gallery {
        gap: 18px !important;
    }

    .gallery-cell {
        flex: 0 0 120px !important;
        width: 120px !important;
        height: 120px !important;
        min-width: 120px !important;
        min-height: 120px !important;
    }

    .gallery-photo {
        max-width: 100px !important;
        max-height: 100px !important;
    }
}

/* Desktop: 150px images as requested */
@media (min-width: 1025px) {
    .sku-gallery {
        gap: 20px !important;
    }

    .gallery-cell {
        flex: 0 0 150px !important;
        width: 150px !important;
        height: 150px !important;
        min-width: 150px !important;
        min-height: 150px !important;
    }

    .gallery-photo {
        max-width: 130px !important;
        max-height: 130px !important;
    }
}

/* Single image: make it larger and centered */
.sku-gallery.single-image .gallery-cell {
    flex: 0 0 300px !important;
    width: 300px !important;
    height: 300px !important;
    min-width: 300px !important;
    min-height: 300px !important;
}

.sku-gallery.single-image .gallery-photo {
    max-width: 280px !important;
    max-height: 280px !important;
}

.sku-gallery.single-image {
    justify-content: center !important;
}
