/* ═══════════════════════════════════════════════════════════════
   Photobooth B&AA - Opschone & Verbeterde Stylesheet
   ═══════════════════════════════════════════════════════════════ */

/* ── Variabelen & Basis ────────────────────────────────────────── */
:root {
    /* Kleurenpalet */
    --bg-color: #F6F1F1;      /* Zeer lichtgrijs/wit */
    --primary-blue: #146C94;   /* Donkerblauw (knoppen, titels) */
    --accent-blue: #19A7CE;    /* Felblauw (badges, outlines) */
    --succes-bg: #AFD3E2;      /* Lichtblauw (succesbox) */
    --error-red: #F47174;      /* Rood (foutmeldingen) */
    
    --flash-color: rgba(255, 255, 255, 0.9);
    --font-base: Arial, sans-serif;
    --border-radius-large: 12px;
    --border-radius-small: 8px;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    font-family: var(--font-base);
    color: #333;
    /* Voorkom 'pull-to-refresh' effect op mobiel */
    overscroll-behavior-y: contain; 
}

#app {
    padding-bottom: 30px; /* Ruimte onderaan */
}

h2 {
    color: var(--primary-blue);
    margin: 0;
    font-size: 1.4em;
}

/* ── Camera Sectie (Staand formaat) ───────────────────────────── */
#cameraContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 10px;
}

#cameraWrap {
    position: relative; /* Nodig voor absolute positionering van switch knop & flash */
    /* Behoud 500x750 (2:3) aspect ratio */
    width: min(400px, 90vw); 
    aspect-ratio: 500 / 750;
    background-color: black;
    border-radius: var(--border-radius-large);
    overflow: hidden; /* Zorgt dat video binnen corners blijft */
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Vul het vak zonder vervorming */
    display: block;
}

/* Spiegel selfie camera */
.flipped {
    transform: rotateY(180deg);
}

/* Flits overlay */
#flash {
    position: absolute;
    inset: 0; /* top, right, bottom, left op 0 */
    background-color: transparent;
    display: none;
    z-index: 5;
    pointer-events: none; /* Klik er doorheen */
}

.flashActive {
    display: block !important;
    animation: flashAnim 0.25s ease-out;
}

@keyframes flashAnim {
    0% { background-color: transparent; }
    50% { background-color: var(--flash-color); }
    100% { background-color: transparent; }
}

/* countdown getal over video */
#countdownOverlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 8rem;
    font-weight: bold;
    text-shadow: 0 0 20px rgba(0,0,0,0.5);
    z-index: 4;
    pointer-events: none;
}

/* ── Reverse Camera Knop (Wit, over video) ───────────────────── */
#cameraSwitchBtn {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;

    position: absolute;
    top: 15px;
    right: 15px;
    color: white !important; /* Forceer wit */
    background-color: rgba(0, 0, 0, 0.3); /* Halftransparante achtergrond voor contrast */
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10; /* Boven de video */
    font-size: 28px; /* Grootte van het icoon */
    
    /* Zorg dat het er goed uitziet als Material Icon */
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

#cameraSwitchBtn:hover {
    background-color: rgba(0, 0, 0, 0.5);
}

/* Verberg switch knop op desktop als er waarschijnlijk maar 1 camera is */
@media (min-width: 1024px) {
    /* Optioneel: verbergen op desktop */
    /* #cameraSwitchBtn { display: none; } */
}

/* ── Grids (3 Foto's per rij) ────────────────────────────────── */
#selectionSection, #collageSection {
    margin: 20px 16px;
}

#selectHeader, #collageHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 4px;
}

#selectCount {
    color: var(--accent-blue);
    font-weight: bold;
}

#gridHint {
    font-size: 0.85em;
    color: #777;
    margin: -5px 4px 10px;
}

/* De Grid definitie voor 3 kolommen */
#photoGridTop, #photoGridRest, #collageGrid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Exact 3 gelijke kolommen */
    gap: 10px; /* Ruimte tussen foto's */
    margin-bottom: 15px;
}

/* Thumbnail styling */
.gridThumb, .collageThumb {
    position: relative;
    /* thumbnails niet meer vierkant */
 /* Vierkante vakjes */
    border-radius: var(--border-radius-small);
    overflow: hidden;
    background-color: #ddd;
    cursor: pointer;
    box-sizing: border-box;
    transition: transform 0.1s ease, outline 0.1s ease;
    border: 2px solid transparent; /* Basis border voor layout stabiliteit */
}



/* Ratio's zodat er minder wordt afgesneden */
.gridThumb{ aspect-ratio: 2 / 3; }
.collageThumb{ aspect-ratio: 2 / 3; }

