:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --bg: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --danger: #ef4444;
    --radius: 20px;
    --glass: blur(12px) saturate(180%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.app-container {
    position: relative;
    height: 100%;
    width: 100%;
}

.view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.view.active {
    opacity: 1;
    pointer-events: all;
}

/* Home View */
#home-view {
    padding: 2rem;
    justify-content: space-between;
}

header {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
}

.hero h1 {
    font-size: 2.25rem;
    line-height: 1.2;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 300px;
}

.hero-image {
    width: 100%;
    max-width: 300px;
    height: 300px;
    border-radius: 40px;
    overflow: hidden;
    margin: 1rem 0;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    transform: rotate(-3deg);
}

.hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    border-radius: 100px;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    max-width: 280px;
}

.btn-primary:active {
    transform: scale(0.96);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.875rem 2rem;
    border-radius: 100px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: var(--glass);
    margin-top: 1.5rem;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: var(--glass);
    cursor: pointer;
}

/* Scanner View */
#scanner-view {
    background: #000;
}

#reader {
    width: 100%;
    height: 100%;
}

#reader video {
    object-fit: cover !important;
}

.scanner-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem;
    pointer-events: none;
}

.scanner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: all;
}

.scanner-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.spacer { width: 48px; }

.scan-frame-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-frame {
    width: 260px;
    height: 380px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 4px solid var(--primary);
}

.top-left { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; }
.top-right { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-radius: 0 12px 0 0; }
.bottom-left { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-radius: 0 0 0 12px; }
.bottom-right { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-radius: 0 0 12px 0; }

.scan-line {
    position: absolute;
    top: 50%;
    left: 2px;
    right: 2px;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 0 15px var(--primary);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0%, 100% { top: 5%; }
    50% { top: 95%; }
}

.scan-hint {
    text-align: center;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2rem;
}

.scanner-footer {
    display: flex;
    justify-content: center;
    pointer-events: all;
}

/* Result Drawer */
.drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    backdrop-filter: var(--glass);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px 30px 0 0;
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    max-height: 85vh;
}

.drawer.open {
    transform: translateY(0);
}

.drawer-handle {
    width: 40px;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin: 1rem auto;
}

.drawer-content {
    padding: 1.5rem 2rem 3rem;
    overflow-y: auto;
    max-height: calc(85vh - 40px);
}

/* Product Info */
.product-header {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.product-image-container {
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    overflow: hidden;
    flex-shrink: 0;
}

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

.product-meta {
    flex: 1;
}

#p-name {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

#p-brand {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.nutriscore-badge {
    height: 32px;
    width: 80px;
    background: #555;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    text-transform: uppercase;
}

/* Nutrition Grid */
.detail-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

#p-ingredients {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 2rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.nutrition-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.nutrient {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
}

.nutrient .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.nutrient .value {
    font-weight: 600;
}

/* States */
.loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--primary);
    border-bottom-color: transparent;
    border-radius: 50%;
    margin: 2rem auto;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-state, #error-state {
    text-align: center;
    padding: 2rem 0;
}

.error-icon {
    color: var(--danger);
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}
