/* ============================================
   Products CSS - Catalog list & detail screens
   ============================================ */

/* ============================================
   Products List Screen
   ============================================ */
.products-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

.products-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: calc(var(--safe-top) + var(--space-md)) var(--space-md) var(--space-sm);
    background: var(--bg-primary);
    z-index: 5;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.products-header h2 {
    flex: 1;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--accent-light);
}

.products-header .products-count {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-weight: 400;
}

/* Search bar */
.products-search {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 4;
    flex-shrink: 0;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper svg {
    position: absolute;
    left: var(--space-sm);
    width: 18px;
    height: 18px;
    stroke: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md) var(--space-sm) 36px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-clear {
    position: absolute;
    right: var(--space-xs);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-muted);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.search-clear.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Product list */
.products-list {
    flex: 1;
    padding: var(--space-sm) var(--space-md) calc(72px + var(--safe-bottom) + var(--space-sm));
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Product card */
.product-card {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.product-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-glow);
}

.product-card-thumb {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-input);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-card-thumb .thumb-placeholder {
    width: 32px;
    height: 32px;
    stroke: var(--text-muted);
    opacity: 0.4;
}

.product-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    justify-content: center;
}

.product-card-title {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.product-card-category {
    display: inline-block;
    padding: 2px var(--space-sm);
    background: rgba(0, 90, 134, 0.15);
    color: var(--accent-light);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.product-card-code {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.product-card-indicators {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-top: 2px;
}

.indicator-dot {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    color: var(--text-muted);
}

.indicator-dot svg {
    width: 12px;
    height: 12px;
}

.indicator-dot.active svg {
    stroke: var(--success);
}

.indicator-dot.inactive svg {
    stroke: var(--text-muted);
    opacity: 0.4;
}

.indicator-dot.indicator-gift.active svg {
    stroke: #d4a017;
}

.indicator-dot.indicator-macro.active svg {
    stroke: #17a2b8;
}

/* Long press visual feedback */
.product-card.long-press {
    background: rgba(255, 71, 87, 0.1);
    border-color: rgba(255, 71, 87, 0.4);
}

/* Empty state */
.products-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
    color: var(--text-muted);
    gap: var(--space-md);
}

.products-empty svg {
    width: 64px;
    height: 64px;
    stroke: var(--text-muted);
    opacity: 0.3;
}

.products-empty p {
    font-size: var(--font-size-sm);
}

/* Loading state */
.products-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
}

.products-loading .mini-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Load more button */
.products-load-more {
    padding: var(--space-md);
    text-align: center;
}

.btn-load-more {
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--accent-light);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-load-more:active {
    background: var(--bg-input);
}


/* ============================================
   Product Detail Screen
   ============================================ */
.product-detail-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background: var(--bg-primary);
}

.product-detail-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: calc(var(--safe-top) + var(--space-md)) var(--space-md) var(--space-md);
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 5;
    border-bottom: 1px solid var(--border-color);
}

