:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --bg-color: #0f172a;
    --surface: rgba(30, 41, 59, 0.7);
    --surface-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --radius: 16px;
    --radius-sm: 8px;
    --shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: radial-gradient(circle at top left, #1e1b4b, var(--bg-color));
    color: var(--text-primary);
    min-height: 100vh;
    padding-bottom: 2rem;
}

/* Glass Header */
.glass-header {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--surface-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.glass-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #6ee7b7, var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    margin-left: 1rem;
    transition: color 0.3s;
}

nav button:hover, nav button.active {
    color: var(--text-primary);
}

/* Main Container */
#app-container {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Views */
.view {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* UI Elements */
.card {
    background: var(--surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.2s, filter 0.2s, background 0.3s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:active {
    transform: scale(0.95);
}

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

.btn.accent {
    background: var(--accent);
    color: #1e293b;
}
.btn.accent:hover { background: var(--accent-hover); }

.btn.text {
    background: none;
    color: var(--text-secondary);
    padding: 0.6rem 0;
}
.btn.text:hover { color: var(--text-primary); }

.input-group {
    margin-bottom: 1rem;
}
.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.input-group input {
    width: 100%;
    padding: 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--surface-border);
    background: rgba(0,0,0,0.2);
    color: white;
    font-family: inherit;
    outline: none;
}
.input-group input:focus {
    border-color: var(--primary);
}

.hidden { display: none !important; }

/* Grid Layouts */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

/* Model Card */
.model-card {
    cursor: pointer;
    transition: transform 0.3s;
}
.model-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}
.model-card h3 {
    margin-bottom: 0.5rem;
}
.model-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Parts Grid */
.parts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.part-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.part-card img {
    max-width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 0.5rem;
}

.part-card .qty-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: auto;
    background: rgba(0,0,0,0.3);
    border-radius: 20px;
    padding: 0.2rem 0.5rem;
}

.qty-controls button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    width: 24px;
    height: 24px;
    border-radius: 12px;
}
.qty-controls button:hover { background: rgba(255,255,255,0.1); }

/* Progress / Stats */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin-bottom: 1.5rem;
}
.stat {
    display: flex;
    flex-direction: column;
}
.stat .label { font-size: 0.8rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px;}
.stat .value { font-size: 1.5rem; font-weight: 800; }
.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    margin-top: 1rem;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--danger), var(--success));
    width: 0%;
    transition: width 0.5s ease-out;
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    width: 90%;
    max-width: 400px;
}

/* Scanner */
.scanner-container {
    text-align: center;
}

.upload-zone {
    margin: 2rem 0;
}
.upload-zone input {
    display: none;
}

.preview-container {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--surface-border);
    display: inline-block; /* Ensure canvas overlays exactly on img */
}

.preview-container img {
    display: block;
    max-width: 100%;
    height: auto;
}

.preview-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.status-msg {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.results-list {
    margin-top: 2rem;
}
.results-list ul {
    list-style: none;
    padding: 0;
}
.results-list li {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    padding: 0.8rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

/* Dropdown */
.dropdown {
    list-style: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-color);
    border: 1px solid var(--surface-border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
}
.dropdown li {
    padding: 0.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--surface-border);
    cursor: pointer;
    transition: background 0.2s;
}
.dropdown li:hover, .dropdown li.focused-item {
    background: var(--surface);
}
.dropdown li img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 4px;
}
.dropdown li div {
    flex: 1;
}
.dropdown li div strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text-primary);
}
.dropdown li div small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Child Check-in Options */
#checkin-set-options .btn {
    padding: 1.5rem 1rem;
    font-size: 1.2rem;
    display: flex;
    justify-content: flex-start;
    gap: 1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
#checkin-set-options .btn img {
    height: 48px;
    border-radius: 4px;
}
