/* ============================================
   ProductPilot — Styles
   Modern, minimal, clean design
   ============================================ */

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --navbar-height: 44px;
    --color-bg: #999999;
    --color-navbar: #ffffff;
    --color-text: #1a1a1a;
    --color-text-muted: #777777;
    --color-accent: #0066ff;
    --color-border: #e0e0e0;
    --color-hover: #f0f4ff;
    --color-shadow: rgba(0, 0, 0, 0.06);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --transition: 180ms ease;
}

html, body {
    height: 100%;
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    overflow: hidden;
}

/* ============================================
   Navbar
   ============================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: var(--color-navbar);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 1px 3px var(--color-shadow);
}

.navbar-brand {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--color-text);
    user-select: none;
}

.navbar-menu {
    margin-left: 32px;
    position: relative;
    flex: 1;
}

/* iOS Badge (Apple logo, top-right in navbar) */
.navbar-ios-badge {
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    margin-left: auto;
    opacity: 0.5;
}

.navbar-ios-badge.visible {
    display: flex;
}

/* ============================================
   Dropdown
   ============================================ */
.dropdown {
    position: relative;
}

.dropdown-toggle {
    background: none;
    border: none;
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition);
}

.dropdown-toggle:hover,
.dropdown-toggle.active {
    background: var(--color-hover);
    color: var(--color-text);
}

.dropdown-toggle::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 6px;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    transition: transform var(--transition);
}

.dropdown-toggle.active::after {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: max-content;
    white-space: nowrap;
    background: var(--color-navbar);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
    overflow: hidden;
}

.dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    text-align: left;
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition);
    line-height: 1.5;
}

.dropdown-item:hover {
    background: var(--color-hover);
}

.dropdown-item.selected {
    background: var(--color-hover);
    color: var(--color-accent);
}

.dropdown-item .art-number {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-left: 2px;
}

/* ============================================
   3D Viewer
   ============================================ */
.viewer-container {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-bg);
}

model-viewer {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 0;
    background-color: var(--color-bg);
    --poster-color: var(--color-bg);
}

/* Loading indicator */
model-viewer[loading]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ============================================
   Scrollbar (for dropdown if many items)
   ============================================ */
.dropdown-menu::-webkit-scrollbar {
    width: 4px;
}

.dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 2px;
}

/* ============================================
   Product Info Panel (top-left overlay)
   ============================================ */
.info-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    max-width: 420px;
    z-index: 100;
    pointer-events: auto;
    cursor: pointer;
    padding: 16px 20px;
    padding-right: 36px;
    border-radius: 12px;
    background: rgba(30, 30, 30, 0.65);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 250ms ease, transform 250ms ease;
}

/* Decorative X close hint (top-right corner) */
.info-close-hint {
    position: absolute;
    top: 10px;
    right: 10px;
    color: rgba(255, 255, 255, 0.35);
    transition: color 180ms ease;
}

.info-panel:hover .info-close-hint {
    color: rgba(255, 255, 255, 0.7);
}

.info-panel.visible {
    opacity: 1;
    transform: translateY(0);
}

.info-title {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 6px;
    line-height: 1.3;
}

.info-description {
    font-size: 12px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.55;
    margin-bottom: 12px;
}

.info-data {
    border-collapse: collapse;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.88);
}

.info-data tr + tr td {
    padding-top: 3px;
}

.info-data td:first-child {
    font-weight: 600;
    padding-right: 12px;
    white-space: nowrap;
    vertical-align: top;
}

.info-data td:last-child {
    font-weight: 400;
}

/* Info Toggle Button ("i" icon) */
.info-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(30, 30, 30, 0.65);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
    transition: opacity 200ms ease, transform 200ms ease, background 150ms ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.info-toggle.visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.info-toggle:hover {
    background: rgba(50, 50, 50, 0.8);
}

/* ============================================
   Background Selector (bottom-left)
   ============================================ */
.bg-selector {
    position: absolute;
    left: 16px;
    bottom: 16px;
    display: flex;
    gap: 6px;
    z-index: 100;
    pointer-events: auto;
}

