/* ============================================================
   App do Colaborador — AM Smart
   Tema: light-first (branco/cinza claro, acentos pretos)
   ============================================================ */
:root {
    --white:      #ffffff;
    --bg:         #fafafa;
    --surface:    #ffffff;
    --surface-2:  #f4f4f4;
    --border:     #e5e5e5;
    --border-2:   #d9d9d9;
    --text:       #111111;
    --text-2:     #444444;
    --muted:      #8a8a8a;
    --accent:     #111111;
    --accent-2:   #000000;
    --success:    #127a3b;
    --danger:     #b42318;
    --info:       #1f66d6;
    --shadow:     0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.06);
    --radius:     14px;
    --radius-sm:  10px;
    --h-header:   56px;
    --h-tabbar:   62px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.45;
    -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ──────────── AUTH (login / primeiro acesso) ──────────── */
.auth-body { background: linear-gradient(180deg, #ffffff 0%, #f1f1f1 100%); min-height: 100dvh; }
.auth-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2rem 1.75rem;
    box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 1.75rem; }
.auth-brand img { max-width: 72px; margin-bottom: .5rem; }
.auth-tag { margin: 0; color: var(--muted); font-size: .8rem; font-weight: 500; }
.auth-title { margin: 0 0 .25rem; font-size: 1.55rem; font-weight: 700; }
.auth-subtitle { margin: 0 0 1.5rem; color: var(--muted); font-size: .9rem; }
.auth-foot { margin-top: 1.5rem; text-align: center; font-size: .85rem; color: var(--muted); }
.auth-foot a { font-weight: 600; color: var(--accent); }

/* ──────────── Forms ──────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; margin-bottom: .35rem; font-weight: 600; font-size: .85rem; }
.form-input {
    width: 100%; padding: .85rem 1rem; font: inherit;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color .15s, background .15s;
}
.form-input:focus { outline: 0; border-color: var(--accent); background: var(--white); }
.help-text { display: block; margin-top: .3rem; font-size: .75rem; color: var(--muted); }

/* ──────────── Buttons ──────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .9rem 1.2rem; font: 600 .95rem 'Inter', sans-serif;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    cursor: pointer; transition: transform .05s, background .15s, border-color .15s;
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: var(--accent-2); }
.btn-primary[disabled] { opacity: .5; cursor: not-allowed; }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--border-2); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { display: flex; width: 100%; }
.mt-sm { margin-top: .5rem; }

/* ──────────── Alerts ──────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); font-size: .85rem; margin-bottom: 1rem; border: 1px solid; }
.alert-error   { background: #fdecec; border-color: #f5c6c6; color: var(--danger); }
.alert-success { background: #e8f5ee; border-color: #bfe2cd; color: var(--success); }
.alert-info    { background: #eaf2fd; border-color: #c4d9f7; color: var(--info); }

/* Confirm (primeiro acesso step 2) */
.confirm-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; margin-bottom: 1.25rem; }
.confirm-row { display: flex; justify-content: space-between; padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.confirm-row:last-child { border-bottom: 0; }
.confirm-label { color: var(--muted); font-size: .8rem; }
.confirm-value { font-weight: 600; font-size: .85rem; text-align: right; }

/* Spinner (botão) */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; margin-right: .35rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   APP SHELL (autenticado)
   ============================================================ */
.app-body { padding-top: var(--h-header); padding-bottom: calc(var(--h-tabbar) + env(safe-area-inset-bottom)); background: var(--bg); }
.app-header {
    position: fixed; top: 0; left: 0; right: 0; height: var(--h-header);
    background: var(--white); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1rem; z-index: 20;
}
.app-brand { display: inline-flex; align-items: center; gap: .5rem; color: var(--text); font-weight: 700; }
.app-brand img { width: 28px; height: 28px; }
.app-user { display: flex; align-items: center; gap: .6rem; }
.app-user-name { font-size: .85rem; font-weight: 600; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); border: 1px solid transparent; }
.icon-btn:hover { background: var(--surface-2); text-decoration: none; }

