:root {
    --bg-primary: #0a0b10;
    --bg-secondary: #121420;
    --card-bg: rgba(22, 26, 41, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;
    
    --glow-blue: rgba(59, 130, 246, 0.15);
    --glow-cyan: rgba(6, 182, 212, 0.2);
    --glow-green: rgba(16, 185, 129, 0.2);
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

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

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.08) 0px, transparent 50%);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
}

.app-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    min-height: 100vh;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 0.5rem;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    font-size: 2.5rem;
}

.app-header h1 {
    font-family: var(--font-heading);
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.125rem;
    max-width: 600px;
    margin: 0 auto;
    font-weight: 400;
}

/* Navigation Menu */
.nav-menu {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem auto 1rem auto;
    background: rgba(22, 26, 41, 0.7);
    border: 1px solid var(--border-color);
    padding: 0.35rem;
    border-radius: 30px;
    backdrop-filter: blur(12px);
    width: fit-content;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.6rem 1.25rem;
    border-radius: 24px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.nav-tab.active {
    color: #ffffff;
    background: linear-gradient(135deg, var(--accent-blue) 0%, #2563eb 100%);
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.35);
}

.nav-badge {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
}

.nav-tab.active .nav-badge {
    background: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

/* Two Separate Page Views (Mobile & Desktop) */
.main-content.view-scan .sets-section {
    display: none !important;
}

.main-content.view-sets .scanner-section,
.main-content.view-sets .results-section {
    display: none !important;
}

.main-content.view-sets {
    display: block !important;
    grid-template-columns: 1fr !important;
}

.main-content.view-sets .right-panel {
    width: 100%;
}

.main-content.view-sets .sets-section {
    display: flex !important;
    width: 100%;
}

/* Main Layout Grid for Scan Page */
.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 900px) {
    .main-content.view-scan {
        grid-template-columns: 420px 1fr;
        align-items: start;
    }
}

/* Cards style */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    backdrop-filter: blur(16px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.card-header h2 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

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

/* Dropdown/Upload area */
.upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.01);
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.upload-area:hover {
    border-color: var(--accent-cyan);
    background-color: rgba(6, 182, 212, 0.03);
}

#camera-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    text-align: center;
}

.scanner-circle-outer {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(6, 182, 212, 0.2);
    position: relative;
    margin-bottom: 0.5rem;
}

.scanner-circle-inner {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.upload-action-text {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.upload-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.preview-container {
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin: 0 auto;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.image-wrapper img {
    display: block;
    max-width: 100%;
    max-height: 380px;
    width: auto;
    height: auto;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
}

#bounding-boxes-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Scan overlay animation */
.scanning-overlay {
    position: absolute;
    top: 1rem;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    overflow: hidden;
    pointer-events: none;
    border-radius: var(--radius-sm);
}

.scan-line {
    height: 3px;
    width: 100%;
    background: linear-gradient(to right, transparent, var(--accent-cyan), transparent);
    position: absolute;
    box-shadow: 0 0 12px var(--accent-cyan);
    animation: scanAnimation 2s linear infinite;
}

@keyframes scanAnimation {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

.btn-retake {
    position: absolute;
    bottom: 1.5rem;
    z-index: 10;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.75rem;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
    width: 100%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-cyan) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--glow-cyan);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: color var(--transition-fast);
}

.btn-close:hover {
    color: var(--accent-red);
}

/* Right Panel Elements */
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Loaded Sets Dashboard */
.sets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.set-card {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all var(--transition-normal);
}

.set-card:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.set-image-container {
    width: 65px;
    height: 65px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.set-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.set-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.set-number {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-primary);
}

.set-count {
    font-size: 0.825rem;
    color: var(--text-secondary);
}

/* Results section elements */
.header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Brick Candidate List */
.candidates-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.candidate-item {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: border-color var(--transition-fast);
}

.candidate-item.has-match {
    border-left: 4px solid var(--accent-green);
    background-color: rgba(16, 185, 129, 0.02);
}

.candidate-top {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.part-thumbnail-container {
    width: 80px;
    height: 80px;
    background-color: rgba(0, 0, 0, 0.25);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.part-thumbnail-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.part-meta {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.part-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.part-details-stacked {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.candidate-color-detail {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.score-badge {
    align-self: flex-start;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.score-badge.high-confidence {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

/* Color indicator swatch */
.color-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.25);
    vertical-align: middle;
    margin-right: 4px;
}

/* Matches sections */
.matches-section {
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    padding-top: 0.75rem;
}

.matches-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.matches-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.match-row {
    background-color: rgba(255,255,255,0.015);
    border: 1px solid rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.5rem;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto auto;
    align-items: center;
    gap: 0.05rem 0.6rem;
    font-size: 0.9rem;
}

.match-row.color-perfect {
    border-color: rgba(16, 185, 129, 0.15);
    background-color: rgba(16, 185, 129, 0.01);
}

.match-set-icon {
    grid-row: 1 / span 3;
    grid-column: 1;
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background-color: rgba(255, 255, 255, 0.05);
    padding: 2px;
    flex-shrink: 0;
}

.set-link {
    grid-row: 1;
    grid-column: 2;
    font-weight: 600;
    color: var(--accent-cyan);
    text-decoration: none;
    transition: text-decoration var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: clamp(150px, 60vw, 500px);
}

.set-link:hover {
    text-decoration: underline;
}

.set-number-sub {
    grid-row: 2;
    grid-column: 2;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    line-height: 1;
}

.match-details-sub {
    grid-row: 3;
    grid-column: 2;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.76rem;
    color: var(--text-secondary);
    min-width: 0;
}

.color-swatch-container {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
}

.color-swatch {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.2);
    display: inline-block;
    flex-shrink: 0;
}

.color-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bullet-separator {
    color: var(--text-muted);
    font-size: 0.6rem;
}

.match-qty-sub {
    grid-row: 1 / span 2;
    grid-column: 3;
    justify-self: end;
    align-self: center;
    font-weight: 600;
    font-family: var(--font-heading);
    color: var(--text-primary);
    white-space: nowrap;
    font-size: 0.9rem;
}

.match-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    background-color: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    display: inline-block;
    line-height: 1.2;
    flex-shrink: 0;
}

.match-badge.badge-exact {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.match-badge.badge-loose {
    background-color: rgba(245, 158, 11, 0.15);
    color: var(--accent-yellow);
}

.match-badge.badge-variant {
    background-color: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
}

/* External Link Button */
.btn-catalog-link {
    margin-top: 0.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.btn-catalog-link:hover {
    color: var(--accent-cyan);
    text-decoration: underline;
}

/* Footer styling */
.app-footer {
    text-align: center;
    padding: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.app-footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

.app-footer a:hover {
    color: var(--accent-cyan);
    text-decoration: underline;
}

/* Utilities */
.hidden {
    display: none !important;
}

.loading-spinner {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-family: var(--font-heading);
}

.no-matches-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 0.5rem 0;
}

/* Collapsible Sets Panel */
.toggle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.chevron-icon {
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: transform var(--transition-normal);
}

.sets-section {
    transition: gap var(--transition-normal);
}

.sets-grid {
    transition: max-height var(--transition-normal), opacity var(--transition-normal), margin-top var(--transition-normal);
    max-height: 2000px;
    opacity: 1;
    overflow: hidden;
}

.sets-section.collapsed {
    gap: 0;
}

.sets-section.collapsed .sets-grid {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    pointer-events: none;
}

.sets-section.collapsed .chevron-icon {
    transform: rotate(-90deg);
}
