/* ============================================================
   Check-in Vacancier — Mobile-first
   ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0; padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

:root {
    --primary:   #0f766e;
    --primary-d: #0e7490;
    --primary-l: #ccfbf1;
    --absent:    #dc2626;
    --absent-bg: #fee2e2;
    --dmg:       #d97706;
    --dmg-bg:    #fef3c7;
    --ok:        #16a34a;
    --ok-bg:     #dcfce7;
    --text:      #1a202c;
    --muted:     #6b7280;
    --border:    #e5e7eb;
    --card:      #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    -webkit-font-smoothing: antialiased;
}

.card {
    background: var(--card);
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: up .35s ease;
}

@keyframes up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header de la card ── */
.card-head {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-d) 100%);
    color: #fff;
    padding: 20px;
    text-align: center;
}
.card-head .icon  { font-size: 40px; margin-bottom: 6px; }
.card-head h1     { font-size: 20px; font-weight: 700; }
.card-head .sub   { font-size: 13px; opacity: .8; margin-top: 4px; }

/* ── Barre de progression ── */
.progress-bar {
    height: 5px;
    background: #e5e7eb;
}
.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width .4s ease;
}

/* ── Contenu ── */
.card-body { padding: 24px 20px; }

/* ── Formulaire ── */
.form-group { margin-bottom: 18px; }
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}
label .req { color: #ef4444; }
input[type="text"],
input[type="number"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 16px;    /* évite le zoom iOS */
    font-family: inherit;
    background: #fff;
    transition: border-color .2s;
    -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}
textarea { resize: vertical; min-height: 70px; }

/* ── Bouton principal ── */
.btn-main {
    display: block;
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-d) 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    touch-action: manipulation;
}
.btn-main:active { transform: scale(.98); }
.btn-main:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
    display: block;
    width: 100%;
    padding: 13px;
    background: transparent;
    border: 2px solid var(--border);
    color: var(--muted);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: border-color .2s, color .2s;
}
.btn-secondary:active { background: #f9fafb; }

/* ── Erreur / Info ── */
.msg-error {
    background: var(--absent-bg);
    color: #b91c1c;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}
.msg-error.visible { display: block; }

/* ── Onglets catégories ── */
.cat-tabs {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding: 12px 20px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
    background: var(--card);
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
    flex-shrink: 0;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid var(--border);
    color: var(--muted);
    background: var(--card);
    transition: all .15s;
    white-space: nowrap;
    touch-action: manipulation;
}
.cat-tab.done    { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.cat-tab.active  { border-color: var(--primary); color: var(--primary); background: var(--primary-l); }
.cat-tab.alerte  { border-color: var(--absent); color: var(--absent); background: var(--absent-bg); }

/* ── Sticky layout écran items ── */
#screen-items {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    padding: 0; /* override .card-body */
}
#screen-recap,
#screen-signature {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}
#items-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    padding: 16px 20px;
}
.nav-cats {
    flex-shrink: 0;
    display: flex;
    gap: 10px;
    padding: 12px 20px 20px;
    border-top: 1px solid var(--border);
    background: var(--card);
}

/* ── Items ── */
.item-block {
    border: 1.5px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: border-color .2s;
    background: #ffffff;
}
.item-block:nth-child(even) { background: #e9eaec; }
.item-block.is-absent    { border-color: var(--absent); }
.item-block.is-endommage { border-color: var(--dmg); }
.item-block.is-present   { border-color: var(--ok); }

.item-head {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.item-name {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
}
.item-qty {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

/* Boutons statut */
.statut-btns {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    padding: 0 16px 14px;
}
.statut-btn {
    flex: 1;
    padding: 10px 6px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    border: 2px solid var(--border);
    background: #fff;
    cursor: pointer;
    text-align: center;
    touch-action: manipulation;
    transition: all .15s;
}
.statut-btn.sel-present   { background: var(--ok-bg);     border-color: var(--ok);     color: var(--ok); }
.statut-btn.sel-absent    { background: var(--absent-bg); border-color: var(--absent); color: var(--absent); }
.statut-btn.sel-endommage { background: var(--dmg-bg);    border-color: var(--dmg);    color: var(--dmg); }

/* Détails (commentaire / qte) */
.item-details {
    display: none;
    padding: 0 16px 14px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}
.item-details.visible { display: block; }
.item-details .form-group { margin-bottom: 10px; }

/* ── Recap ── */
.recap-section { margin-bottom: 20px; }
.recap-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }
.recap-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 6px;
    font-size: 14px;
}
.recap-item.absent    { background: var(--absent-bg); color: #991b1b; }
.recap-item.endommage { background: var(--dmg-bg);    color: #92400e; }
.recap-ok {
    text-align: center;
    padding: 24px;
    color: var(--ok);
    font-size: 15px;
    font-weight: 600;
}
.recap-ok .ok-icon { font-size: 40px; display: block; margin-bottom: 8px; }

/* ── Stepper quantité (inspiré /store) ── */
.qty-stepper {
    display: inline-flex;
    align-items: center;
    gap: 0;
    background: #f3f4f6;
    border-radius: 50px;
    padding: 4px;
}
.stepper-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #fff;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    transition: transform .1s, background .15s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.stepper-btn:active   { transform: scale(.88); background: #e5e7eb; }
.stepper-btn:disabled { opacity: .35; cursor: not-allowed; }
.stepper-val {
    min-width: 44px;
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}
.stepper-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0 10px;
}
.stepper-label {
    font-size: 13px;
    color: var(--muted);
}

/* ── Note de propreté (étoiles) ── */
.rating-stars {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}
.rating-stars .star {
    flex: 1;
    background: #fafafa;
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 12px 0;
    font-size: 30px;
    line-height: 1;
    color: #d1d5db;
    cursor: pointer;
    transition: all .15s;
    -webkit-tap-highlight-color: transparent;
}
.rating-stars .star:hover { border-color: var(--dmg); }
.rating-stars .star.on {
    color: var(--dmg);
    border-color: var(--dmg);
    background: var(--dmg-bg);
}

/* ── Signature ── */
#signature-canvas {
    display: block;
    width: 100%;
    height: 200px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: #fafafa;
    cursor: crosshair;
    touch-action: none;
}
#signature-canvas.signed { border-color: var(--primary); }
.sig-hint { font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px; }

/* ── Loading ── */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--primary-l);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ── */
.app-footer { text-align: center; padding: 14px; color: rgba(255,255,255,.5); font-size: 11px; }

/* ── Scanner QR Code ── */
#screen-scan {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.scanner-area {
    flex: 1;
    position: relative;
    background: #0d1117;
    overflow: hidden;
    min-height: 0;
}
#qr-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
#qr-canvas { display: none; }

