:root {
    --blue: #0759b5;
    --blue-light: #eaf3ff;
    --background: #f3f6fb;
    --text: #182230;
    --muted: #667085;
    --border: #e5eaf2;
    --green: #087443;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: Arial, sans-serif;
}

.container {
    width: 100%;
    max-width: 1050px;
    margin: auto;
    padding-left: 16px;
    padding-right: 16px;
}

/* HEADER */

.hero {
    background: linear-gradient(120deg, #064b9b, #0878d1);
    color: white;
    padding: 30px 0 85px;
}

.brand {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #ffe45c;
}

.hero h1 {
    font-size: 29px;
    margin: 13px 0 8px;
}

.hero p {
    font-size: 14px;
    color: #e1edff;
    margin: 0;
}

/* MAIN */

.main {
    margin-top: -53px;
    padding-bottom: 40px;
}

.search-box {
    background: white;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 25px #1b35550b;
}

.search-row {
    display: flex;
    gap: 10px;
}

input,
textarea {
    width: 100%;
    padding: 13px;
    border: 1px solid #cfd8e5;
    border-radius: 10px;
    outline: none;
    font-size: 14px;
    font-family: inherit;
}

input:focus,
textarea:focus {
    border-color: #2684df;
}

button {
    border: none;
    border-radius: 10px;
    padding: 12px 16px;
    background: var(--blue);
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: .2s;
}

button:hover {
    filter: brightness(.94);
}

button:disabled {
    opacity: .55;
    cursor: wait;
}

.search-row input {
    flex: 1;
    min-width: 0;
}

.api-row {
    margin-top: 12px;
}

.api-row input {
    max-width: 320px;
    padding: 10px 12px;
}

.scan-actions {
    display: flex;
    gap: 9px;
    margin-top: 13px;
    flex-wrap: wrap;
}

.btn-scan {
    background: #087443;
}

.btn-light {
    background: var(--blue-light);
    color: var(--blue);
}

.btn-dark {
    background: #344054;
}

.btn-close {
    background: #edf2f7;
    color: #344054;
    padding: 8px 12px;
}

/* SCANNER */

.scanner-panel {
    display: none;
    margin-top: 17px;
    border: 1px solid var(--border);
    padding: 14px;
    border-radius: 12px;
}

.scanner-panel.show {
    display: block;
}

.scanner-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

#reader {
    width: 100%;
    max-width: 480px;
    margin: auto;
    overflow: hidden;
    border-radius: 10px;
}

.hint {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

/* RESULTS */

.results {
    margin-top: 20px;
}

.result-title {
    font-size: 18px;
    margin: 0 0 13px;
}

.empty {
    background: white;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    padding: 30px 15px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.error {
    color: #b42318;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
    gap: 15px;
}

/* PRODUCT CARD */

.product-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 5px 18px #1b355508;
    min-width: 0;
}

.product-image {
    display: block;
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
    transition: transform .2s;
}

.product-image:hover {
    transform: scale(1.025);
}

.no-image {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f6f8fb;
    border-radius: 10px;
    color: var(--muted);
    cursor: pointer;
}

.product-name {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.5;
    margin-top: 12px;
    cursor: pointer;
}

.normal-price {
    font-size: 13px;
    color: #98a2b3;
    text-decoration: line-through;
    margin-top: 9px;
}

.promo-price {
    color: var(--green);
    font-size: 24px;
    font-weight: 900;
    margin: 7px 0;
}

/* PLU & BARCODE */

.product-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.product-meta div {
    background: #f5f7fa;
    border-radius: 8px;
    padding: 9px;
    min-width: 0;
}

.product-meta small {
    display: block;
    font-size: 10px;
    color: var(--muted);
    margin-bottom: 5px;
}

.product-meta b {
    display: block;
    font-size: 12px;
    overflow-wrap: anywhere;
}

/* BARCODE VISUAL */

.barcode-box {
    margin-top: 13px;
    padding: 12px 8px;
    background: white;
    border: 1px dashed #d0d5dd;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: .2s;
}

.barcode-box:hover {
    border-color: var(--blue);
    background: #f8fbff;
}

.barcode-box svg {
    display: block;
    max-width: 100%;
    height: auto;
    margin: auto;
}

.barcode-number {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
    margin-top: 5px;
}

.barcode-box small {
    display: block;
    color: var(--muted);
    font-size: 10px;
    margin-top: 5px;
}

.detail-button {
    width: 100%;
    margin-top: 12px;
    background: var(--blue-light);
    color: var(--blue);
}

/* SETTINGS */

.settings {
    background: white;
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 18px;
    margin-top: 13px;
}

.settings.hidden {
    display: none;
}

.settings-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.settings-head h3 {
    margin: 0;
}

.settings label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin: 14px 0 7px;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

textarea {
    min-height: 90px;
    resize: vertical;
}

.button-row {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.message {
    font-size: 12px;
    color: var(--muted);
    margin-top: 12px;
    white-space: pre-wrap;
}

.settings hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* MODAL DETAIL */

.modal {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background: #101828a8;
}

.modal.show {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    background: white;
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 15px 50px #0003;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.modal-head h2 {
    font-size: 18px;
    margin: 0;
}

.detail-image {
    display: block;
    width: 100%;
    height: 220px;
    object-fit: contain;
    margin: 0 auto 15px;
}

#detailContent h3 {
    font-size: 17px;
    line-height: 1.5;
}

.detail-line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.detail-line span {
    color: var(--muted);
}

.detail-line b {
    overflow-wrap: anywhere;
    text-align: right;
}

.detail-barcode {
    text-align: center;
    background: #f8fafc;
    padding: 15px;
    margin-top: 13px;
    border-radius: 10px;
}

.detail-barcode svg {
    display: block;
    max-width: 100%;
    height: auto;
    margin: auto;
}

.detail-barcode b {
    display: block;
    margin-top: 8px;
    letter-spacing: 1px;
}

.json-detail {
    background: #101828;
    color: #d0d5dd;
    padding: 13px;
    border-radius: 9px;
    font-size: 11px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 300px;
    overflow: auto;
}

/* FOOTER */

footer {
    text-align: center;
    color: #98a2b3;
    font-size: 11px;
    padding: 25px 12px;
}

/* MOBILE */

@media (max-width: 600px) {
    .hero {
        padding-top: 23px;
    }

    .hero h1 {
        font-size: 24px;
    }

    .search-row {
        flex-direction: column;
    }

    .search-row button {
        width: 100%;
    }

    .config-grid {
        grid-template-columns: 1fr;
    }

    .product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .product-card {
        padding: 10px;
    }

    .product-image,
    .no-image {
        height: 135px;
    }

    .product-name {
        font-size: 13px;
    }

    .promo-price {
        font-size: 19px;
    }

    .product-meta {
        grid-template-columns: 1fr;
    }

    .barcode-box {
        padding: 8px 4px;
    }

    .barcode-number {
        font-size: 11px;
    }
}

/* Tombol kamera di samping tombol cari */
.search-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.search-row input {
    flex: 1;
    min-width: 0;
}

.btn-scan-camera {
    min-width: 48px;
    padding: 10px;
    font-size: 21px;
    border: none;
    border-radius: 10px;
    background: #e8f1ff;
    color: #1769aa;
    cursor: pointer;
}

.btn-scan-camera:hover {
    background: #d5e7ff;
}

.search-row #searchBtn {
    white-space: nowrap;
}

.api-setting-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.api-setting-row input {
    flex: 1;
    min-width: 0;
}

.api-setting-row button {
    flex-shrink: 0;
}