/* ==========================================================================
   Base Reset & Layout Shell
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
}

/* App Container (for split-view layouts if file listing sidebar is used) */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* ==========================================================================
   Header & Logo Navigation Bar
   ========================================================================== */
.logo-container {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Keeps empty/left area, buttons center, logo right */
    padding: 12px 24px;
    background-color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.logo-container .controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center; /* Centers the image buttons horizontally */
    gap: 8px;
    margin: 0 auto; /* Pushes the buttons to the middle */
}

.logo-container img {
    max-height: 48px;
    width: auto;
    object-fit: contain;
    margin-left: auto; /* Ensures logo anchors to the far right */
}

/* ==========================================================================
   Left Sidebar / File List (Optional Split Layout)
   ========================================================================== */
/* HEADER stays visible */
#file-list-header {
    padding: 10px;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid #ddd;
}
/* Left panel with file list */
#file-list {
    width: 250px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ccc;
}
/* Scroll only the images */
#file-list-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}
/* Right panel for preview */
#preview {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

/* File card style */
.file-card {
    width: 100%;
    height: 120px;
    background-size: cover;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 2px black;
    padding-bottom: 5px;
    cursor: pointer;
    border: 1px solid #aaa;
    position: relative; /* needed for delete button positioning */
    margin-bottom: 5px;
}


.file-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.file-card.selected {
    outline: 3px solid #ef4444;
    border-color: transparent;
}


/* Delete button inside card */
.delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(255,0,0,0.7);
    border: none;
    color: white;
    font-weight: bold;
    padding: 0;
    cursor: pointer;
    border-radius: 3px;
    width: 20px;
    height: 20px;
    text-align: center;
    line-height: 20px; /* vertical center X */
    font-size: 12px; /* make X fit nicely */
}

/* Hover effect for delete */
.delete-btn:hover {
    background-color: rgba(255,0,0,1);
}


/* Download button */
.btn-download {
    margin-top: 10px;
    padding: 5px 10px;
    cursor: pointer;
    background-color: limegreen;
    border-radius: 3px;
    border-color: black;
    border-width: 1px;
    width: 110px;
    height: 50px;
}

.btn-download:hover {
    margin-top: 10px;
    padding: 5px 10px;
    cursor: pointer;
    background-color: #8cf58c ;
    border-radius: 3px;
    border-color: black;
    border-width: 1px;
    width: 110px;
    height: 50px;
}



/* ==========================================================================
   Main Editor & Upload Card
   ========================================================================== */
.editor {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.upload-card {
    background: #ffffff;
    padding: 24px;
    border-radius: 16px;
    width: 95%;
    max-width: 650px;
    margin: 20px auto;
}

.upload-btn {
    font-size: 1.1rem;
    padding: 12px 32px;
    border-radius: 10px;
}

/* ==========================================================================
   Modernized Controls & Buttons Toolbar
   ========================================================================== */

.controls {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
    width: 100%;
}

/* Base Modern Button Style Override */
.controls .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    user-select: none;
}

/* Subtle Lift on Hover */
.controls .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* Tactile Click Feedback */
.controls .btn:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Focus Ring for Keyboard & Accessibility */
.controls .btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Modern Color Overrides mapped to standard Bootstrap classes */
.controls .btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #ffffff;
}
.controls .btn-success:hover {
    background: linear-gradient(135deg, #16a34a, #15803d);
}

.controls .btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #ffffff;
}
.controls .btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.controls .btn-warning {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #ffffff;
}
.controls .btn-warning:hover {
    background: linear-gradient(135deg, #ea580c, #c2410c);
}

.controls .btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff;
}
.controls .btn-primary:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}


/* Preview image */
#preview-img {
    max-width: 80%;
    max-height: 80%;
}

/* Dedicated Admin Right Panel Image Display */
#preview-panel {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}
/* ==========================================================================
   Fully Responsive WYSIWYG Canvas Container
   ========================================================================== */
