/* ============================================================
   Mobile Scan Tab Styles
   Fullscreen camera capture experience for photogrammetry
   Theme: Dark (#0a0a0a bg, #3b82f6 accent blue)
   Loaded via <link> in scan.ejs
   ============================================================ */


/* ------------------------------------------------------------
   1. Mobile Scan Container
   ------------------------------------------------------------ */

.mobile-scan-container {
    position: relative;
    height: calc(100vh - 60px);
    overflow: hidden;
    background: #0a0a0a;
    display: flex;
    flex-direction: column;
}


/* ------------------------------------------------------------
   2. Camera Preview
   ------------------------------------------------------------ */

.mobile-camera-preview {
    position: relative;
    width: 100%;
    height: 75vh;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
}

.mobile-camera-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}


/* ------------------------------------------------------------
   3. Turntable Guide Overlay
   ------------------------------------------------------------ */

.mobile-guide-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
}

.mobile-guide-overlay .guide-ring {
    width: 55%;
    aspect-ratio: 1;
    border: 2px dashed rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-guide-overlay .guide-ring::before {
    content: '';
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        transparent 48%,
        rgba(0, 0, 0, 0.35) 52%,
        rgba(0, 0, 0, 0.35) 100%
    );
    pointer-events: none;
}

.mobile-guide-overlay svg {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}


/* ------------------------------------------------------------
   4. Shutter Button
   ------------------------------------------------------------ */

.mobile-shutter-btn {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid #fff;
    background: transparent;
    cursor: pointer;
    z-index: 10;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease;
}

.mobile-shutter-btn::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.mobile-shutter-btn:active {
    transform: translateX(-50%) scale(0.85);
}

.mobile-shutter-btn:active::after {
    background: #d4d4d4;
    transform: scale(0.9);
}


/* ------------------------------------------------------------
   5. Control Buttons (switch camera, done)
   ------------------------------------------------------------ */