.product-detail-header h2 {
    flex: 1;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--accent-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Detail image section */
.product-detail-images {
    position: relative;
}

/* Regenerate buttons */
.regenerate-actions {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    overflow-x: auto;
}

.btn-regenerate {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--accent-light);
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-regenerate:active {
    background: var(--bg-input);
}

.btn-regenerate svg {
    width: 14px;
    height: 14px;
    stroke: var(--accent);
    flex-shrink: 0;
}

.btn-regenerate.loading {
    opacity: 0.6;
    pointer-events: none;
}

.btn-regenerate.loading svg {
    animation: spin 0.8s linear infinite;
}

.btn-regenerate-gift {
    color: #d4a017;
    border-color: rgba(212, 160, 23, 0.3);
}

.btn-regenerate-gift svg {
    stroke: #d4a017;
}

.btn-regenerate-macro {
    color: #17a2b8;
    border-color: rgba(23, 162, 184, 0.3);
}

.btn-regenerate-macro svg {
    stroke: #17a2b8;
}

/* Detail cards section - reuses analysis-cards from results.css */
.product-detail-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
    padding: var(--space-md);
}

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* --- Phone landscape / large phone (480px+) --- */
@media (min-width: 480px) {
    .products-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- Small tablet (600px+) --- */
@media (min-width: 600px) {
    .product-detail-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .product-card-thumb {
        width: 84px;
        height: 84px;
    }

    .product-card-title {
        font-size: var(--font-size-lg);
    }

    .detail-thumb-card {
        width: 140px;
    }

    .detail-thumb-card img,
    .thumb-img-wrap,
    .thumb-img-wrap img,
    .detail-thumb-card .thumb-placeholder {
        width: 140px;
        height: 140px;
    }
}

/* --- Tablet portrait (768px+) --- */
@media (min-width: 768px) {
    .products-header,
    .product-detail-header {
        padding-left: var(--space-lg);
        padding-right: var(--space-lg);
    }

    .products-header h2,
    .product-detail-header h2 {
        font-size: var(--font-size-xl);
    }

    .products-search {
        padding: var(--space-sm) var(--space-lg);
    }

    .products-list {
        padding: var(--space-md) var(--space-lg) calc(72px + var(--safe-bottom) + var(--space-md));
        gap: var(--space-md);
    }

    .product-detail-cards {
        padding: var(--space-lg);
        gap: var(--space-lg);
    }

    .regenerate-actions {
        padding: var(--space-sm) var(--space-lg);
    }

    .detail-image-thumbs {
        padding: var(--space-lg);
        gap: var(--space-md);
    }

    .social-post-textarea {
        min-height: 160px;
        font-size: var(--font-size-md);
    }
}

/* --- Tablet landscape / small desktop (1024px+) --- */
@media (min-width: 1024px) {
    .products-list {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-lg);
        padding: var(--space-lg) var(--space-xl) calc(64px + var(--safe-bottom) + var(--space-lg));
    }

    .products-header,
    .product-detail-header {
        padding-left: var(--space-xl);
        padding-right: var(--space-xl);
    }

    .products-search {
        padding: var(--space-sm) var(--space-xl);
    }

    .search-input {
        max-width: 400px;
    }

    .product-card:hover {
        border-color: var(--accent-glow);
        box-shadow: var(--shadow-md);
        transform: translateY(-1px);
    }

    .product-detail-cards {
        max-width: 1000px;
        margin: 0 auto;
    }

    .detail-image-thumbs {
        justify-content: center;
    }

    .detail-thumb-card {
        width: 160px;
    }

    .detail-thumb-card img,
    .thumb-img-wrap,
    .thumb-img-wrap img,
    .detail-thumb-card .thumb-placeholder {
        width: 160px;
        height: 160px;
    }

    .merge-action-bar,
    .thumb-select-bar {
        max-width: 800px;
        margin: 0 auto;
        left: 50%;
        transform: translateX(-50%);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .viewer-action-btn {
        width: 48px;
        height: 48px;
    }
}

/* --- Desktop (1366px+) --- */
@media (min-width: 1366px) {
    .products-list {
        grid-template-columns: repeat(4, 1fr);
        max-width: 1400px;
        margin: 0 auto;
    }

    .products-header,
    .product-detail-header {
        max-width: 1400px;
        margin: 0 auto;
        width: 100%;
        padding-left: var(--space-2xl);
        padding-right: var(--space-2xl);
    }

    .products-search {
        max-width: 1400px;
        margin: 0 auto;
        padding: var(--space-sm) var(--space-2xl);
    }

    .product-card {
        padding: var(--space-md) var(--space-lg);
    }

    .product-card-thumb {
        width: 96px;
        height: 96px;
    }

    .product-detail-cards {
        max-width: 1200px;
        grid-template-columns: repeat(3, 1fr);
    }
}

/* --- 2K / Full HD+ (1920px+) --- */
@media (min-width: 1920px) {
    .products-list {
        max-width: 1800px;
        gap: var(--space-xl);
    }

    .products-header,
    .product-detail-header {
        max-width: 1800px;
    }

    .products-search {
        max-width: 1800px;
    }

    .product-card {
        padding: var(--space-lg) var(--space-xl);
    }

    .product-card-thumb {
        width: 108px;
        height: 108px;
        border-radius: var(--radius-lg);
    }

    .product-card-title {
        font-size: var(--font-size-xl);
    }

    .product-card-category {
        font-size: var(--font-size-sm);
        padding: var(--space-xs) var(--space-md);
    }

    .search-input {
        padding: var(--space-md) var(--space-lg) var(--space-md) 44px;
        font-size: var(--font-size-md);
    }

    .product-detail-cards {
        max-width: 1400px;
    }

    .detail-thumb-card {
        width: 180px;
    }

    .detail-thumb-card img,
    .thumb-img-wrap,
    .thumb-img-wrap img,
    .detail-thumb-card .thumb-placeholder {
        width: 180px;
        height: 180px;
    }

    .detail-thumb-card .thumb-label {
        font-size: var(--font-size-sm);
        padding: var(--space-xs) var(--space-sm);
    }

    .social-post-textarea {
        font-size: var(--font-size-lg);
        min-height: 180px;
    }

    .viewer-action-btn {
        width: 52px;
        height: 52px;
    }
}

/* --- 3K (2560px+) --- */
@media (min-width: 2560px) {
    .products-list {
        grid-template-columns: repeat(5, 1fr);
        max-width: 2400px;
    }

    .products-header,
    .product-detail-header {
        max-width: 2400px;
    }

    .products-search {
        max-width: 2400px;
    }

    .products-header h2,
    .product-detail-header h2 {
        font-size: var(--font-size-2xl);
    }

    .product-card {
        padding: var(--space-xl) var(--space-2xl);
        border-radius: var(--radius-xl);
    }

    .product-card-thumb {
        width: 128px;
        height: 128px;
        border-radius: var(--radius-xl);
    }

    .product-card-title {
        font-size: var(--font-size-2xl);
    }

    .product-card-category {
        font-size: var(--font-size-md);
    }

    .product-card-code {
        font-size: var(--font-size-sm);
    }

    .indicator-dot svg {
        width: 18px;
        height: 18px;
    }

    .search-input {
        max-width: 500px;
        padding: var(--space-md) var(--space-xl) var(--space-md) 52px;
        font-size: var(--font-size-lg);
    }

    .search-input-wrapper svg {
        width: 24px;
        height: 24px;
    }

    .product-detail-cards {
        max-width: 1800px;
        gap: var(--space-xl);
    }

    .detail-thumb-card {
        width: 220px;
        border-radius: var(--radius-lg);
    }

    .detail-thumb-card img,
    .thumb-img-wrap,
    .thumb-img-wrap img,
    .detail-thumb-card .thumb-placeholder {
        width: 220px;
        height: 220px;
    }

    .detail-thumb-card .thumb-label {
        font-size: var(--font-size-md);
    }

    .regenerate-actions {
        gap: var(--space-md);
        justify-content: center;
    }

    .btn-regenerate {
        padding: var(--space-md) var(--space-lg);
        font-size: var(--font-size-md);
        border-radius: var(--radius-lg);
    }

    .btn-regenerate svg {
        width: 20px;
        height: 20px;
    }

    .viewer-action-btn {
        width: 60px;
        height: 60px;
    }

    .image-viewer-title {
        font-size: var(--font-size-lg);
    }

    .social-post-textarea {
        font-size: var(--font-size-xl);
    }

    .social-post-copy-btn {
        font-size: var(--font-size-md);
        padding: var(--space-sm) var(--space-lg);
    }

    .btn-load-more {
        font-size: var(--font-size-md);
        padding: var(--space-md) var(--space-xl);
    }
}

/* --- 4K (3840px+) --- */
@media (min-width: 3840px) {
    .products-list {
        grid-template-columns: repeat(6, 1fr);
        max-width: 3600px;
        gap: var(--space-2xl);
    }

    .products-header,
    .product-detail-header {
        max-width: 3600px;
    }

    .products-search {
        max-width: 3600px;
    }

    .products-header h2,
    .product-detail-header h2 {
        font-size: var(--font-size-3xl);
    }

    .product-card {
        padding: var(--space-2xl);
        border-width: 2px;
        border-radius: 20px;
    }

    .product-card-thumb {
        width: 160px;
        height: 160px;
        border-radius: 16px;
    }

    .product-card-title {
        font-size: var(--font-size-3xl);
    }

    .product-card-category {
        font-size: var(--font-size-lg);
        padding: var(--space-sm) var(--space-lg);
    }

    .product-card-code {
        font-size: var(--font-size-md);
    }

    .indicator-dot {
        font-size: var(--font-size-sm);
    }

    .indicator-dot svg {
        width: 22px;
        height: 22px;
    }

    .search-input {
        max-width: 600px;
        padding: var(--space-lg) var(--space-2xl) var(--space-lg) 64px;
        font-size: var(--font-size-xl);
        border-width: 2px;
    }

    .search-input-wrapper svg {
        width: 28px;
        height: 28px;
        left: var(--space-md);
    }

    .product-detail-cards {
        max-width: 2600px;
        gap: var(--space-2xl);
    }

    .detail-thumb-card {
        width: 280px;
        border-radius: 16px;
        border-width: 3px;
    }

    .detail-thumb-card img,
    .thumb-img-wrap,
    .thumb-img-wrap img,
    .detail-thumb-card .thumb-placeholder {
        width: 280px;
        height: 280px;
    }

    .detail-thumb-card .thumb-label {
        font-size: var(--font-size-lg);
        padding: var(--space-sm);
    }

    .regenerate-actions {
        gap: var(--space-lg);
    }

    .btn-regenerate {
        padding: var(--space-lg) var(--space-xl);
        font-size: var(--font-size-lg);
        border-radius: var(--radius-xl);
        border-width: 2px;
    }

    .btn-regenerate svg {
        width: 24px;
        height: 24px;
    }

    .viewer-action-btn {
        width: 72px;
        height: 72px;
    }

    .viewer-action-btn svg {
        width: 32px;
        height: 32px;
    }

    .image-viewer-title {
        font-size: var(--font-size-xl);
    }

    .social-post-textarea {
        font-size: var(--font-size-2xl);
        min-height: 240px;
        border-width: 2px;
    }

    .social-post-copy-btn {
        font-size: var(--font-size-lg);
        padding: var(--space-md) var(--space-xl);
    }

    .btn-load-more {
        font-size: var(--font-size-lg);
        padding: var(--space-md) var(--space-2xl);
        border-width: 2px;
    }

    .dimension-row {
        grid-template-columns: 1fr 120px 120px 48px;
        gap: var(--space-md);
    }

    .dim-input {
        padding: 14px var(--space-md);
        font-size: var(--font-size-lg);
    }

    .child-card {
        padding: var(--space-lg);
        gap: var(--space-lg);
    }

    .child-thumb {
        width: 72px;
        height: 72px;
    }

    .child-title {
        font-size: var(--font-size-lg);
    }

    .child-color-dot {
        width: 22px;
        height: 22px;
    }

    .merge-badge {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .parent-badge {
        font-size: var(--font-size-sm);
        padding: var(--space-xs) var(--space-md);
    }

    .parent-badge svg {
        width: 18px;
        height: 18px;
    }

    .nav-label {
        font-size: var(--font-size-xs);
    }

    .nav-item svg {
        width: 28px;
        height: 28px;
    }
}

/* --- Landscape phone (compact height) --- */
@media (max-height: 500px) and (orientation: landscape) {
    .product-detail-container,
    .queue-container,
    .results-container,
    .processing-container {
        padding-bottom: calc(52px + var(--safe-bottom));
    }

    .products-list {
        padding-bottom: calc(52px + var(--safe-bottom) + var(--space-sm));
    }

    .products-header,
    .product-detail-header {
        padding-top: calc(var(--safe-top) + var(--space-xs));
        padding-bottom: var(--space-xs);
    }

    .product-card {
        padding: var(--space-sm) var(--space-md);
    }

    .product-card-thumb {
        width: 56px;
        height: 56px;
    }

    .detail-image-thumbs {
        padding: var(--space-sm);
    }

    .detail-thumb-card {
        width: 90px;
    }

    .detail-thumb-card img,
    .thumb-img-wrap,
    .thumb-img-wrap img,
    .detail-thumb-card .thumb-placeholder {
        width: 90px;
        height: 90px;
    }
}

/* --- Landscape tablet --- */
@media (min-width: 768px) and (max-height: 700px) and (orientation: landscape) {
    .products-list {
        grid-template-columns: repeat(3, 1fr);
    }

    .merge-action-bar,
    .thumb-select-bar {
        max-width: 700px;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* Save button in header */
.btn-save-header {
    color: #fff;
    background-color: green;
    border-radius: var(--radius-md);
    padding: 6px 10px;
}

.btn-save-header.saving {
    opacity: 0.5;
    pointer-events: none;
}

.btn-save-header.saved {
    color: var(--success);
}

/* Refresh pull indicator */
.products-refresh {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm);
}

.btn-refresh {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-md);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-refresh:active {
    background: var(--bg-card);
}

.btn-refresh svg {
    width: 14px;
    height: 14px;
}

.btn-refresh.loading svg {
    animation: spin 0.8s linear infinite;
}

/* ============================================
   Pull-to-Refresh Indicator (native feel)
   ============================================ */
.pull-indicator {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 0;
    overflow: hidden;
    transition: height 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    flex-shrink: 0;
}

.pull-indicator.pulling {
    transition: none;
}

.pull-indicator.refreshing {
    height: 52px;
}

.pull-indicator-spinner {
    width: 28px;
    height: 28px;
    opacity: 0;
    transition: opacity 0.15s;
}

.pull-indicator-spinner svg {
    width: 28px;
    height: 28px;
    stroke: var(--accent-light);
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
}

.pull-indicator.pulling .pull-indicator-spinner {
    opacity: 1;
}

.pull-indicator.refreshing .pull-indicator-spinner {
    opacity: 1;
}

.pull-indicator.refreshing .pull-indicator-spinner svg {
    animation: spin 0.7s linear infinite;
}

.pull-indicator.ready .pull-indicator-spinner svg {
    stroke: var(--success, #2ecc71);
}

/* ============================================
   Image Thumbnails Row
   ============================================ */
.detail-image-thumbs {
    display: flex;
    gap: 10px;
    padding: var(--space-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.detail-thumb-card {
    flex: 0 0 auto;
    width: 120px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-card);
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
}

.detail-thumb-card:active {
    transform: scale(0.95);
}

.detail-thumb-card img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    display: block;
}

.detail-thumb-card .thumb-label {
    padding: 4px 6px;
    font-size: 0.7em;
    text-align: center;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-thumb-card .thumb-placeholder {
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #555);
}

.detail-thumb-card .thumb-placeholder svg {
    width: 40px;
    height: 40px;
}

/* ============================================
   Image Viewer Screen (full-screen, native)
   ============================================ */
.image-viewer-container {
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
}

.image-viewer-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: calc(var(--safe-top) + var(--space-sm)) var(--space-md) var(--space-sm);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
}

.image-viewer-header .btn-icon {
    color: #fff;
}

.image-viewer-title {
    flex: 1;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-viewer-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: pinch-zoom;
}

.image-viewer-body img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

/* ============================================
   Image Viewer Action Buttons (download/share)
   ============================================ */
.viewer-action-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transition: background 0.2s;
    flex-shrink: 0;
}

.viewer-action-btn:active {
    background: rgba(255, 255, 255, 0.25);
}

/* ============================================
   Thumbnail Download Button Overlay
   ============================================ */
.thumb-img-wrap {
    position: relative;
    width: 120px;
    height: 120px;
    overflow: hidden;
}

.thumb-img-wrap img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    display: block;
}

.thumb-download-btn {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s, background 0.2s;
}

.thumb-download-btn:active {
    opacity: 1;
    background: rgba(0, 90, 134, 0.8);
}

/* ============================================
   Social Post Card
   ============================================ */
.social-post-card {
    border-color: rgba(0, 90, 134, 0.25);
}

.social-post-textarea {
    width: 100%;
    min-height: 120px;
    padding: var(--space-sm);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    margin-bottom: var(--space-sm);
}

.social-post-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.social-post-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--space-xs) var(--space-md);
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.social-post-copy-btn:active {
    opacity: 0.8;
}

.social-post-copy-btn svg {
    flex-shrink: 0;
}

/* ============================================
   Global Bottom Navigation Bar
   ============================================ */
.main-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding: var(--space-xs) 0 calc(var(--safe-bottom) + var(--space-xs));
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.main-bottom-bar.hidden {
    display: none;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    padding: var(--space-xs) 0;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.nav-item:active {
    opacity: 0.7;
}

.nav-item.active {
    color: var(--accent-light);
}

.nav-item svg {
    flex-shrink: 0;
}

/* Queue badge on nav item */
#nav-queue {
    position: relative;
}

#nav-queue .queue-badge {
    position: absolute;
    top: 0;
    right: 50%;
    transform: translateX(16px);
}