.bg-swatch {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    background-size: cover;
    background-position: center;
    transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.bg-swatch:hover {
    transform: scale(1.12);
    border-color: rgba(255, 255, 255, 0.85);
}

.bg-swatch.active {
    border-color: var(--color-accent);
    box-shadow: 0 0 8px rgba(0, 102, 255, 0.5);
}

/* ============================================
   Image Gallery Strip (right edge, bottom→top)
   ============================================ */
.gallery-strip {
    position: absolute;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
    pointer-events: auto;
}

.gallery-thumb {
    width: min(128px, 10vw);
    height: min(128px, 10vw);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.6);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.gallery-thumb:hover {
    transform: scale(1.08);
    border-color: var(--color-accent);
    box-shadow: 0 4px 16px rgba(0, 102, 255, 0.35);
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 3D media thumb — position relative for badge overlay */
.gallery-thumb-3d {
    position: relative;
}

/* Active 3D thumb indicator */
.gallery-thumb-3d.active {
    border-color: var(--color-accent);
    box-shadow: 0 0 12px rgba(0, 102, 255, 0.5);
}

/* 3D badge in top-right corner of thumbnail */
.gallery-3d-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 102, 255, 0.85);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 5px;
    border-radius: 4px;
    line-height: 1;
    pointer-events: none;
    text-transform: uppercase;
}

/* Placeholder for 3D thumbs without a thumbnail image */
.gallery-thumb-3d-placeholder {
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-thumb-3d-placeholder::before {
    content: '';
    width: 32px;
    height: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2L2 7l10 5 10-5-10-5z'/%3E%3Cpath d='M2 17l10 5 10-5'/%3E%3Cpath d='M2 12l10 5 10-5'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* AI badge in top-right corner — mirrors .gallery-3d-badge */
.gallery-ai-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 102, 255, 0.85);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 5px;
    border-radius: 4px;
    line-height: 1;
    pointer-events: none;
    text-transform: uppercase;
    z-index: 4;
}

/* AI Render button at bottom of gallery */
.gallery-render-btn {
    position: relative;
    width: min(128px, 10vw);
    height: min(128px, 10vw);
    border-radius: 8px;
    border: 2px dashed rgba(255, 255, 255, 0.45);
    background: rgba(30, 30, 30, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: var(--font-family);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.gallery-render-btn:hover {
    background: rgba(0, 102, 255, 0.25);
    border-color: var(--color-accent);
    color: #ffffff;
    transform: scale(1.05);
}

.gallery-render-btn svg {
    opacity: 0.8;
}

/* AI Render button — loading state with screenshot background */
.gallery-render-btn.loading {
    pointer-events: none;
    border-color: var(--color-accent);
    border-style: solid;
    position: relative;
    overflow: hidden;
}

/* Hide default icon and text when loading (keep badge + progress) */
.gallery-render-btn.loading > svg,
.gallery-render-btn.loading > span:not(.gallery-ai-badge):not(.render-progress-label) {
    display: none;
}

/* Dark overlay on top of screenshot for readability */
.gallery-render-btn.loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1;
}

/* Rotating throbber ring */
.gallery-render-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: ai-spin 0.8s linear infinite;
    z-index: 2;
}

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

/* Progress percentage label — centered on throbber */
.render-progress-label {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0;
    text-transform: none;
    z-index: 3;
    position: relative;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* Full-size overlay centered over the viewer (hover preview) */
.gallery-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    transition: opacity 200ms ease;
    max-width: 70vw;
    max-height: 70vh;
}

.gallery-overlay.visible {
    opacity: 1;
}

.gallery-overlay img {
    max-width: 70vw;
    max-height: 70vh;
    border-radius: 12px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.45);
    display: block;
}

/* ============================================
   Gallery Lightbox (click-to-view)
   ============================================ */
.gallery-lightbox {
    position: absolute;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms ease;
}

.gallery-lightbox.open {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-content {
    position: relative;
    display: inline-flex;
    max-width: 80vw;
    max-height: 80vh;
}

.gallery-lightbox-img {
    max-width: 80vw;
    max-height: 80vh;
    border-radius: 10px;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6);
    object-fit: contain;
    transition: opacity 200ms ease;
    display: block;
}

/* Lightbox buttons — shared style */
.lightbox-btn {
    position: absolute;
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease, transform 150ms ease;
    text-decoration: none;
}

.lightbox-btn:hover {
    background: rgba(60, 60, 60, 0.8);
    color: #ffffff;
    transform: scale(1.1);
}

.lightbox-close {
    top: 8px;
    right: 8px;
}

.lightbox-prev {
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
}
.lightbox-prev:hover {
    transform: translateY(-50%) scale(1.1);
}

.lightbox-next {
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}
.lightbox-next:hover {
    transform: translateY(-50%) scale(1.1);
}

.lightbox-download {
    bottom: 8px;
    right: 8px;
}

/* Hide prev/next when only 1 image */
.lightbox-prev.hidden,
.lightbox-next.hidden {
    display: none;
}
