
:root {
    --purple: #7657e8;
    --purple-dark: #5632c4;
    --purple-light: #eee9ff;
    --dark: #17152b;
    --muted: #77758c;
    --background: #f7f5ff;
    --white: #ffffff;
    --border: #e9e3ff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--background);
    color: var(--dark);
    min-height: 100vh;
}

/* NAVBAR */

.topbar {
    min-height: 85px;
    padding: 10px 6%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    border-bottom: 1px solid #eeeafd;
    box-shadow: 0 3px 15px rgba(40, 25, 90, 0.04);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--dark);
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -1.5px;
}

.brand-image {
    width: 62px;
    height: 62px;
    object-fit: contain;
}

.brand-dot {
    color: var(--purple);
}

.logout-button {
    border: none;
    background: var(--purple-light);
    color: var(--purple);
    padding: 12px 23px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
}

.logout-button:hover {
    background: var(--purple);
    color: white;
}

/* MAIN CONTAINER */

.container {
    width: 92%;
    max-width: 1450px;
    margin: 35px auto;
}

/* WELCOME */

.welcome {
    text-align: center;
    margin-bottom: 30px;
}

.eyebrow,
.section-label {
    display: inline-block;
    color: var(--purple);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2px;
}

.welcome h1 {
    font-size: clamp(27px, 4vw, 39px);
    font-weight: 800;
    margin: 12px 0;
    letter-spacing: -1.2px;
}

.welcome h1 span {
    color: var(--purple);
}

.welcome > p {
    color: var(--muted);
    font-size: 15px;
    line-height: 1.7;
    max-width: 700px;
    margin: auto;
}

.welcome-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    padding: 10px 18px;
    background: var(--purple-light);
    border-radius: 30px;
    color: var(--purple-dark);
    font-size: 14px;
    font-weight: 700;
}

.welcome-icon {
    font-size: 17px;
}

/* WORKSPACE */

.workspace {
    display: grid;
    grid-template-columns: 1fr 0.9fr;
    gap: 25px;
    align-items: start;
}

/* SAAT HASIL BELUM ADA */

.workspace:not(.has-result) .scanner-card {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 950px;
    margin: auto;
}

/* CARD */

.scanner-card,
.result-card {
    background: white;
    padding: 25px;
    border: 1px solid rgba(118, 87, 232, 0.08);
    border-radius: 23px;
    box-shadow: 0 12px 35px rgba(50, 35, 100, 0.07);
    min-width: 0;
}

.section-heading,
.result-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.section-heading h2,
.result-heading h2 {
    font-size: 23px;
    margin-top: 6px;
    letter-spacing: -0.5px;
}

.camera-badge {
    padding: 8px 12px;
    border-radius: 30px;
    background: #f1edff;
    color: var(--purple);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1px;
    white-space: nowrap;
}

/* CAMERA */

.camera-area {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    background: #171329;
    border-radius: 17px;
    overflow: hidden;
}

#camera,
#previewImage {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #171329;
}

#camera.active,
#previewImage.active {
    display: block;
}

.camera-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    text-align: center;
    color: white;
    background:
        radial-gradient(circle at center, #30235e 0%, #171329 70%);
}

.camera-icon {
    width: 75px;
    height: 75px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(137, 105, 255, 0.2);
    color: #b9a6ff;
    font-size: 45px;
}

.camera-placeholder h3 {
    font-size: 18px;
}

.camera-placeholder p {
    color: #c5bfd9;
    font-size: 12px;
    line-height: 1.6;
    max-width: 280px;
}

/* SCAN OVERLAY */

.scan-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.scan-frame {
    position: absolute;
    width: 65%;
    height: 72%;
    top: 14%;
    left: 17.5%;
    border: 2px solid rgba(255,255,255,0.65);
    border-radius: 17px;
    box-shadow: 0 0 0 1000px rgba(0,0,0,0.10);
}

.scan-frame::before,
.scan-frame::after {
    content: "";
    position: absolute;
    width: 25px;
    height: 25px;
    border-color: #a88bff;
    border-style: solid;
}

.scan-frame::before {
    top: -2px;
    left: -2px;
    border-width: 4px 0 0 4px;
    border-radius: 8px 0 0 0;
}

.scan-frame::after {
    bottom: -2px;
    right: -2px;
    border-width: 0 4px 4px 0;
    border-radius: 0 0 8px 0;
}

.scan-line {
    display: none;
    position: absolute;
    left: 17.5%;
    width: 65%;
    top: 14%;
    height: 3px;
    background: #9dffdc;
    box-shadow: 0 0 15px #53ffc0;
    z-index: 3;
}

.scan-line.active {
    display: block;
    animation: scanning 2.5s linear infinite;
}

@keyframes scanning {
    from {
        top: 14%;
    }

    to {
        top: 86%;
    }
}