/* Foto-thumbnails: toon de hele foto (geen afsnijden) */
.gridThumb{ background-color: #000; }
.gridThumb img{
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

.collageThumb img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Voorkom squeezien */
    display: block;
}

/* Geselecteerde foto styling */
.gridThumb.selected {
    outline: 4px solid var(--accent-blue); /* Dikke blauwe rand */
    outline-offset: -4px; /* Rand binnen de foto */
    transform: scale(0.96); /* Iets kleiner effect */
}

/* Nummer badge (1, 2, 3, 4) */
.selectBadge {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: var(--accent-blue);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Verberg lege badges */
.selectBadge:empty {
    display: none;
}

/* ── Knoppen Styles ───────────────────────────────────────────── */
.bigBtn {
    font-size: 1.2em;
    padding: 16px;
    background-color: var(--primary-blue);
    color: white;
    font-weight: bold;
    border: none;
    border-radius: var(--border-radius-large);
    width: calc(100% - 32px); /* Rekening houdend met marge */
    margin: 10px 16px;
    cursor: pointer;
    display: block;
    box-shadow: 0 3px 6px rgba(0,0,0,0.16);
    transition: background 0.2s;
    -webkit-appearance: none; /* Fix voor iOS styling */
}

.bigBtn:active {
    background-color: #0f5070;
    transform: translateY(1px);
}

.bigBtn:disabled {
    background-color: #A0BCC2;
    cursor: not-allowed;
    box-shadow: none;
}

/* Terug knop styling */
.outlineBtn {
    font-size: 1.1em;
    padding: 14px;
    background-color: transparent;
    color: var(--primary-blue);
    font-weight: bold;
    border: 2px solid var(--primary-blue);
    border-radius: var(--border-radius-large);
    cursor: pointer;
    flex: 1; /* Neemt beschikbare ruimte in flexbox */
    transition: background 0.2s;
}

.outlineBtn:active {
    background-color: rgba(20, 108, 148, 0.1);
}

#selectActions {
    margin: 10px 0;
    text-align: center;
}

/* ── Paginering ───────────────────────────────────────────────── */
.photoPager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 10px 0 20px;
    border-top: 1px solid #e0e0e0;
    margin-top: 15px;
}

.pagerBtn {
    background-color: #fff;
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue);
    border-radius: var(--border-radius-small);
    padding: 8px 16px;
    font-size: 0.9em;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.pagerBtn:hover {
    background-color: var(--primary-blue);
    color: white;
}

.pagerInfo {
    font-size: 0.9em;
    color: #555;
    font-weight: bold;
}

/* ── Preview Overlay (Gevraagde Transparante Achtergrond) ─────── */
#previewOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Gevraagd: transparante zwarte achtergrond */
    background-color: rgba(0, 0, 0, 0.85); 
    display: none; /* Verborgen bij start */
    z-index: 100; /* Boven alles */
    justify-content: center;
    align-items: center;
    overflow-y: auto; /* Scrollen toestaan binnen overlay indien nodig */
    backdrop-filter: blur(3px); /* Licht blur effect achtergrond */
}

#previewOverlay.open {
    display: flex; /* Toon als open class aanwezig is */
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#previewBox {
    background-color: white;
    padding: 20px;
    border-radius: var(--border-radius-large);
    width: 90%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    margin: 20px; /* Marge voor scrollruimte op kleine schermen */
    position: relative;
}

#previewBox h2 {
    margin-bottom: 15px;
}

/* Het collage canvas binnen de preview */
#canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 500 / 750; /* Behoud staand formaat */
    background-color: #eee;
    border-radius: 4px;
    display: block;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#printBtn {
    /* De knop is standaard zichtbaar, maar JS kan hem verbergen */
    display: block;
}

#previewActions {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-top: 15px;
}

/* Zorg dat als de printknop weg is, de 'Terug' knop de volle breedte pakt */
#previewActions .outlineBtn {
    flex: 1;
}

#printedNotice {
    color: #21C552;
    font-weight: bold;
    margin-top: 10px;
}

/* ── SuccesBox (Meldingen) ───────────────────────────────────── */
#succesBox {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px); /* Start boven scherm */
    width: 80%;
    max-width: 400px;
    background-color: var(--succes-bg);
    color: var(--primary-blue);
    padding: 10px 20px;
    text-align: center;
    border-radius: var(--border-radius-small);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 200;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none; /* Klik er doorheen */
}

#succesBox p {
    margin: 5px 0;
    font-weight: bold;
    font-size: 0.95em;
}

#succesBox.show {
    transform: translateX(-50%) translateY(0); /* Kom in beeld */
}

#succesBox.hide {
    transform: translateX(-50%) translateY(-100px); /* Ga uit beeld */
}

/* Preview knoppen: gelijke hoogte (Terug / Printen / Opslaan) */
#previewActions .bigBtn,
#previewActions .outlineBtn{
    margin: 0;
    width: auto;
    flex: 1;
    height: 56px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