.scanner-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.scanner-frame {
    width: 220px;
    height: 220px;
    position: relative;
    box-shadow: 0 0 0 9999px rgba(0,0,0,.5);
    border-radius: 4px;
}
.corner {
    position: absolute;
    width: 28px;
    height: 28px;
    border-color: var(--primary);
    border-style: solid;
    border-width: 0;
}
.corner.tl { top: -2px;    left: -2px;    border-top-width: 4px;    border-left-width: 4px;    border-top-left-radius: 4px; }
.corner.tr { top: -2px;    right: -2px;   border-top-width: 4px;    border-right-width: 4px;   border-top-right-radius: 4px; }
.corner.bl { bottom: -2px; left: -2px;    border-bottom-width: 4px; border-left-width: 4px;    border-bottom-left-radius: 4px; }
.corner.br { bottom: -2px; right: -2px;   border-bottom-width: 4px; border-right-width: 4px;   border-bottom-right-radius: 4px; }
.scan-line {
    position: absolute;
    left: 4px; right: 4px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: scan-move 2s linear infinite;
    border-radius: 2px;
}
@keyframes scan-move {
    0%   { top: 4px;   opacity: 1; }
    90%  { opacity: 1; }
    100% { top: calc(100% - 6px); opacity: 0; }
}

.scanner-prompt {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0d1117;
    gap: 14px;
    padding: 32px 24px;
    text-align: center;
}
.scanner-prompt-icon { font-size: 52px; }
.scanner-prompt p    { font-size: 15px; color: rgba(255,255,255,.7); line-height: 1.5; }
.scanner-prompt .btn-main { max-width: 260px; }

.scanner-footer {
    flex-shrink: 0;
    padding: 14px 20px 20px;
    background: var(--card);
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}
.scan-hint {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

/* ── Responsive : carte centrée sur desktop ── */
@media (min-width: 520px) {
    body {
        background: linear-gradient(160deg, #0f766e 0%, #0e7490 100%);
        height: auto;
        overflow: visible;
        padding: 24px 16px;
        align-items: flex-start;
        justify-content: center;
        flex-direction: column;
    }
    .card {
        border-radius: 20px;
        box-shadow: 0 20px 60px rgba(0,0,0,.25);
        max-width: 500px;
        width: 100%;
        flex: none;
        height: auto;
        margin: 0 auto;
    }
    #screen-items {
        display: block;
        overflow: visible;
        padding: 24px 20px;
        min-height: unset;
        flex: unset;
    }
    #screen-recap,
    #screen-signature {
        flex: unset;
        overflow-y: visible;
        min-height: unset;
    }
    #items-container {
        overflow: visible;
        padding: 0;
        flex: unset;
        min-height: unset;
    }
    .cat-tabs {
        padding: 0 0 14px;
        border-bottom: none;
        margin-bottom: 16px;
    }
    .nav-cats {
        padding: 20px 0 0;
        border-top: none;
    }
    .app-footer { color: rgba(255,255,255,.5); }
}