/* INSTRUCTION */

.scanner-instruction {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    color: var(--muted);
    font-size: 12px;
}

.instruction-icon {
    color: var(--purple);
    font-size: 17px;
}

/* BUTTONS */

.scanner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.primary-button,
.secondary-button,
.retake-button {
    border: none;
    padding: 13px 17px;
    border-radius: 11px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: 0.2s ease;
}

.primary-button {
    flex: 1;
    background: linear-gradient(110deg, #815cf0, #6035d0);
    color: white;
}

.primary-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(118, 87, 232, 0.25);
}

.secondary-button {
    background: var(--purple-light);
    color: var(--purple-dark);
}

.secondary-button:hover:not(:disabled),
.retake-button:hover {
    background: #e1d8ff;
}

.retake-button {
    background: #f1edff;
    color: var(--purple-dark);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* STATUS */

.status-message {
    text-align: center;
    margin-top: 17px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

/* RESULT CARD */

.result-card {
    animation: resultAppear 0.35s ease;
}

@keyframes resultAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--purple-light);
    color: var(--purple);
    font-size: 20px;
    font-weight: 800;
    flex-shrink: 0;
}

.result-status-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px;
    border-radius: 12px;
    background: #f5f2ff;
    margin-bottom: 20px;
}

.status-indicator {
    width: 9px;
    height: 9px;
    margin-top: 4px;
    border-radius: 50%;
    background: var(--purple);
    flex-shrink: 0;
}

.result-status-box p {
    color: #5942a6;
    font-size: 12px;
    line-height: 1.6;
    font-weight: 600;
}

/* PRODUCT INFORMATION */

.product-information {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.info-item {
    min-width: 0;
    padding: 13px;
    border: 1px solid #eeeafd;
    border-radius: 12px;
    background: #fdfcff;
}

.info-label {
    display: block;
    color: #9188aa;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.info-item p {
    color: var(--dark);
    font-size: 13px;
    line-height: 1.6;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.full-info {
    grid-column: 1 / -1;
}

/* NUTRITION */

.nutrition-section {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid #eeeafd;
}

.nutrition-heading {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 14px;
}

.nutrition-heading span {
    color: var(--purple);
    font-size: 20px;
}

.nutrition-heading h3 {
    color: var(--dark);
    font-size: 16px;
}

.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.nutrition-item {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 13px;
    border-radius: 12px;
    background: #f5f2ff;
}

.nutrition-item span {
    color: var(--muted);
    font-size: 11px;
}

.nutrition-item strong {
    color: var(--purple-dark);
    font-size: 15px;
    overflow-wrap: anywhere;
}

.disclaimer {
    margin-top: 18px;
    color: #918aa5;
    font-size: 10px;
    line-height: 1.7;
}

/* FOOTER */

.page-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    margin: 35px 0 20px;
    color: #9389b5;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-align: center;
}

/* HIDDEN */

[hidden] {
    display: none !important;
}

/* TABLET */

@media (max-width: 1000px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .workspace:not(.has-result) .scanner-card {
        max-width: 850px;
    }

    .scanner-card,
    .result-card {
        width: 100%;
    }

    .camera-area {
        aspect-ratio: 16 / 9;
    }
}

/* MOBILE */

@media (max-width: 600px) {
    .topbar {
        min-height: 70px;
        padding: 8px 5%;
    }

    .brand {
        font-size: 24px;
        gap: 6px;
    }

    .brand-image {
        width: 48px;
        height: 48px;
    }

    .logout-button {
        padding: 10px 15px;
        font-size: 12px;
    }

    .container {
        width: 92%;
        margin: 25px auto;
    }

    .welcome {
        margin-bottom: 22px;
    }

    .welcome h1 {
        font-size: 26px;
        line-height: 1.3;
    }

    .welcome > p {
        font-size: 13px;
    }

    .scanner-card,
    .result-card {
        padding: 17px;
        border-radius: 17px;
    }

    .section-heading h2,
    .result-heading h2 {
        font-size: 19px;
    }

    .camera-area {
        aspect-ratio: 4 / 5;
    }

    .scan-frame {
        width: 76%;
        left: 12%;
    }

    .scan-line {
        width: 76%;
        left: 12%;
    }

    .scanner-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .scanner-actions button {
        width: 100%;
        min-height: 45px;
        padding: 11px 8px;
        font-size: 10px;
    }

    .primary-button {
        grid-column: 1 / -1;
    }

    .product-information {
        grid-template-columns: 1fr;
    }

    .full-info {
        grid-column: auto;
    }

    .nutrition-grid {
        grid-template-columns: 1fr 1fr;
    }

    .page-footer {
        flex-direction: column;
        gap: 8px;
        font-size: 9px;
    }
}
