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

:root {
    --bg: #0d0d1a;
    --surface: #1a1a2e;
    --surface2: #242440;
    --text: #eee;
    --text2: #999;
    --primary: #4CAF50;
    --accent: #FFC107;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    padding-bottom: 40px;
}

/* ======== Header ======== */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

header h1 {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, #4CAF50, #8BC34A);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 8px;
    border-radius: 12px;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--surface2);
}

/* ======== Search ======== */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--surface);
    margin: 8px 16px;
    border-radius: 16px;
    border: 1px solid var(--surface2);
}

.search-bar input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 16px;
    outline: none;
}

.search-bar input::placeholder {
    color: var(--text2);
}

/* ======== Search Results ======== */
#search-results {
    margin: 8px 16px;
    background: var(--surface);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--surface2);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--surface2);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--surface2);
}

.search-result-item img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 8px;
    background: var(--bg);
}

.search-result-item strong {
    display: block;
    font-size: 14px;
}

.search-result-item small {
    color: var(--text2);
    font-size: 12px;
}

/* ======== Score Section ======== */
.score-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding: 24px 20px;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: conic-gradient(#4CAF50 100%, #1a1a2e 0deg);
    position: relative;
}

.score-circle::before {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--surface);
}

.score-circle span {
    position: relative;
    z-index: 1;
}

#score-value {
    font-size: 36px;
    font-weight: 800;
}

.score-label {
    font-size: 12px;
    color: var(--text2);
}

.product-image-container {
    width: 100px;
    height: 100px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
}

#product-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ======== Product Info ======== */
.product-name {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    padding: 0 20px;
    margin-bottom: 4px;
}

.product-brand {
    text-align: center;
    color: var(--text2);
    font-size: 14px;
    margin-bottom: 2px;
}

.product-category {
    text-align: center;
    color: var(--text2);
    font-size: 12px;
    margin-bottom: 16px;
}

/* ======== Badges ======== */
.badges-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 0 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.badge {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: white;
}

/* ======== Tabs ======== */
.tabs {
    display: flex;
    gap: 4px;
    padding: 0 20px;
    margin-bottom: 4px;
}

.tab {
    flex: 1;
    padding: 12px;
    background: var(--surface);
    border: none;
    color: var(--text2);
    font-size: 14px;
    cursor: pointer;
    border-radius: 12px 12px 0 0;
    transition: all 0.2s;
}

.tab.active {
    background: var(--surface2);
    color: var(--text);
    font-weight: 600;
}

.tab-content {
    display: none;
    background: var(--surface2);
    border-radius: 0 0 16px 16px;
    padding: 20px;
    margin: 0 20px 20px;
}

.tab-content.active {
    display: block;
}

/* ======== Nutrition ======== */
.nutrition-grid {
    display: grid;
    gap: 1px;
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
}

.nutrition-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
}

.nutrition-label {
    color: var(--text2);
    font-size: 14px;
}

.nutrition-value {
    font-weight: 600;
    font-size: 14px;
}

.nutrition-empty {
    padding: 20px;
    text-align: center;
    color: var(--text2);
}

/* ======== Ingredients ======== */
.ingredients-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

/* ======== Labels ======== */
#labels-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.label-tag {
    padding: 6px 12px;
    background: var(--surface);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text);
}

/* ======== Origin ======== */
.origin-section {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    margin-bottom: 12px;
    color: var(--text2);
    font-size: 13px;
}

.product-link {
    display: block;
    text-align: center;
    padding: 12px 20px;
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
}

/* ======== Scanner Overlay ======== */
#scanner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#scanner-container {
    width: 90%;
    max-width: 400px;
}

#scanner-video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
}

#scanner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #4CAF50, transparent);
    animation: scanMove 2s ease-in-out infinite;
}

@keyframes scanMove {
    0%, 100% { top: 20%; }
    50% { top: 75%; }
}

.scan-corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border-color: #4CAF50;
    border-style: solid;
}

.scan-corner.tl { top: 10px; left: 10px; border-width: 3px 0 0 3px; }
.scan-corner.tr { top: 10px; right: 10px; border-width: 3px 3px 0 0; }
.scan-corner.bl { bottom: 10px; left: 10px; border-width: 0 0 3px 3px; }
.scan-corner.br { bottom: 10px; right: 10px; border-width: 0 3px 3px 0; }

.scanner-footer {
    margin-top: 16px;
    text-align: center;
}

.scanner-footer p {
    color: #ccc;
    font-size: 14px;
    margin-bottom: 16px;
}

.scanner-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

#manual-barcode {
    width: 100%;
    padding: 14px 20px;
    border: 2px solid var(--surface2);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    font-size: 18px;
    text-align: center;
    outline: none;
    margin-top: 12px;
}

#manual-barcode:focus {
    border-color: var(--primary);
}

/* ======== Buttons ======== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

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

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
}

.btn-large {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 32px;
    font-size: 18px;
}

/* ======== Empty State ======== */
#empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    text-align: center;
}

#empty-state h2 {
    margin-top: 24px;
    font-size: 24px;
    background: linear-gradient(135deg, #4CAF50, #8BC34A);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#empty-state p {
    color: var(--text2);
    margin: 12px 0 32px;
    line-height: 1.5;
    font-size: 15px;
}

/* ======== Loading ======== */
#loading {
    padding: 60px 20px;
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--surface2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

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

/* ======== Error ======== */
.error-state {
    text-align: center;
    padding: 40px 20px;
    color: #F44336;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }
