/* ============================================================
   Advanced GPS Attendance – Frontend Styles v6.1
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

.agfa-container {
    --blue:    #3b82f6;
    --indigo:  #6366f1;
    --green:   #22c55e;
    --red:     #ef4444;
    --amber:   #f59e0b;
    --gray-50: #f8fafc;
    --gray-100:#f1f5f9;
    --gray-200:#e2e8f0;
    --gray-500:#64748b;
    --gray-700:#334155;
    --gray-900:#0f172a;
    --radius:  14px;
    --shadow:  0 2px 12px rgba(0,0,0,.08);

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 16px;
    color: var(--gray-700);
}

/* ── Header ── */
.agfa-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    padding: 20px 22px;
    background: linear-gradient(135deg, var(--blue) 0%, var(--indigo) 100%);
    border-radius: var(--radius);
    color: #fff;
}
.agfa-logo svg { width: 44px; height: 44px; flex-shrink: 0; }
.agfa-header-text h2 { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.agfa-header-text p  { margin: 0; font-size: 13px; opacity: .85; }

/* ── Generic card ── */
.agfa-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 16px;
    border: 1px solid var(--gray-200);
}

/* ── Status row ── */
.agfa-status-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}
.agfa-card-icon { font-size: 26px; margin-bottom: 8px; }
.agfa-card-title { display: block; font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); margin-bottom: 6px; }
.agfa-card-meta { font-size: 11px; color: var(--gray-500); margin-top: 8px; line-height: 1.5; }

