:root {
    color-scheme: dark;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: #050505;
    color: #ffffff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Header styling */
.header {
    width: 100%;
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 15, 18, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.header-title .icon {
    font-size: 20px;
}

.timer-badge {
    background: rgba(255, 255, 255, 0.12);
    color: #e0e0e0;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: "SF Mono", "Courier New", monospace;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Main Camera Container */
.viewport-container {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
}

#qr-reader {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0;
    left: 0;
    background: #000;
    border: none !important;
}

#qr-reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

#qr-reader img[alt="Info icon"],
#qr-reader select,
#qr-reader button,
#qr-reader div:not(#qr-reader) {
    display: none !important;
}

#canvasHidden {
    display: none;
}

/* Overlay Frame */
.scanner-overlay {
    position: relative;
    width: 280px;
    height: 280px;
    z-index: 5;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.scanner-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Green Frame Corners */
.corner {
    position: absolute;
    width: 38px;
    height: 38px;
    border-color: #00f0a8;
    border-style: solid;
    pointer-events: none;
    box-shadow: 0 0 12px rgba(0, 240, 168, 0.4);
}

.top-left {
    top: 0;
    left: 0;
    border-width: 4px 0 0 4px;
    border-top-left-radius: 12px;
}

.top-right {
    top: 0;
    right: 0;
    border-width: 4px 4px 0 0;
    border-top-right-radius: 12px;
}

.bottom-left {
    bottom: 0;
    left: 0;
    border-width: 0 0 4px 4px;
    border-bottom-left-radius: 12px;
}

.bottom-right {
    bottom: 0;
    right: 0;
    border-width: 0 4px 4px 0;
    border-bottom-right-radius: 12px;
}

/* Animated Glowing Laser Scan Line */
.laser-line {
    position: absolute;
    left: 5px;
    right: 5px;
    height: 3px;
    background: linear-gradient(90deg, rgba(0,240,168,0) 0%, rgba(0,240,168,0.95) 50%, rgba(0,240,168,0) 100%);
    box-shadow: 0 0 16px #00f0a8, 0 0 8px #00f0a8;
    top: 10px;
    animation: laserScan 2.4s ease-in-out infinite alternate;
    border-radius: 2px;
}

@keyframes laserScan {
    0% {
        top: 15px;
        opacity: 0.9;
    }
    100% {
        top: 260px;
        opacity: 0.9;
    }
}

/* Instruction Text Footer */
.footer-text {
    position: absolute;
    bottom: 50px;
    left: 0;
    width: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
    font-weight: 400;
    z-index: 6;
    letter-spacing: 0.3px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    transition: opacity 0.3s ease;
}

.footer-text.hidden {
    opacity: 0;
}

/* Toast Notification Alert */
.toast-notification {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(0, 240, 168, 0.95);
    color: #050505;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 15px;
    box-shadow: 0 8px 24px rgba(0, 240, 168, 0.4);
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-notification.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Scan Result Preview Screen Overlay */
.result-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 8, 0.96);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-container.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.preview-card {
    width: 100%;
    max-width: 340px;
    background: rgba(22, 22, 28, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
    text-align: center;
}

.image-wrapper {
    position: relative;
    width: 100%;
    max-width: 240px;
    height: 240px;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 2px solid #00f0a8;
    box-shadow: 0 0 24px rgba(0, 240, 168, 0.35);
    background: #000;
}

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

/* Status Alert Badge */
.status-alert {
    width: 100%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 18px;
    transition: all 0.3s ease;
}

.status-alert.loading {
    background: rgba(255, 255, 255, 0.08);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.status-alert.success {
    background: rgba(0, 240, 168, 0.15);
    color: #00f0a8;
    border: 1px solid rgba(0, 240, 168, 0.3);
}

.status-alert.error {
    background: rgba(255, 71, 87, 0.15);
    color: #ff4757;
    border: 1px solid rgba(255, 71, 87, 0.3);
}

/* Spinner Animation */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #00f0a8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.qr-text-preview {
    width: 100%;
    max-height: 70px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 14px;
    font-family: "SF Mono", "Courier New", monospace;
    font-size: 13px;
    color: #a0a0ab;
    word-break: break-all;
    overflow-y: auto;
    margin-bottom: 20px;
    text-align: left;
}

/* Action Button */
.btn-scan-again {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #00f0a8 0%, #00b37e 100%);
    color: #050505;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 8px 24px rgba(0, 240, 168, 0.35);
    transition: all 0.2s ease;
}

.btn-scan-again:active {
    transform: scale(0.97);
    box-shadow: 0 4px 12px rgba(0, 240, 168, 0.2);
}

/* Expired Container & Screen */
.expired-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: #0b0b12;
    padding: 24px;
}

.expired-card {
    width: 100%;
    max-width: 380px;
    margin: auto;
    padding: 48px 28px 40px;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.expired-clock-icon {
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    filter: drop-shadow(0 8px 20px rgba(229, 57, 53, 0.3));
    animation: bounceSlow 3s ease-in-out infinite alternate;
}

@keyframes bounceSlow {
    0% { transform: translateY(0); }
    100% { transform: translateY(-6px); }
}

.expired-title {
    font-size: 26px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 12px;
    letter-spacing: -0.3px;
}

.expired-desc {
    color: #8c8c9e;
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 36px;
    max-width: 290px;
}

.btn-try-again {
    width: 100%;
    max-width: 280px;
    padding: 16px 32px;
    background: linear-gradient(135deg, #7b78ff 0%, #6865ff 100%);
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    border-radius: 30px;
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 10px 28px rgba(110, 108, 246, 0.4);
    transition: all 0.25s ease;
}

.btn-try-again:active {
    transform: scale(0.97);
    box-shadow: 0 4px 14px rgba(110, 108, 246, 0.25);
}
