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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #fff;
    -webkit-user-select: none;
    user-select: none;
}

/* ── Scanner View ────────────────────────────────────────────────────── */
#scanner-view {
    position: relative;
    width: 100%;
    height: 100%;
}

#camera {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Overlay ─────────────────────────────────────────────────────────── */
#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

#scan-frame {
    position: relative;
    width: 75%;
    max-width: 400px;
    aspect-ratio: 4 / 3;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
}

/* Corner markers */
.corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: #00d4ff;
    border-style: solid;
    border-width: 0;
}

.corner.tl { top: -2px; left: -2px; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 12px; }
.corner.tr { top: -2px; right: -2px; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 12px; }
.corner.bl { bottom: -2px; left: -2px; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 12px; }
.corner.br { bottom: -2px; right: -2px; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 12px; }

/* ── Status Bar ──────────────────────────────────────────────────────── */
#status-bar {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    z-index: 10;
}

#status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #888;
    flex-shrink: 0;
}

#status-dot.pulse {
    background: #00d4ff;
    animation: pulse 1.5s ease-in-out infinite;
}

#status-dot.error {
    background: #ff4444;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* ── Frame Counter ───────────────────────────────────────────────────── */
#frame-counter {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    font-family: monospace;
    z-index: 10;
}

/* ── Result Overlay ──────────────────────────────────────────────────── */
#result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f5f5f5;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#result-overlay.hidden {
    display: none;
    opacity: 0;
}

#result-overlay.show {
    opacity: 1;
}

#result-page {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 12px 24px;
    animation: slideUp 0.4s ease forwards;
}

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

/* Handle bar */
.handle-bar {
    display: flex;
    justify-content: center;
    padding: 12px 0;
}
.handle {
    width: 40px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
}

/* Banners */
.banner {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 14px;
}
.banner-icon {
    font-size: 18px;
    margin-right: 10px;
    flex-shrink: 0;
}
.banner-genuine {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}
.banner-fake {
    background: #fbe9e7;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

/* Cards */
.card {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Product image */
.product-image-card {
    padding: 0;
    overflow: hidden;
}
.product-image-card img {
    width: 100%;
    height: 220px;
    object-fit: contain;
    display: block;
}

/* Serial number */
.serial-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.serial-label {
    color: #666;
    font-size: 14px;
}
.serial-value {
    font-size: 16px;
    font-weight: 700;
    font-family: "SF Mono", monospace;
    color: #333;
}

/* Detail rows */
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}
.detail-label {
    color: #888;
    font-size: 14px;
}
.detail-value {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

/* Accordion */
.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.accordion-title {
    font-size: 16px;
    font-weight: 700;
    color: #333;
}
.accordion-arrow {
    font-size: 12px;
    color: #999;
    transition: transform 0.3s;
}
.accordion-arrow.open {
    transform: rotate(180deg);
}
.accordion-divider {
    height: 1px;
    background: #e4e4e4;
    margin: 12px 0;
}
.accordion-body {
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.accordion-body.collapsed {
    max-height: 0 !important;
    overflow: hidden;
}
.product-name {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    padding-bottom: 6px;
}
.product-desc {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    padding-bottom: 12px;
}
.spec-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
}
.spec-label {
    color: #999;
    font-size: 14px;
}
.spec-value {
    font-weight: 700;
    font-size: 14px;
    color: #333;
}

/* Fake card */
.fake-title {
    font-size: 16px;
    font-weight: 700;
    color: #c62828;
    padding-bottom: 6px;
}

/* Contact card */
.contact-card {
    display: flex;
    align-items: center;
    padding: 16px;
    min-height: 90px;
}
.contact-left {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}
.contact-brand {
    font-weight: 700;
    color: #007DFA;
    font-size: 15px;
}
.contact-divider {
    width: 1px;
    height: 50px;
    background: #e0e0e0;
    margin: 0 16px;
}
.contact-right {
    text-align: center;
}
.contact-label {
    font-size: 12px;
    color: #777;
    margin-bottom: 8px;
}
.contact-icons {
    display: flex;
    gap: 16px;
}
.contact-icon-link {
    font-size: 20px;
    text-decoration: none;
    color: #555;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
#btn-scan-again {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 18px;
    background: #2F76FF;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(47, 118, 255, 0.3);
    transition: background 0.2s;
}

#btn-scan-again:hover {
    background: #1a5fd4;
}

#btn-scan-again:active {
    transform: scale(0.98);
}

/* ── Error Overlay ───────────────────────────────────────────────────── */
#error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

#error-overlay.hidden {
    display: none;
}

#error-card {
    width: 85%;
    max-width: 340px;
    background: #1a1a2e;
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    border: 2px solid rgba(255, 23, 68, 0.3);
}

#error-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 23, 68, 0.2);
    color: #ff1744;
    font-size: 30px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

#error-message {
    color: #ccc;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 24px;
}

#error-card button {
    padding: 12px 32px;
    border: none;
    border-radius: 10px;
    background: #ff1744;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

/* ── Embed Link ─────────────────────────────────────────────────────── */
#embed-link {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #00d4ff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    z-index: 10;
}

#embed-link:hover { background: rgba(0, 212, 255, 0.2); }

/* ── Capture Bar ────────────────────────────────────────────────────── */
#capture-bar {
    position: absolute;
    bottom: 110px;
    left: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 10;
}

#btn-capture {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 4px solid #fff;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

#btn-capture:active {
    transform: scale(0.9);
}

#capture-ring {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #fff;
    transition: background 0.2s;
}

#btn-capture.processing #capture-ring {
    background: #00d4ff;
    animation: pulse 1s ease-in-out infinite;
}

#btn-gallery {
    padding: 10px 20px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

#btn-gallery:active {
    background: rgba(255, 255, 255, 0.3);
}

/* ── Video Card ─────────────────────────────────────────────────────── */
.video-title {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    margin-bottom: 12px;
}
.video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}
.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ── Processing Overlay ─────────────────────────────────────────────── */
#processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
}

#processing-overlay.hidden {
    display: none;
}

.processing-content {
    text-align: center;
}

.processing-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #0072ee;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}

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

.processing-text {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* ── Safe area for notched phones ────────────────────────────────────── */
@supports (padding-top: env(safe-area-inset-top)) {
    #frame-counter {
        top: calc(20px + env(safe-area-inset-top));
    }
    #status-bar {
        bottom: calc(60px + env(safe-area-inset-bottom));
    }
}