/* ── Badges ── */
.agfa-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
}
.agfa-badge--info    { background: #dbeafe; color: #1d4ed8; }
.agfa-badge--success { background: #dcfce7; color: #15803d; }
.agfa-badge--error   { background: #fee2e2; color: #b91c1c; }
.agfa-badge--warning { background: #fef9c3; color: #92400e; }

/* ── Camera section ──
   NOTE: NO overflow:hidden here — it clips the buttons below on some themes */
.agfa-camera-section {
    background: var(--gray-900);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 16px;
}

/* Camera wrapper has its own overflow:hidden to clip the video/overlays */
.agfa-camera-wrapper {
    position: relative;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;       /* clip video + overlays only, not buttons */
    background: #000;
    aspect-ratio: 4/3;
    margin-bottom: 14px;
}
.agfa-camera-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* NO scaleX(-1) here — mirroring is done in JS canvas capture only,
       so the live preview matches what gets saved */
    display: block;
}

#faceOverlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}
.agfa-detection-overlay {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    background: rgba(0,0,0,.72);
    color: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    z-index: 10;
    backdrop-filter: blur(4px);
    pointer-events: none;
}
.agfa-detection-icon { font-size: 14px; }

/* Scanning animation */
.agfa-scan-line {
    position: absolute;
    left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--green), transparent);
    animation: agfa-scan 2s ease-in-out infinite;
    pointer-events: none;
    z-index: 9;
}
@keyframes agfa-scan {
    0%   { top: 10%; opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { top: 90%; opacity: 0; }
}

/* ── Controls ── */
.agfa-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    padding-top: 4px;      /* breathing room between wrapper and buttons */
    position: relative;    /* ensure buttons are above any stacking context */
    z-index: 1;
}

/* ── Buttons ── */
.agfa-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform .15s, opacity .15s, box-shadow .15s;
    line-height: 1;
    white-space: nowrap;
    position: relative;
    z-index: 1;             /* ensure clickable above any overlay remnants */
    -webkit-appearance: none;
    appearance: none;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;  /* always clickable */
    touch-action: manipulation; /* fast tap on mobile, no 300ms delay */
}
.agfa-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.agfa-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none !important;
    pointer-events: none;   /* disabled = truly unclickable */
}
.agfa-btn--primary { background: var(--blue);  color: #fff; box-shadow: 0 2px 8px rgba(59,130,246,.35); }
.agfa-btn--primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(59,130,246,.45); }
.agfa-btn--danger  { background: var(--red);   color: #fff; }
.agfa-btn--danger:hover:not(:disabled)  { transform: translateY(-2px); }
.agfa-btn--success { background: var(--green); color: #fff; box-shadow: 0 2px 10px rgba(34,197,94,.4); }
.agfa-btn--success:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 18px rgba(34,197,94,.55); }

/* Mark button pulse — only when enabled */
.agfa-btn--mark:not(:disabled) {
    animation: markPulse 1.8s ease-in-out infinite;
}
@keyframes markPulse {
    0%, 100% { box-shadow: 0 2px 10px rgba(34,197,94,.4); }
    50%       { box-shadow: 0 2px 22px rgba(34,197,94,.85), 0 0 0 6px rgba(34,197,94,.15); }
}

.agfa-btn--ghost { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.agfa-btn--lg    { padding: 12px 28px; font-size: 15px; width: 100%; justify-content: center; }

/* ── Face status text ── */
.agfa-face-status {
    padding: 10px 14px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 13px;
    text-align: center;
    margin: 10px 0;
    min-height: 36px;
}
.agfa-face-status.info    { background: #dbeafe; color: #1d4ed8; }
.agfa-face-status.success { background: #dcfce7; color: #15803d; }
.agfa-face-status.error   { background: #fee2e2; color: #b91c1c; }

/* ── Main status ── */
.agfa-main-status {
    padding: 13px 20px;
    margin: 14px 0;
    border-radius: var(--radius);
    text-align: center;
    font-weight: 600;
    font-size: 15px;
    min-height: 46px;
    transition: all .25s;
}
.agfa-main-status.success { background: linear-gradient(135deg,#22c55e,#16a34a); color:#fff; }
.agfa-main-status.error   { background: linear-gradient(135deg,#ef4444,#dc2626); color:#fff; }
.agfa-main-status.warning { background: #fef9c3; color: #92400e; }
.agfa-main-status.info    { background: #dbeafe; color: #1e40af; }

/* ── Auto status card ── */
.agfa-auto-card { display: flex; align-items: flex-start; gap: 14px; }
.agfa-auto-hints { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.agfa-auto-hints span { font-size: 11px; color: var(--gray-500); background: var(--gray-100);
    padding: 3px 8px; border-radius: 20px; }

/* ── Pills ── */
.agfa-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    margin-right: 6px;
}
.agfa-pill--waiting { background: #fef9c3; color: #92400e; }
.agfa-pill--active  { background: #dcfce7; color: #15803d; }
.agfa-pill--success { background: #dcfce7; color: #15803d; }
.agfa-pill--error   { background: #fee2e2; color: #b91c1c; }
.agfa-pill--off     { background: var(--gray-100); color: var(--gray-500); }

/* ── Info row ── */
.agfa-info-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}
.agfa-today-card h3, .agfa-total-card h3 {
    margin: 0 0 12px;
    font-size: 15px;
    color: var(--gray-700);
}
.agfa-today-status { font-size: 18px; font-weight: 700; color: var(--gray-500); }
.agfa-today-status.success { color: var(--green); }
.agfa-check-time   { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.agfa-total-number { font-size: 52px; font-weight: 800; color: var(--blue); line-height: 1; }
.agfa-total-label  { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ── Instructions ── */
.agfa-instructions {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.agfa-instructions h4 { margin: 0 0 12px; font-size: 14px; color: var(--gray-700); }
.agfa-instructions ol { margin: 0; padding-left: 20px; }
.agfa-instructions li { font-size: 13px; line-height: 1.9; color: var(--gray-500); }

/* ── Spinner ── */
.agfa-spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(0,0,0,.15);
    border-radius: 50%;
    border-top-color: currentColor;
    animation: agfa-spin .8s linear infinite;
    vertical-align: middle;
}
@keyframes agfa-spin { to { transform: rotate(360deg); } }

/* ── Admin registration page ── */
.agfa-reg-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
    align-items: start;
}
.agfa-cam-section   { margin-top: 24px; }
.agfa-cam-section h3 { font-size: 16px; margin: 0 0 12px; }
.agfa-step-hint     { font-size: 12px; font-weight: 400; color: var(--gray-500); }
.agfa-cam-wrapper   {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 14px;
}
.agfa-cam-wrapper video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.agfa-capture-controls  { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.agfa-capture-status    { padding: 9px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; min-height: 38px; }
.agfa-face-preview      { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.agfa-tip               { font-size: 12px; color: var(--gray-500); margin-top: 8px; }

.agfa-form-group        { margin-bottom: 16px; }
.agfa-form-group label  { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.agfa-form-group .required { color: var(--red); }

/* ── Mobile ── */
@media (max-width: 680px) {
    .agfa-container      { padding: 16px 12px; }
    .agfa-status-row     { grid-template-columns: 1fr; }
    .agfa-info-row       { grid-template-columns: 1fr; }
    .agfa-reg-grid       { grid-template-columns: 1fr; }
    .agfa-camera-wrapper { aspect-ratio: 3/4; min-height: 300px; }
    .agfa-total-number   { font-size: 40px; }
    .agfa-controls       { flex-direction: column; align-items: stretch; }
    .agfa-btn            { justify-content: center; width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════
   ID ENTRY PANEL  (guest / no-login attendance)
═══════════════════════════════════════════════════════════════ */
.agfa-id-panel {
    margin-bottom: 20px;
}

.agfa-id-panel-inner {
    background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
    border: 1.5px solid #c7d2fe;
    border-radius: 16px;
    padding: 28px 24px 20px;
    text-align: center;
}

.agfa-id-icon {
    font-size: 40px;
    margin-bottom: 10px;
    line-height: 1;
}

.agfa-id-panel-inner h3 {
    margin: 0 0 6px;
    font-size: 18px;
    color: #1e1b4b;
    font-weight: 700;
}

.agfa-id-desc {
    color: #6b7280;
    font-size: 14px;
    margin: 0 0 20px;
    line-height: 1.5;
}

.agfa-id-input-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.agfa-id-input-row input[type="text"] {
    flex: 1;
    min-width: 180px;
    max-width: 260px;
    padding: 12px 16px;
    border: 2px solid #a5b4fc;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 2px;
    text-align: center;
    color: #1e1b4b;
    background: #fff;
    outline: none;
    transition: border-color .2s;
}

.agfa-id-input-row input[type="text"]:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.agfa-id-input-row button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s, transform .1s;
    white-space: nowrap;
}

.agfa-id-input-row button:hover:not(:disabled) {
    opacity: .9;
    transform: translateY(-1px);
}

.agfa-id-input-row button:disabled {
    opacity: .65;
    cursor: not-allowed;
}

.agfa-id-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    color: #dc2626;
    font-size: 13px;
    padding: 8px 14px;
    margin: 0 auto 10px;
    max-width: 400px;
    text-align: left;
}

/* Confirmed user card */
.agfa-id-confirmed {
    margin: 0 auto 14px;
    max-width: 380px;
}

.agfa-id-confirmed-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 2px solid #22c55e;
    border-radius: 12px;
    padding: 12px 16px;
    text-align: left;
}

.agfa-id-confirmed-inner img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #e2e8f0;
    flex-shrink: 0;
}

.agfa-id-confirmed-icon {
    font-size: 28px;
    width: 48px;
    height: 48px;
    background: #dcfce7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.agfa-id-confirmed-name {
    font-weight: 700;
    font-size: 15px;
    color: #15803d;
}

.agfa-id-confirmed-sub {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.agfa-id-change-btn {
    margin-left: auto;
    padding: 5px 12px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    color: #475569;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s;
}

.agfa-id-change-btn:hover {
    background: #e2e8f0;
}

.agfa-id-login-hint {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 8px;
}

.agfa-id-login-hint a {
    color: #6366f1;
    text-decoration: none;
}

.agfa-id-login-hint a:hover {
    text-decoration: underline;
}

/* Spinner keyframes (used inline in JS too) */
@keyframes spin {
    to { transform: rotate(360deg); }
}