.nav-label {
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
}

/* Center button - shared */
.nav-item-center {
    flex: 1;
    position: relative;
    padding: 0;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.nav-item-center:active {
    opacity: 1;
}

/* Capture mode (camera screen) */
.nav-center-capture {
    display: none;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(0, 90, 134, 0.25);
    border: 3px solid #fff;
    align-items: center;
    justify-content: center;
    margin-top: -20px;
    animation: nav-pulse-glow 2.5s ease-in-out infinite;
}

.nav-center-capture-inner {
    display: block;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #fff;
    transition: background 0.15s, transform 0.15s;
}

.nav-item-center.capture-mode .nav-center-capture {
    display: flex;
}

.nav-item-center.capture-mode .nav-center-home {
    display: none;
}

.nav-item-center.capture-mode:active .nav-center-capture {
    animation: none;
    transform: scale(0.92);
}

.nav-item-center.capture-mode:active .nav-center-capture-inner {
    transform: scale(0.88);
    background: var(--accent-light);
}

@keyframes nav-pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 90, 134, 0.3); }
    50% { box-shadow: 0 0 0 12px rgba(0, 90, 134, 0); }
}

/* Home mode (other screens) */
.nav-center-home {
    display: none;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent-gradient);
    align-items: center;
    justify-content: center;
    margin-top: -14px;
    box-shadow: 0 4px 16px rgba(0, 90, 134, 0.4);
    color: #fff;
    transition: transform 0.15s;
}