.app-main { padding: 1rem 1rem 2rem; max-width: 560px; margin: 0 auto; }

/* Tab bar fixa */
.app-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: calc(var(--h-tabbar) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--white); border-top: 1px solid var(--border);
    display: flex; justify-content: space-around; align-items: stretch;
    z-index: 20;
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; flex: 1; color: var(--muted); font-size: .7rem; font-weight: 600; }
.tab i { font-size: 1.25rem; }
.tab:hover { text-decoration: none; color: var(--text); }
.tab.active { color: var(--accent); }
.tab-action { color: var(--accent); }
.tab-action i { background: var(--accent); color: var(--white); padding: .4rem; border-radius: 50%; }

/* ──────────── Splash ──────────── */
.app-splash { position: fixed; inset: 0; background: var(--white); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.25rem; z-index: 99; transition: opacity .35s; }
.app-splash.hide { opacity: 0; pointer-events: none; }
.app-splash-logo { width: 120px; }
.app-splash-spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }

/* ──────────── Cards / Home ──────────── */
.hero { padding: .5rem 0 1.25rem; }
.hero-hello { margin: 0; color: var(--muted); font-size: .9rem; }
.hero-name  { margin: .1rem 0 .25rem; font-size: 1.4rem; font-weight: 700; }
.hero-sub   { margin: 0; color: var(--muted); font-size: .8rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.card-title { margin: 0; font-size: 1rem; font-weight: 700; }
.card-meta  { color: var(--muted); font-size: .8rem; }
.empty { margin: .5rem 0; color: var(--muted); font-size: .9rem; }

.timeline { list-style: none; padding: 0; margin: .25rem 0 0; }
.timeline-item { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px dashed var(--border); }
.timeline-item:last-child { border-bottom: 0; }
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; }
.timeline-dot.in  { background: var(--success); }
.timeline-dot.out { background: var(--danger); }
.timeline-time  { font-weight: 700; min-width: 44px; }
.timeline-label { color: var(--text-2); font-size: .9rem; }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.quick { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: .4rem; color: var(--text); box-shadow: var(--shadow); }
.quick:hover { background: var(--surface-2); text-decoration: none; }
.quick i { font-size: 1.5rem; }
.quick span { font-weight: 600; font-size: .9rem; }

