/*
 * Custom styles for the Corporate QR Scanner Application
 * Mobile-first, responsive design.
 */

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    /* On mobile, the background is black to support the edge-to-edge feel */
    background-color: #000;
}

/* --- Mobile Viewport Styles --- */

/* ISSUE FIX: Only target the #main-window to be the full-screen container on mobile. */
#main-window.window {
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    /* ISSUE FIX: Remove the window border/shadow for a flat, edge-to-edge mobile view. */
    box-shadow: none;
    border: none;
}

.title-bar { flex-shrink: 0; }
.status-bar { flex-shrink: 0; }

.window-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 8px;
    overflow: hidden;
    min-height: 0;
}

.window-body p { margin: 0; }

.title-bar-icon, button img {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 4px;
    image-rendering: pixelated;
}
.title-bar-icon { vertical-align: text-bottom; }

.scanner-view {
    flex-grow: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    overflow: hidden;
}

#camera-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- Modal Styles (Consistent across Mobile & Desktop) --- */
#result-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

/* ISSUE FIX: Style the modal popup as a proper window, but don't let it take over the screen. */
#result-modal-overlay .window {
    height: auto; /* Height is determined by content */
    width: 300px;
    margin: 1em; /* Ensures it doesn't touch the screen edges on mobile */
    /* Restore the classic 98.css window border that was being overridden */
    box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #dfdfdf, inset -2px -2px grey, inset 2px 2px #fff;
    padding: 3px;
    border: none; /* Use box-shadow for border effect */
}

/* ISSUE FIX: The modal's body should not be a fixed height. */
#result-modal-overlay .window-body {
    height: auto;
    overflow: visible;
}

#result-panel {
    padding: 8px;
    min-height: 50px;
    word-break: break-all;
}

.formatted-content p { margin-bottom: 6px; }
.formatted-content p:last-child { margin-bottom: 0; }
.formatted-content strong { display: block; color: #000080; }

/* --- Desktop Styles --- */
@media (min-width: 501px) {
    body {
        /* On desktop, switch to the classic teal background */
        background-color: #008080;
        align-items: center;
        padding: 30px;
    }

    /* ISSUE FIX: Make the main window larger on desktop. */
    #main-window.window {
        min-width: 450px;
        width: 50vw; /* Takes up 50% of the viewport width */
        min-height: 550px;
        height: 70vh; /* Takes up 70% of the viewport height */
        
        /* ISSUE FIX: Restore the classic 98.css window border for desktop. */
        padding: 3px;
        box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #dfdfdf, inset -2px -2px grey, inset 2px 2px #fff;
    }
    
    /* The main window's body should fill the available space within the window. */
    #main-window .window-body {
        height: 100%; /* Let flexbox handle the height calculation */
    }
}