.mobile-control-btn {
    position: fixed;
    bottom: 40px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(30, 30, 30, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.2s ease;
}

.mobile-control-btn:active {
    background: rgba(60, 60, 60, 0.9);
}

.mobile-control-btn--left {
    left: calc(50% - 80px);
}

.mobile-control-btn--right {
    left: calc(50% + 48px);
}

.mobile-control-btn svg,
.mobile-control-btn img {
    width: 22px;
    height: 22px;
}


/* ------------------------------------------------------------
   6. Photo Counter Badge
   ------------------------------------------------------------ */

.mobile-counter {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    background: #3b82f6;
    color: #fff;
    border-radius: 20px;
    padding: 6px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    min-width: 48px;
}

.mobile-counter .counter-number {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.mobile-counter .counter-label {
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.85;
    margin-top: 2px;
}


/* ------------------------------------------------------------
   7. Height Guide (3-level indicator)
   ------------------------------------------------------------ */

.mobile-height-guide {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.mobile-height-guide .height-level {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.mobile-height-guide .height-level.active {
    opacity: 1;
}

.mobile-height-guide .height-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.mobile-height-guide .height-level.active .height-dot {
    background: #3b82f6;
    border-color: #3b82f6;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

.mobile-height-guide .height-label {
    font-size: 9px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    writing-mode: horizontal-tb;
}

.mobile-height-guide .height-level.active .height-label {
    color: #3b82f6;
}


/* ------------------------------------------------------------
   8. Photo Strip (horizontal scrollable thumbnails)
   ------------------------------------------------------------ */

.mobile-photo-strip {
    position: relative;
    width: 100%;
    height: 72px;
    padding: 8px 0;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-mask-image: linear-gradient(
        to right,
        transparent 0px,
        #000 16px,
        #000 calc(100% - 16px),
        transparent 100%
    );
    mask-image: linear-gradient(
        to right,
        transparent 0px,
        #000 16px,
        #000 calc(100% - 16px),
        transparent 100%
    );
    padding-left: 16px;
    padding-right: 16px;
}

.mobile-photo-strip::-webkit-scrollbar {
    display: none;
}

.mobile-photo-strip .strip-thumb {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #1a1a1a;
    border: 1px solid #333;
}

.mobile-photo-strip .strip-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.mobile-photo-strip .strip-thumb .strip-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.75);
    border: none;
    color: #fff;
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-photo-strip .strip-thumb:hover .strip-remove,
.mobile-photo-strip .strip-thumb:active .strip-remove {
    opacity: 1;
}

/* On touch devices, always show remove button */
@media (hover: none) and (pointer: coarse) {
    .mobile-photo-strip .strip-thumb .strip-remove {
        opacity: 0.7;
    }
}


/* ------------------------------------------------------------
   9. Flash Overlay
   ------------------------------------------------------------ */

.mobile-flash {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 3;
    transition: opacity 0.1s ease;
}

.mobile-flash.flash {
    opacity: 0.7;
}


/* ------------------------------------------------------------
   10. Angle Indicator
   ------------------------------------------------------------ */

.mobile-angle-text {
    position: absolute;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 8px;
    pointer-events: none;
}

.mobile-angle-text .angle-value {
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.mobile-angle-text .angle-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


/* ------------------------------------------------------------
   11. Done Banner
   ------------------------------------------------------------ */

.mobile-done-banner {
    position: fixed;
    bottom: 120px;
    left: 16px;
    right: 16px;
    z-index: 9;
    background: #16a34a;
    color: #fff;
    border-radius: 12px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transform: translateY(200%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 24px rgba(22, 163, 74, 0.35);
}

.mobile-done-banner.visible {
    transform: translateY(0);
}

.mobile-done-banner .done-text {
    font-size: 15px;
    font-weight: 600;
}

.mobile-done-banner .done-subtext {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
}

.mobile-done-banner .done-arrow {
    font-size: 20px;
    opacity: 0.7;
}

.mobile-done-banner:active {
    background: #15803d;
}


/* ------------------------------------------------------------
   12. Camera Permission Denied
   ------------------------------------------------------------ */

.mobile-no-camera {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 24px;
    text-align: center;
    color: #888;
}

.mobile-no-camera .no-camera-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    opacity: 0.4;
}

.mobile-no-camera .no-camera-icon svg {
    width: 100%;
    height: 100%;
}

.mobile-no-camera h3 {
    font-size: 18px;
    font-weight: 600;
    color: #ccc;
    margin-bottom: 8px;
}

.mobile-no-camera p {
    font-size: 14px;
    line-height: 1.5;
    color: #666;
    max-width: 300px;
    margin-bottom: 16px;
}

.mobile-no-camera a {
    color: #3b82f6;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.mobile-no-camera a:hover {
    text-decoration: underline;
}


/* ------------------------------------------------------------
   13. Responsive Adjustments
   ------------------------------------------------------------ */

/* Desktop: constrain preview, show side panel layout */
@media (min-width: 769px) {
    .mobile-scan-container {
        max-width: 900px;
        margin: 0 auto;
        height: auto;
        min-height: calc(100vh - 60px);
        overflow: visible;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 20px;
        padding: 20px;
    }

    .mobile-camera-preview {
        width: 60%;
        height: 500px;
        max-height: 65vh;
        flex-shrink: 0;
    }

    .mobile-scan-sidebar {
        flex: 1;
        min-width: 240px;
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .mobile-photo-strip {
        width: 100%;
        height: 80px;
    }

    .mobile-photo-strip .strip-thumb {
        width: 64px;
        height: 64px;
    }

    .mobile-shutter-btn {
        position: relative;
        bottom: auto;
        left: auto;
        transform: none;
        margin: 16px auto;
    }

    .mobile-shutter-btn:active {
        transform: scale(0.85);
    }

    .mobile-control-btn {
        position: relative;
        bottom: auto;
        left: auto;
    }

    .mobile-control-btn--left,
    .mobile-control-btn--right {
        left: auto;
    }

    .mobile-controls-bar {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 20px;
        padding: 16px 0;
    }

    .mobile-done-banner {
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
        transform: translateY(20px);
        opacity: 0;
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                    opacity 0.3s ease;
    }

    .mobile-done-banner.visible {
        transform: translateY(0);
        opacity: 1;
    }

    .mobile-height-guide {
        position: relative;
        left: auto;
        top: auto;
        transform: none;
        flex-direction: row;
        gap: 24px;
    }
}

/* Mobile: fullscreen feel, larger touch targets */
@media (max-width: 768px) {
    .mobile-scan-container {
        height: 100vh;
        height: 100dvh;
        padding: 0;
        border-radius: 0;
    }

    .mobile-camera-preview {
        height: calc(100dvh - 160px);
        border-radius: 0;
    }

    .mobile-shutter-btn {
        width: 76px;
        height: 76px;
        bottom: 28px;
    }

    .mobile-control-btn {
        width: 52px;
        height: 52px;
        font-size: 22px;
        bottom: 42px;
    }

    .mobile-control-btn--left {
        left: calc(50% - 88px);
    }

    .mobile-control-btn--right {
        left: calc(50% + 52px);
    }

    .mobile-counter {
        top: 8px;
        right: 8px;
    }

    .mobile-height-guide {
        left: 8px;
    }

    .mobile-photo-strip {
        height: 64px;
        padding: 4px 0;
        padding-left: 12px;
        padding-right: 12px;
    }

    .mobile-photo-strip .strip-thumb {
        width: 48px;
        height: 48px;
        border-radius: 4px;
    }

    .mobile-photo-strip .strip-thumb .strip-remove {
        opacity: 0.7;
    }

    .mobile-done-banner {
        bottom: 116px;
        left: 12px;
        right: 12px;
    }

    .mobile-angle-text .angle-value {
        font-size: 16px;
    }
}

/* Small phones (SE, etc.) */
@media (max-width: 375px) {
    .mobile-camera-preview {
        height: calc(100dvh - 140px);
    }

    .mobile-shutter-btn {
        width: 68px;
        height: 68px;
        bottom: 20px;
    }

    .mobile-control-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
        bottom: 36px;
    }

    .mobile-control-btn--left {
        left: calc(50% - 76px);
    }

    .mobile-control-btn--right {
        left: calc(50% + 44px);
    }

    .mobile-counter .counter-number {
        font-size: 17px;
    }

    .mobile-photo-strip .strip-thumb {
        width: 44px;
        height: 44px;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .mobile-scan-container {
        flex-direction: row;
    }

    .mobile-camera-preview {
        width: 65%;
        height: 100dvh;
        border-radius: 0;
    }

    .mobile-shutter-btn {
        position: fixed;
        right: 24px;
        bottom: 50%;
        left: auto;
        transform: translateY(50%);
        width: 64px;
        height: 64px;
    }

    .mobile-shutter-btn:active {
        transform: translateY(50%) scale(0.85);
    }

    .mobile-control-btn {
        position: fixed;
        right: 32px;
        left: auto;
    }

    .mobile-control-btn--left {
        bottom: calc(50% + 52px);
        left: auto;
    }

    .mobile-control-btn--right {
        bottom: calc(50% - 88px);
        left: auto;
    }

    .mobile-photo-strip {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 72px;
        height: 100dvh;
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 12px 8px;
        -webkit-mask-image: linear-gradient(
            to bottom,
            transparent 0px,
            #000 16px,
            #000 calc(100% - 16px),
            transparent 100%
        );
        mask-image: linear-gradient(
            to bottom,
            transparent 0px,
            #000 16px,
            #000 calc(100% - 16px),
            transparent 100%
        );
    }

    .mobile-height-guide {
        left: auto;
        right: 84px;
        flex-direction: column;
    }

    .mobile-counter {
        top: 8px;
        left: 8px;
        right: auto;
    }

    .mobile-done-banner {
        bottom: 12px;
        left: 12px;
        right: 100px;
    }
}


/* ------------------------------------------------------------
   Utility: Safe area insets (notched phones)
   ------------------------------------------------------------ */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-shutter-btn {
        bottom: calc(24px + env(safe-area-inset-bottom));
    }

    .mobile-control-btn {
        bottom: calc(40px + env(safe-area-inset-bottom));
    }

    .mobile-done-banner {
        bottom: calc(120px + env(safe-area-inset-bottom));
    }
}
