/* --- style.css --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}
html {
    box-sizing: border-box;
}
body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif;
    margin: 0;
    padding: 15px;
    line-height: 1.6;
    background: #fffefe;
    background: linear-gradient(
        180deg,
        rgba(255, 254, 254, 1) 0%,
        #f5f5f7 100%
    );
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* --- HEADER STYLES --- */
.site-header {
    width: 100%;
    padding-left: 15px;
    margin-bottom: 15px;
    box-sizing: border-box;
    height: 40px; /* Keep space consistent even without logo */
}

h1 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #2c3e50;
    text-align: center;
}

/* --- INTRO & FINISH SCREEN SHARED STYLES --- */
.intro-container,
.finish-container {
    background-color: #ffffff;
    padding: 30px 15px; /* MODIFIED: Reduced left/right padding */
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 480px; /* UPDATED: Made the container more compact */
    text-align: center;
    margin-top: 20px;
}
.intro-container h2,
.finish-container h2 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 1.5em;
}

/* --- INTRO SCREEN STYLES --- */
.steps-list {
    list-style: none;
    padding: 0;
    margin: 30px auto; /* UPDATED: Use auto margin for centering */
    display: flex;
    flex-direction: column;
    align-items: center; /* UPDATED: Center the list items horizontally */
    gap: 25px;
}
.step-item {
    display: flex;
    align-items: center;
    gap: 20px;
    max-width: 350px; /* UPDATED: Set a max-width for better alignment and wrapping */
    text-align: left; /* UPDATED: Keep text left-aligned relative to its icon */
}
.step-item .icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background-color: #f5f5f7; /* UPDATED: Softer gray background for icon */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.step-item .icon svg {
    width: 24px;
    height: 24px;
    stroke: #8e8e93; /* UPDATED: Changed icon stroke to a specific gray */
    stroke-width: 2;
}
.step-item p {
    margin: 0;
    color: #555;
    font-size: 0.9em; /* UPDATED: Made font smaller as requested */
    line-height: 1.5;
}
.get-started-btn {
    display: block; /* UPDATED: Change to block */
    width: 100%; /* UPDATED: Make width only as big as content + padding */
    margin: 0 auto; /* UPDATED: Use auto margins to center the block */
    padding: 11px 40px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    border: none;
    background-color: #1d1d1f;
    color: white;
    border-radius: 8px;
    transition: background-color 0.3s ease;
    position: relative;
    border: 2px solid rgba(0, 0, 0, 0);
}
.get-started-btn:hover:not(:disabled) {
    border: 2px solid #ffbf1c;
    color: #ffbf1c;
}
.get-started-btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

.get-started-btn.is-loading {
    color: transparent !important; /* Keep text hidden */
    cursor: not-allowed; /* Show not-allowed cursor during load */

    /* --- THE NEW PROGRESS BAR EFFECT --- */
    /* 1. Base color is the disabled gray */
    background-color: #bdc3c7;

    /* 2. On top, we add a solid black gradient that we will resize */
    background-image: linear-gradient(to right, #1d1d1f, #1d1d1f);
    background-repeat: no-repeat;

    /* 3. The size of the black gradient is controlled by our JS variable */
    background-size: var(--progress, 0%) 100%;

    /* 4. Smooth transition for the fill effect */
    transition: background-size 0.1s ease-out;
}

/* This is the spinner, it remains unchanged and will appear on top */
.get-started-btn.is-loading::after {
    content: "";
    display: block;
    width: 1.5em;
    height: 1.5em;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: button-spin 0.8s linear infinite;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -0.75em;
    margin-top: -0.75em;
}

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

/* --- DESKTOP QR MESSAGE STYLES --- */
.desktop-intro-message {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}
.desktop-intro-message p {
    margin: 0 0 15px 0;
    font-weight: 500;
    color: #2c3e50;
    font-size: 1.1em;
}
#qrCodeContainer {
    display: inline-block;
    border-radius: 8px;
    background: white;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    line-height: 0;
}