.nav-item-center:not(.capture-mode) .nav-center-home {
    display: flex;
}

.nav-item-center:not(.capture-mode) .nav-center-capture {
    display: none;
}

.nav-item-center:not(.capture-mode):active .nav-center-home {
    transform: scale(0.92);
}

/* ============================================
   Screen padding-bottom adjustments for nav bar
   ============================================ */
.product-detail-container {
    padding-bottom: calc(72px + var(--safe-bottom));
}

.queue-container {
    padding-bottom: calc(72px + var(--safe-bottom));
}

.results-container {
    padding-bottom: calc(72px + var(--safe-bottom));
}

.processing-container {
    padding-bottom: calc(72px + var(--safe-bottom));
}

/* ============================================
   Merge Mode
   ============================================ */
.merge-action-bar {
    position: fixed;
    bottom: calc(56px + var(--safe-bottom));
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 20;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.merge-action-bar.hidden {
    display: none;
}

.merge-count {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.btn-merge-cancel {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    cursor: pointer;
}

.btn-merge-confirm {
    padding: 8px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-merge-confirm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.products-list.merge-mode .product-card {
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
}

.product-card.merge-selected {
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 90, 134, 0.2);
}

.merge-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.products-header .btn-icon.active {
    color: var(--accent);
    background: rgba(0, 90, 134, 0.15);
    border-radius: var(--radius-md);
}

/* Parent badge on product card */
.parent-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    background: rgba(0, 90, 134, 0.85);
    color: #fff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    z-index: 2;
}

.parent-badge svg {
    width: 12px;
    height: 12px;
}

/* ============================================
   Multi-Dimensions Card
   ============================================ */
.dimensions-card {
    padding-bottom: var(--space-sm);
}

.dimensions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: var(--space-xs);
}

