/* ============================================================
   App PWA Ponto - estilos compartilhados (kiosk + live + enroll).
   Paleta: turquesa SeuSaude #006666 / #004d4d / #0e7490.
   ============================================================ */
:root {
    --primary:        #006666;
    --primary-dark:   #004d4d;
    --primary-light:  #0e7490;
    --success:        #10b981;
    --warning:        #f59e0b;
    --danger:         #ef4444;
    --info:           #3b82f6;
    --muted:          #6b7280;
    --bg:             #f7fafa;
    --bg-card:        #ffffff;
    --border:         #e5e7eb;
    --text:           #111827;
    --text-light:     #6b7280;
    --radius:         10px;
    --radius-lg:      16px;
    --shadow:         0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg:      0 12px 32px rgba(0,0,0,0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 12px 20px; font-family: inherit; font-size: 15px; font-weight: 600;
    border: 1px solid transparent; border-radius: var(--radius);
    cursor: pointer; text-decoration: none; line-height: 1.2;
    transition: background .15s, border-color .15s, color .15s, transform .05s;
    min-height: 44px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-light); border-color: transparent; }
.btn-ghost:hover { color: var(--text); }
.btn-link { background: transparent; color: var(--primary-light); padding: 6px 8px; border: none; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }
.btn-block { display: flex; width: 100%; }
.btn-huge { font-size: 18px; padding: 22px 24px; min-height: 64px; width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 36px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- WELCOME (page-welcome) ---------- */
.page-welcome { background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 55%, var(--primary-light) 100%); }
.welcome { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.welcome-card { background: #fff; border-radius: var(--radius-lg); padding: 36px 28px; max-width: 380px; width: 100%; box-shadow: var(--shadow-lg); text-align: center; }
.welcome-logo img { height: 44px; max-width: 75%; }
.welcome-card h1 { font-size: 22px; font-weight: 800; margin: 18px 0 4px; }
.welcome-sub { color: var(--text-light); font-size: 14px; margin-bottom: 22px; }
.welcome-card .btn { margin-bottom: 10px; }
.welcome-meta { margin-top: 18px; color: var(--text-light); font-size: 12px; }

/* ---------- KIOSK (page-kiosk) ---------- */
.page-kiosk { background: #000; color: #fff; overflow: hidden; touch-action: manipulation; }
.kiosk { display: grid; grid-template-rows: auto 1fr auto; height: 100vh; height: 100dvh; }
.page-kiosk input, .page-kiosk select, .page-kiosk textarea, .page-kiosk button { font-size: 16px; touch-action: manipulation; }
.kiosk-header {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 18px; background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.kiosk-logo { height: 28px; filter: brightness(0) invert(1); }
.kiosk-empresa { font-weight: 700; font-size: 14px; flex: 1; }
.kiosk-clock { font-family: 'Roboto Mono', ui-monospace, monospace; font-weight: 700; font-size: 18px; color: #86efac; }
.kiosk-stage {
    position: relative;
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background: #000;
}
.kiosk-stage video {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; transform: scaleX(-1); /* mirror */
    z-index: 1;
}
.kiosk-overlay {
    position: absolute; inset: 0; z-index: 2;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 24px;
    background: linear-gradient(180deg, rgba(0,0,0,0.0) 0%, rgba(0,0,0,0.0) 50%, rgba(0,0,0,0.6) 100%);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.kiosk-frame {
    width: 260px; height: 320px; max-width: 60vw; max-height: 50vh;
    border: 3px solid rgba(255,255,255,0.65);
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
    animation: pulseFrame 2.4s ease-in-out infinite;
}
@keyframes pulseFrame {
    0%,100% { transform: scale(1); border-color: rgba(255,255,255,0.65); }
    50%     { transform: scale(1.02); border-color: rgba(134,239,172,0.85); }
}
.kiosk-msg { margin-top: 28px; font-size: 16px; font-weight: 600; text-align: center; }
.kiosk-recognize { background: rgba(0,0,0,0.6); }
.kiosk-confirm { background: rgba(0,0,0,0.78); justify-content: flex-start; padding-top: 36px; gap: 16px; }
.kiosk-colab { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.kiosk-avatar {
    width: 88px; height: 88px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; font-size: 38px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 20px rgba(0,102,102,0.5);
}
.kiosk-nome { font-size: 20px; font-weight: 700; }
.kiosk-cargo { color: rgba(255,255,255,0.7); font-size: 13px; }
.kiosk-batidas { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.kiosk-batidas li {
    padding: 6px 12px; border-radius: 999px;
    background: rgba(255,255,255,0.12); font-size: 12px; font-weight: 500;
}
.kiosk-confirm .btn-huge { background: #10b981; }
.kiosk-confirm .btn-huge:hover { background: #059669; }
.kiosk-success { background: rgba(16,185,129,0.18); justify-content: center; gap: 14px; }
.kiosk-check {
    width: 96px; height: 96px; border-radius: 50%;
    background: #10b981; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 56px; font-weight: 900;
    box-shadow: 0 10px 30px rgba(16,185,129,0.5);
    animation: checkPop .35s ease-out;
}
@keyframes checkPop { 0% { transform: scale(0.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.kiosk-greet { font-size: 24px; font-weight: 800; text-align: center; }
.kiosk-detail { font-size: 16px; text-align: center; color: rgba(255,255,255,0.85); }
.kiosk-back { font-size: 13px; color: rgba(255,255,255,0.6); margin-top: 8px; }
.kiosk-error { background: rgba(239,68,68,0.22); justify-content: center; gap: 14px; }
.kiosk-error-icon {
    width: 80px; height: 80px; border-radius: 50%;
    background: var(--danger); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 44px; font-weight: 900;
}
.kiosk-footer {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 18px; background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 12px;
}
.kiosk-status { flex: 1; color: rgba(255,255,255,0.7); }
.kiosk-admin-actions { display: inline; }
.kiosk-footer .btn-link { color: rgba(255,255,255,0.85); }

/* ---------- LIVE (page-live) mobile-first ---------- */
.page-live { background: var(--bg); touch-action: manipulation; }
.page-live input, .page-live select, .page-live textarea, .page-live button { font-size: 16px; touch-action: manipulation; }
.live { max-width: 1200px; margin: 0 auto; padding: 12px; padding-bottom: 64px; }
@media (min-width: 720px) { .live { padding: 18px; } }

/* Header: empilha em mobile, 1 linha em desktop */
.live-header { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
@media (min-width: 720px) { .live-header { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; } }
.live-title { display: flex; gap: 10px; align-items: center; min-width: 0; }
.live-logo { height: 32px; flex-shrink: 0; }
.live-title h1 { font-size: 18px; font-weight: 800; color: var(--primary-dark); line-height: 1.1; }
@media (min-width: 720px) { .live-title h1 { font-size: 22px; } }
.live-date { font-size: 12px; color: var(--text-light); }
.live-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--success); margin: 0 6px; animation: livePulse 1.6s infinite; vertical-align: middle; }
@keyframes livePulse { 0%,100%{ opacity: 1; transform: scale(1);} 50%{ opacity: 0.45; transform: scale(1.4);} }

/* Nav: scroll horizontal em mobile, sem quebra */
.live-nav { display: flex; align-items: center; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.live-nav::-webkit-scrollbar { height: 0; display: none; }
.live-nav > * { flex-shrink: 0; }
.live-nav .btn { white-space: nowrap; }
.live-nav form.inline { display: flex; gap: 6px; align-items: center; }
.input-inline { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 14px; min-width: 0; max-width: 160px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.chip-kiosk::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #86efac; }

/* KPIs: 2 colunas em <360, 3 em <720, 6 em desktop. Touch-friendly. */
.live-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
@media (max-width: 360px) { .live-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 720px) { .live-kpis { grid-template-columns: repeat(6, 1fr); gap: 10px; } }
.kpi { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 8px; box-shadow: var(--shadow); text-align: center; }
@media (min-width: 720px) { .kpi { padding: 14px; } }
.kpi-num { font-size: 22px; font-weight: 800; color: var(--primary-dark); font-variant-numeric: tabular-nums; line-height: 1.1; }
@media (min-width: 720px) { .kpi-num { font-size: 28px; } }
.kpi-label { font-size: 10px; color: var(--text-light); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-top: 4px; }

/* Cards empilhados em mobile, 3 colunas em desktop largo */
.live-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 1024px) { .live-grid { grid-template-columns: 1fr 1.4fr 1fr; } }
.live-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
@media (min-width: 720px) { .live-card { padding: 16px; } }
.live-card h2 { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .04em; }

/* Listas: max-height escalonado, scroll suave touch */
.live-list { list-style: none; max-height: 320px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
@media (min-width: 720px) { .live-list { max-height: 480px; } }
.live-list li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; gap: 10px; align-items: center; }
.live-list li:last-child { border-bottom: 0; }
.live-list .muted { color: var(--text-light); justify-content: center; padding: 18px 0; }

/* Row do colab: avatar + info que trunca + badge fixo. Nada quebra layout. */
.live-list .colab-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; }
/* Alertas nao tem avatar: nome/mensagem a esquerda, badge (Ausente/Atraso) a
   direita. Sem isto o badge caia na coluna de 32px do avatar e transbordava,
   empurrando o nome para cima do badge. */
.live-list .colab-row.alert-row { grid-template-columns: minmax(0, 1fr) auto; }
.live-list .colab-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.live-list .colab-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.live-list .colab-info b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-list .colab-info small { color: var(--text-light); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-list .badge { padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; flex-shrink: 0; }
.badge-presente { background: #d1fae5; color: #047857; }
.badge-almoco { background: #fef3c7; color: #92400e; }
.badge-saiu { background: #e5e7eb; color: #374151; }
.badge-atraso { background: #fee2e2; color: #b91c1c; }
.badge-ausente { background: #fef2f2; color: #b91c1c; }
.tipo-entrada { color: var(--success); }
.tipo-saida { color: var(--danger); }
.tipo-almoco_saida, .tipo-almoco_retorno { color: var(--warning); }

/* Footer fixo discreto */
.live-footer { position: fixed; bottom: 0; left: 0; right: 0; padding: 8px 14px; background: rgba(255,255,255,0.96); border-top: 1px solid var(--border); display: flex; gap: 10px; font-size: 11px; color: var(--text-light); justify-content: center; align-items: center; backdrop-filter: blur(8px); }
@media (min-width: 720px) { .live-footer { font-size: 12px; padding: 10px 16px; } }
.live-sep { width: 1px; height: 12px; background: var(--border); }
@media (max-width: 380px) { .live-footer .live-sep { display: none; } .live-footer { gap: 6px; flex-wrap: wrap; } }

/* ---------- ENROLL (page-enroll) ---------- */
.page-enroll { background: #fff; }
.enroll { max-width: 540px; margin: 0 auto; padding: 18px 16px 80px; }
.enroll-back { color: var(--primary); text-decoration: none; font-size: 14px; font-weight: 600; display: inline-block; margin-bottom: 8px; }
.enroll-header h1 { font-size: 22px; font-weight: 800; color: var(--primary-dark); margin-bottom: 4px; }
.enroll-sub { font-size: 13px; color: var(--text-light); margin-bottom: 18px; }
.enroll-pick { background: var(--bg); padding: 12px; border-radius: var(--radius); margin-bottom: 14px; }
.enroll-pick label { font-size: 12px; font-weight: 600; display: block; margin-bottom: 4px; color: var(--text); }
.enroll-pick select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 14px; background: #fff; }
.enroll-nome { font-size: 14px; margin-bottom: 12px; }
.enroll-video-wrap { position: relative; border-radius: var(--radius-lg); overflow: hidden; aspect-ratio: 3/4; background: #000; box-shadow: var(--shadow); }
.enroll-video-wrap video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.enroll-frame {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: 200px; height: 260px;
    border: 3px solid rgba(134,239,172,0.85); border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.35);
    pointer-events: none;
}
.enroll-samples { display: flex; gap: 8px; justify-content: center; margin: 14px 0; }
.enroll-sample {
    width: 56px; height: 56px; border-radius: 12px;
    border: 2px dashed var(--border);
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: var(--text-light);
    overflow: hidden;
}
.enroll-sample.done { border-style: solid; border-color: var(--success); background: #d1fae5; color: var(--success); }
.enroll-sample.done span { display: none; }
.enroll-sample.done::after { content: '\2713'; font-size: 26px; font-weight: 900; color: var(--success); }
.enroll-hint { font-size: 13px; color: var(--text-light); text-align: center; margin: 8px 0 16px; }
.enroll-actions { display: flex; flex-direction: column; gap: 8px; }
.enroll-msg { margin-top: 12px; padding: 10px 14px; border-radius: 8px; font-size: 13px; display: none; }
.enroll-msg.success { background: #d1fae5; color: #047857; display: block; }
.enroll-msg.error { background: #fee2e2; color: #b91c1c; display: block; }
.muted { color: var(--text-light); }

/* ---------- SPINNER ---------- */
.spinner {
    width: 48px; height: 48px;
    border: 4px solid rgba(255,255,255,0.18);
    border-top-color: #86efac;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- iOS safe area ---------- */
@supports (padding: env(safe-area-inset-top)) {
    .kiosk-header { padding-top: max(14px, env(safe-area-inset-top)); }
    .kiosk-footer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    .live-footer { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}