/* --- FINISH SCREEN STYLES --- */
.finish-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.finish-icon svg {
    width: 40px;
    height: 40px;
    stroke-width: 3;
    display: none; /* Hide all icons by default */
}
#finishMessage {
    font-size: 1.1em;
    color: #333;
    margin-bottom: 5px;
}
#finishInstruction {
    font-size: 1em;
    color: #555;
    margin-top: 0;
    margin-bottom: 25px;
}
#finishActions {
    margin-top: 20px;
}
#redirectButton {
    /* Uses .get-started-btn styles */
}

.finish-container.status-success .finish-icon {
    background-color: #e4f8f0;
}
.finish-container.status-success .finish-icon svg {
    stroke: #27ae60;
}
.finish-container.status-success #successIcon {
    display: block;
}
.finish-container.status-review .finish-icon {
    background-color: #fff8e1;
}
.finish-container.status-review .finish-icon svg {
    stroke: #f39c12;
}
.finish-container.status-review #reviewIcon {
    display: block;
}
.finish-container.status-error .finish-icon {
    background-color: #f8e4e4;
}
.finish-container.status-error .finish-icon svg {
    stroke: #e74c3c;
}
.finish-container.status-error #errorIcon {
    display: block;
}

/* --- "POWERED BY" TEXT STYLES --- */
.powered-by-idnorm {
    margin: 15px auto 20px auto; /* top, horizontal, bottom */
    text-align: center;
    color: #8e8e93; /* Gray from icon stroke */
    font-size: 0.8em; /* Reduced font size */
}

/* --- CAMERA & OVERLAY STYLES (MODERNIZED) --- */
#cameraHost {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 95%;
    margin-bottom: 0;
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Add animation */
@keyframes borderPulse {
    0% {
        border-color: #1525ff;
    }
    25% {
        border-color: #ffbf1c;
    }
    50% {
        border-color: #1525ff;
    }
    75% {
        border-color: #ffbf1c;
    }
    100% {
        border-color: #1525ff;
    }
}

/* Base style for BOTH guide overlays for positioning and vignette effect */
.document-guide-overlay-style,
.head-guide-overlay-style {
    pointer-events: none;
    z-index: 6;
    display: none;
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 9999px rgba(255, 255, 255, 0.9);

    border: 2px solid #1525ff;
    animation: borderPulse 6s ease-in-out infinite; /* 2 cycles = 4 color swaps */
}

/* Modern Document Guide style */
.document-guide-overlay-style {
    top: 43%;
    width: 87%;
    aspect-ratio: 1.59;
    border-radius: 16px;
}

/* Modern Head/Face Guide style */
.head-guide-overlay-style {
    top: 43%;
    width: 60%;
    border-radius: 50%;
    aspect-ratio: 0.75;
}

.document-guide-overlay-style.ov-showing,
.head-guide-overlay-style.ov-showing {
    display: block;
}

#cameraHost video {
    display: none;
    width: 100%;
    height: auto;
    border-radius: 8px;
}

#cameraHost .video-overlay-capture-button {
    position: absolute;
    bottom: 10%;
    left: 50%;
    transform: translateX(-50%);
    width: 11%;
    max-width: 75px;
    min-width: 55px;
    height: auto;
    aspect-ratio: 1;
    z-index: 11;
    cursor: pointer;
    display: none;
    transition: transform 0.2s ease;
}

#cameraHost .video-overlay-capture-button.ov-showing {
    display: block;
}

#cameraHost .video-overlay-capture-button circle {
    fill: #1d1d1f;
    transition: all 0.2s ease-out;
}
#cameraHost .video-overlay-capture-button .button-ring {
    stroke: #1d1d1f;
    fill: none;
}

#cameraHost .video-overlay-capture-button:active {
    transform: translateX(-50%) scale(0.95);
}

/* NEW: Camera "Powered by" text style */
#cameraHost .camera-powered-by {
    position: absolute;
    bottom: 4%;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(29, 29, 31, 0.4);
    font-size: 0.8em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 10;
    pointer-events: none;
    margin: 0;
    padding: 0;
    white-space: nowrap;
}