.dimension-row {
    display: grid;
    grid-template-columns: 1fr 76px 76px 32px;
    gap: 6px;
    align-items: center;
}

.dim-input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input, var(--bg-primary));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-family: inherit;
}

.dim-input:focus {
    outline: none;
    border-color: var(--accent);
}

.dim-input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.btn-add-dimension {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 6px;
    padding: 8px;
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn-add-dimension:hover,
.btn-add-dimension:active {
    background: rgba(0, 90, 134, 0.08);
    border-color: var(--accent);
}

.btn-remove-dimension {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid rgba(255, 71, 87, 0.3);
    border-radius: var(--radius-sm);
    color: #ff4757;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-remove-dimension:hover,
.btn-remove-dimension:active {
    background: rgba(255, 71, 87, 0.12);
}

/* ============================================
   Children Section (Varianti Colore)
   ============================================ */
.children-section .children-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: var(--space-xs);
}

.child-card {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px;
    background: var(--bg-input, var(--bg-primary));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.2s;
}

.child-card:active {
    background: rgba(0, 90, 134, 0.08);
}

.child-thumb {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

.child-thumb-empty {
    background: var(--bg-secondary);
}

.child-info {
    flex: 1;
    min-width: 0;
}

.child-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.child-colors {
    display: flex;
    gap: 4px;
    margin-top: 3px;
}

.child-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.child-dimensions {
    font-size: 0.78em;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-unmerge-child {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid rgba(255, 71, 87, 0.3);
    border-radius: 50%;
    color: #ff4757;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.btn-unmerge-child:active {
    background: rgba(255, 71, 87, 0.15);
}

/* Merge mode: add extra padding-bottom for merge bar */
.products-list.merge-mode {
    padding-bottom: 56px;
}

/* ============================================
   Watermark loading spinner on thumbnails
   ============================================ */
.thumb-watermark-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.mini-spinner-sm {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================
   Thumbnail selection mode
   ============================================ */
.detail-thumb-card.thumb-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow, rgba(0, 90, 134, 0.3));
}

.thumb-select-check {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent, #005a86);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.thumb-select-check svg {
    width: 14px;
    height: 14px;
    stroke: #fff;
    fill: none;
    stroke-width: 3;
}

.detail-image-thumbs.selection-mode .detail-thumb-card {
    opacity: 0.7;
    transition: opacity 0.15s, border-color 0.2s;
}

.detail-image-thumbs.selection-mode .detail-thumb-card.thumb-selected {
    opacity: 1;
}

/* ============================================
   Thumbnail selection bar (fixed bottom)
   ============================================ */
.thumb-select-bar {
    position: fixed;
    bottom: calc(56px + var(--safe-bottom, 0px));
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm, 8px);
    padding: var(--space-sm, 8px) var(--space-md, 16px);
    background: var(--bg-secondary, #152238);
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.1));
    z-index: 20;
    animation: slideUpBar 0.2s ease-out;
}

.thumb-select-bar.hidden {
    display: none;
}

@keyframes slideUpBar {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.thumb-select-bar #thumb-select-count {
    flex: 1;
    font-size: var(--font-size-sm, 14px);
    color: var(--text-secondary, #aaa);
    font-weight: 500;
}

.btn-thumb-cancel {
    padding: 8px 16px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    background: transparent;
    color: var(--text-primary, #fff);
    border-radius: var(--radius-md, 8px);
    font-size: var(--font-size-sm, 14px);
    cursor: pointer;
}

.btn-thumb-share {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent, #005a86);
    color: #fff;
    border: none;
    border-radius: var(--radius-md, 8px);
    padding: 8px 16px;
    font-size: var(--font-size-sm, 14px);
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-thumb-share:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-thumb-share svg {
    flex-shrink: 0;
}