/* Perfil */
.profile { text-align: center; padding: 1rem 0 .75rem; }
.profile-avatar { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto .75rem; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 3rem; color: var(--muted); overflow: hidden; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { margin: 0; font-weight: 700; }
.profile-meta { margin: .25rem 0 0; color: var(--muted); font-size: .85rem; }
.info-list { margin: 1rem 0; padding: 0; }
.info-list > div { display: flex; justify-content: space-between; padding: .6rem 0; border-bottom: 1px dashed var(--border); }
.info-list dt { color: var(--muted); font-size: .85rem; margin: 0; }
.info-list dd { margin: 0; font-weight: 600; font-size: .9rem; text-align: right; }

/* Folha mensal */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.month-title { font-size: 1rem; margin: 0; }
.day-list { list-style: none; padding: 0; margin: 0; }
.day-item { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.day-item:last-child { border-bottom: 0; }
.day-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .35rem; }
.day-num { font-weight: 700; font-size: 1.1rem; margin-right: .5rem; }
.day-name { color: var(--muted); font-size: .8rem; text-transform: uppercase; }
.day-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.day-marks { display: flex; flex-wrap: wrap; gap: .4rem; }
.mark { display: inline-flex; align-items: center; gap: .25rem; padding: .25rem .5rem; border-radius: 99px; font-size: .8rem; font-weight: 600; border: 1px solid var(--border); background: var(--surface-2); }
.mark-entrada { color: var(--success); }
.mark-saida   { color: var(--danger); }

/* ──────────── Face / Câmera ──────────── */
.face-stage { padding: .5rem 0 1rem; }
.face-header { text-align: center; margin-bottom: 1rem; }
.face-header h2 { margin: 0 0 .4rem; font-size: 1.2rem; }
.face-status { margin: 0; color: var(--text-2); font-size: .9rem; min-height: 1.4em; }
.camera-wrap {
    position: relative; width: 100%; max-width: 420px; aspect-ratio: 4 / 3;
    margin: 0 auto 1rem; border-radius: var(--radius); overflow: hidden;
    background: #000;
    box-shadow: var(--shadow);
}
.camera-wrap video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.face-outline {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 65%; aspect-ratio: 3/4; border: 3px dashed rgba(255,255,255,.7); border-radius: 50% / 40%;
    pointer-events: none;
}
.face-actions { display: flex; flex-direction: column; gap: .5rem; max-width: 420px; margin: 0 auto; }

/* Receipt */
.receipt { max-width: 420px; margin: 1rem auto; padding: 1.5rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-align: center; box-shadow: var(--shadow); }
.receipt-icon { font-size: 3rem; }
.receipt-icon.ok { color: var(--success); }
.receipt-icon.error { color: var(--danger); }
.receipt h2 { margin: .5rem 0 1rem; }
.receipt-list { text-align: left; margin: 0 0 1.25rem; padding: 0; }
.receipt-list > div { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem 0; border-bottom: 1px dashed var(--border); }
.receipt-list dt { color: var(--muted); font-size: .8rem; margin: 0; }
.receipt-list dd { margin: 0; font-weight: 600; font-size: .85rem; text-align: right; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .7rem; }

/* ──────────── Mark row (folha com download) ──────────── */
.mark-row { display: flex; align-items: center; gap: .4rem; margin-bottom: .3rem; }
.mark-row .mark { flex: 0 0 auto; }
.mark small { margin-left: .15rem; font-weight: 500; }
.mark-local { font-size: .7rem; color: var(--muted); border: 1px solid var(--border); border-radius: 99px; padding: .15rem .45rem; }
.mark-download { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--text-2); margin-left: auto; }
.mark-download:hover { background: var(--surface-2); text-decoration: none; color: var(--accent); }

/* ──────────── Justificativas ──────────── */
.just-list { list-style: none; padding: 0; margin: 0; }
.just-item { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.just-item:last-child { border-bottom: 0; }
.just-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
.just-date { font-weight: 700; font-size: .95rem; }
.just-motivo { margin: .15rem 0; font-weight: 600; font-size: .9rem; }
.just-desc { margin: .1rem 0; font-size: .82rem; color: var(--text-2); }
.just-attach { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; color: var(--muted); margin-top: .25rem; }
.just-obs { margin: .4rem 0 0; font-size: .82rem; color: var(--danger); background: #fdecec; border-radius: 6px; padding: .4rem .6rem; }

.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: .2rem .55rem; border-radius: 99px; text-transform: uppercase; letter-spacing: .3px; }
.badge-pendente  { background: #fef3cd; color: #856404; }
.badge-aprovada  { background: #d4edda; color: #155724; }
.badge-rejeitada { background: #f8d7da; color: #721c24; }

.btn-sm { padding: .5rem .9rem; font-size: .82rem; }

/* ──────────── iOS install hint ──────────── */
.ios-hint { position: fixed; bottom: -120px; left: 0; right: 0; z-index: 998; transition: bottom .3s ease; }
.ios-hint.show { bottom: calc(var(--h-tabbar) + 8px + env(safe-area-inset-bottom)); }
.ios-hint-inner { max-width: 480px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; box-shadow: var(--shadow); display: flex; align-items: center; gap: .5rem; font-size: .82rem; }
.ios-hint-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); padding: .25rem; }

/* Responsivo */
@media (max-width: 380px) {
    .auth-card { padding: 1.5rem 1.25rem; }
    .quick-grid { grid-template-columns: 1fr; }
}