#cameraHost > .video-overlay-capture-button.landscape-mode {
    width: 8%;
    bottom: 8%;
}
#cameraHost > .document-guide-overlay-style.landscape-mode {
    width: 55%;
    top: 45%;
}
#cameraHost > .head-guide-overlay-style.landscape-mode {
    width: auto;
    height: 70%;
    top: 50%;
}
#cameraHost > .video-overlay-capture-button.landscape-mode {
    width: 8%;
    height: auto;
    bottom: 5%;
}

/* NEW: Camera "Powered by" text landscape style */
#cameraHost > .camera-powered-by.landscape-mode {
    bottom: 2%;
}

#cameraHost .processing-overlay-style {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 254, 254, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
    border-radius: 0px;
}

#cameraHost .processing-overlay-style.ov-showing {
    display: flex;
}

.loader {
    width: 50px;
    aspect-ratio: 1;
    display: grid;
}
.loader::before,
.loader::after {
    content: "";
    grid-area: 1/1;
    --c: no-repeat radial-gradient(farthest-side, #25b09b 92%, #0000);
    background:
        var(--c) 50% 0,
        var(--c) 50% 100%,
        var(--c) 100% 50%,
        var(--c) 0 50%;
    background-size: 12px 12px;
    animation: l12 1s infinite;
}
.loader::before {
    margin: 4px;
    filter: hue-rotate(45deg);
    background-size: 8px 8px;
    animation-timing-function: linear;
}
@keyframes l12 {
    100% {
        transform: rotate(0.5turn);
    }
}

/* --- MODERN MESSAGE STYLES --- */
@keyframes fadeInDownWithWiggle {
    from {
        opacity: 0;
        transform: translate(-50%, -15px);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, 0);
    }
    65% {
        transform: translate(-50%, 0) rotate(3deg);
    }
    80% {
        transform: translate(-50%, 0) rotate(-3deg);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

#cameraHost .message-overlay-base-style {
    position: absolute;
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 400px;
    display: none;
    font-size: 1.1em;
    font-weight: 500;
    text-align: center;
    text-shadow: none;
    z-index: 19;
}

#cameraHost .message-overlay-base-style.text-wiggle {
    animation: fadeInDownWithWiggle 0.7s ease-in-out forwards;
}

#cameraHost .message-overlay-base-style.ov-showing {
    display: block;
}

#cameraHost .message-overlay-base-style.landscape-mode {
    top: 4%;
}

#cameraHost .message-overlay-base-style.message-type-info {
    color: #2c3e50;
}

#cameraHost .message-overlay-base-style.message-type-warning {
    color: #d35400;
}

/* --- FULLSCREEN CAMERA STYLES --- */
body.camera-active {
    overflow: hidden;
    padding: 0;
}
body.camera-active .site-header,
body.camera-active h1,
body.camera-active .powered-by-idnorm {
    display: none;
}
body.camera-active #cameraHost {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
body.camera-active #cameraHost video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
}

/* --- Collapsible Design Controls --- */
#designControls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(44, 62, 80, 0.9);
    color: white;
    padding: 15px 10px 10px 10px;
    z-index: 2000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    display: none;
    font-size: 12px;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    transition: transform 0.3s ease-in-out;
}
#designControls.collapsed {
    transform: translateY(calc(100% - 40px));
}
#designControlsToggle {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 30px;
    background-color: rgba(44, 62, 80, 0.9);
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
#designControlsToggle svg {
    width: 24px;
    height: 24px;
    stroke: white;
    stroke-width: 2;
    transition: transform 0.3s ease-in-out;
}
#designControls.collapsed #designControlsToggle svg {
    transform: rotate(180deg);
}
#designControls fieldset {
    border: 1px solid #7f8c8d;
    border-radius: 4px;
    margin: 5px;
    padding: 8px;
}
#designControls legend {
    padding: 0 5px;
    font-weight: bold;
}
#designControls .controls-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
#designControls button {
    padding: 5px 10px;
    font-size: 12px;
    border: 1px solid #95a5a6;
    background-color: #34495e;
    color: white;
    border-radius: 4px;
    cursor: pointer;
}
#designControls button:hover {
    background-color: #4e6d8d;
}