.preview-container {
    position: relative;
    /* Dynamically scales between 320px on mobile up to 580px on large monitors */
    height: clamp(350px, 60vh, 550px);
    aspect-ratio: 5 / 8; /* Strict 500x800 aspect ratio lock */
    width: auto; /* Width is automatically calculated from height + aspect-ratio */
    max-width: 90vw; /* Safety barrier so it never leaks off narrow screens horizontally */
    overflow: hidden;
    margin: 0 auto;
    background-color: #000000;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    touch-action: none;
}

/* Base Layers */
#preview, #uploadLayer, #previewMask {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
     z-index: 1;
}


.upload-layer {
    z-index: 5;
    display: none;
    pointer-events: none;
}

#previewMask {
    z-index: 10;
    pointer-events: none;
}

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

#maskLayerImage {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* Interactive Upload Image Overlay */
#uploadPreviewImage {
    position: absolute;
    width: 200px;
    height: auto;
    left: 0;
    top: 0;
    transform-origin: center center;
    cursor: grab;
    user-select: none;
    touch-action: none;
    pointer-events: auto;
}

#uploadPreviewImage:active {
    cursor: grabbing;
}

.preview-box img {
    max-width: 100%;
    max-height: 250px;
    display: none;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
   /* background: #1e293b; */
    color: #000000;
    padding: 14px;
    font-size: 1.1rem;
    text-align: center;
    margin-top: auto;
}

/* ==========================================================================
   Floating Picture-in-Picture (pin) Keypad Overlay
   ========================================================================== */
.pin-keypad {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: clamp(280px, 90vw, 360px); /* Smoothly resizes across mobile & desktop */
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.08);
    z-index: 99999 !important;
    user-select: none;
    overflow: hidden;
    display: none;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.pin-header {
    background: #1e293b;
    color: #ffffff;
    padding: 12px 16px;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    touch-action: none;
}

.pin-header .close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s ease;
}

.pin-header .close-btn:hover {
    background: #ef4444;
}

.pin-display {
    padding: 16px;
    text-align: center;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.pin-display input {
    width: 100%;
    height: 48px;
    font-size: 24px;
    text-align: center;
    letter-spacing: 6px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    outline: none;
    background: #ffffff;
    color: #0f172a;
    font-weight: 700;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03);
}

.pin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 16px;
    background: #ffffff;
}

.pin-btn {
    height: 52px;
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pin-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.pin-btn:active {
    transform: scale(0.95);
    background: #cbd5e1;
}

.pin-btn.action {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
    font-size: 15px;
}

.pin-btn.submit {
    background: #22c55e;
    color: #ffffff;
    border-color: #16a34a;
    font-size: 20px;
}

.pin-btn.submit:hover {
    background: #16a34a;
}

/* ==========================================================================
   Media Queries (Responsive Device Scaling)
   ========================================================================== */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    #file-list {
        width: 100%;
        height: auto;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }



    .logo-container {
        flex-direction: column;
        text-align: center;
        padding: 12px 16px;
    }

    .logo-container .controls {
        justify-content: center;
    }



    .upload-card {
        padding: 14px;
        margin: 10px auto;
        border-radius: 12px;
    }

    .controls .btn {
        min-width: 45%;
        padding: 10px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .pin-keypad {
        width: 92vw;
    }

    .pin-btn {
        height: 46px;
        font-size: 18px;
    }
}








/* ==========================================================================
   Settings Page Specific Layout
   ========================================================================== */
.settings-container {
    max-width: 1100px;
    margin: 40px auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.card {
    border-radius: 14px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.card-header {
    font-weight: bold;
    font-size: 1.1rem;
}

.whitelist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #ddd;
}

.qr-preview {
    max-width: 220px;
    border-radius: 10px;
    border: 1px solid #ccc;
}

.top-actions {
    max-width: 1100px;
    margin: 20px auto 0;
    display: flex;
    justify-content: space-between;
}

.top-actions .btn {
    height: 50px;
    line-height: 50px;
    padding: 0 20px;
    font-size: 1rem;
}

/* Mobile responsive fallback for Settings grid */
@media (max-width: 768px) {
    .settings-container {
        grid-template-columns: 1fr;
        padding: 0 16px;
        margin: 20px auto;
    }

    .top-actions {
        padding: 0 16px;
    }
}









