/* ============================
   RESET & BASE
   ============================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', sans-serif;
    background: #e5e5e5;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}
#app {
    width: 100%;
    max-width: 430px;
    height: 100vh;
    height: 100dvh;
    background: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0,0,0,0.15);
}
.screen {
    position: absolute;
    inset: 0;
    display: none;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
}
.screen.active { display: block; }

/* ============================
   SCREEN 1 — ĐĂNG NHẬP (ảnh)
   ============================ */
#screen1,
.s1-img-screen {
    background: #fff;
    overflow: hidden !important;
    flex-direction: column;
}
#screen1.active,
.s1-img-screen.active {
    display: flex !important;
}

.s1-img-wrap {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}
.s1-full-img {
    width: 100%;
    display: block;
}
/* Vùng click trong suốt chính xác lên nút "Đăng nhập bằng Face ID"
   Nút nằm tại ~56% đến ~67% chiều cao ảnh, full width để dễ bấm */
.s1-faceid-zone {
    position: absolute;
    top: 56%;
    left: 0;
    right: 0;
    height: 11%;
    background: transparent;
    cursor: pointer;
    z-index: 10;
    /* Bỏ comment dòng dưới để debug vị trí */
    /* background: rgba(255,0,0,0.2); */
}


/* ============================
   SCREEN 2 — TRANG CHỦ (ảnh)
   ============================ */
#screen2,
.s2-img-screen {
    background: #fff;
    overflow: hidden !important; /* override .screen overflow-y:auto */
    flex-direction: column;
}
#screen2.active,
.s2-img-screen.active {
    display: flex !important;
}

.s2-img-wrap {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.s2-full-img {
    width: 100%;
    display: block;
}
/* Nav nằm trong flex flow (không absolute) để ghim đúng đáy màn hình */
.s2-nav-relative {
    position: relative !important; /* override bottom-nav position:absolute */
    flex-shrink: 0;
}


.s2-header {
    background: linear-gradient(160deg, #8b0000 0%, #c62828 60%, #d32f2f 100%);
    padding: 48px 18px 18px;
    position: relative;
    overflow: hidden;
}
.s2-header::before {
    content: '';
    position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 5L55 50H5L30 5z' stroke='rgba(255,255,255,0.06)' stroke-width='1' fill='none'/%3E%3C/svg%3E") repeat;
    pointer-events: none;
}

.s2-hero {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 16px; position: relative; z-index: 1;
}
.s2-avatar-wrap {
    width: 52px; height: 52px;
    border-radius: 50%;
    border: 2.5px solid rgba(255,255,255,0.8);
    overflow: hidden; flex-shrink: 0;
}
.s2-avatar { width: 100%; height: 100%; object-fit: cover; }
.s2-user-center { flex: 1; }
.s2-level {
    background: rgba(255,255,255,0.95);
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 700; color: #333;
    margin-bottom: 5px;
}
.s2-name { color: #fff; font-size: 18px; font-weight: 800; letter-spacing: 0.5px; }
.s2-search {
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    color: #fff; font-size: 16px; cursor: pointer;
}

.s2-qr-row {
    display: flex; gap: 12px; position: relative; z-index: 1;
}
.s2-qr-card {
    flex: 1;
    background: linear-gradient(135deg, #fdf5d0, #f0d878);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex; align-items: center; gap: 10px;
}
.s2-qr-icon { width: 28px; height: 28px; object-fit: contain; }
.s2-qr-label { font-size: 11px; color: #666; font-weight: 500; }
.s2-qr-sub { font-size: 13px; font-weight: 700; color: #333; }

.s2-body { padding: 18px 18px 20px; }
.s2-section-title { font-size: 15px; font-weight: 700; color: #222; margin-bottom: 14px; }

.s2-services {
    display: flex; gap: 8px;
    margin-bottom: 18px;
    overflow-x: auto; padding-bottom: 4px;
}
.s2-services::-webkit-scrollbar { display: none; }
.s2-svc { text-align: center; min-width: 64px; }
.s2-svc-icon {
    width: 60px; height: 60px;
    background: #c62828;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-size: 24px; color: #fff;
    margin: 0 auto 7px;
    position: relative;
}
.badge-new {
    position: absolute;
    top: -5px; right: -4px;
    background: #c62828; color: #fff;
    font-size: 9px; font-weight: 700;
    padding: 2px 5px; border-radius: 10px;
    border: 1.5px solid #fff;
}
.s2-svc-name { font-size: 11px; color: #444; line-height: 1.3; font-weight: 500; }

.s2-org-banner {
    background: #c62828;
    border-radius: 10px;
    padding: 14px 16px;
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 16px;
}
.s2-org-text { flex: 1; color: #fff; }
.s2-org-title { font-size: 15px; font-weight: 700; }
.s2-org-sub { font-size: 11px; opacity: 0.85; margin-top: 2px; }

.s2-bca-banner {
    background: linear-gradient(135deg, #fff8dc, #fde8a0);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    margin-bottom: 20px;
    border: 1px solid #f5c842;
}
.s2-bca-logo { width: 50px; margin-bottom: 8px; }
.s2-bca-title { font-size: 12px; font-weight: 600; color: #333; }
.s2-bca-name { font-size: 18px; font-weight: 800; color: #c62828; margin-bottom: 5px; }
.s2-bca-links { font-size: 10px; color: #777; margin-bottom: 10px; }
.s2-bca-btn {
    border: 1.5px solid #c62828; color: #c62828;
    display: inline-block; padding: 6px 12px;
    font-size: 10px; font-weight: 700;
    border-radius: 20px; cursor: pointer;
}

.s2-fav-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px;
}
.s2-edit { font-size: 13px; font-weight: 600; color: #c62828; cursor: pointer; }
.s2-fav-items { display: flex; gap: 15px; }
.s2-fav-icon {
    width: 60px; height: 60px;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-size: 26px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.fav1 { background: linear-gradient(135deg, #fff3cd, #ffc107); color: #8B6914; border-bottom: 3px solid #e6a800; }
.fav2 { background: linear-gradient(135deg, #d4edda, #28a745); color: #fff; border-bottom: 3px solid #1e7e34; }
.fav3 { background: linear-gradient(135deg, #f8d7da, #dc3545); color: #fff; border-bottom: 3px solid #bd2130; }

/* ============================
   BOTTOM NAV (shared)
   ============================ */
.bottom-nav {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    display: flex;
    border-top: 1px solid #eee;
    padding: 8px 0 20px;
    z-index: 50;
}
.nav-item {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-end;
    font-size: 10px; color: #999;
    cursor: pointer; gap: 3px;
    padding-top: 5px;
}
.nav-item i { font-size: 22px; }
.nav-item span { font-size: 10px; }
.nav-item.active { color: #c62828; }
.nav-item.active i { color: #c62828; }
.nav-scan { position: relative; }
.scan-circle {
    width: 54px; height: 54px;
    background: #c62828;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    position: absolute;
    bottom: 5px; left: 50%; transform: translateX(-50%);
    box-shadow: 0 4px 14px rgba(198,40,40,0.45);
    color: #fff; font-size: 24px;
}

/* ============================
   ID CARD SHARED STYLES
   ============================ */
.card-header-row {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 6px;
}
.card-flag { width: 30px; height: 22px; object-fit: cover; border-radius: 2px; flex-shrink: 0; }
.card-header-text {
    font-size: 8px; font-weight: 700;
    color: #003366; line-height: 1.4; text-align: center; flex: 1;
}
.card-title {
    text-align: center; color: #c62828;
    font-weight: 800; font-size: 14px;
    margin-bottom: 10px; letter-spacing: 0.5px;
}
.card-info-row { display: flex; gap: 10px; }
.card-photo {
    width: 75px; height: 100px;
    object-fit: cover;
    border-radius: 4px; flex-shrink: 0;
}
.card-fields { flex: 1; }
.cf-label { font-size: 7.5px; color: #444; line-height: 1.3; margin-bottom: 1px; }
.cf-val { font-size: 11px; font-weight: 800; color: #111; margin-bottom: 5px; }
.cf-sex { float: right; font-size: 7.5px; font-weight: 400; color: #444; }
.cf-sex-full { float: right; font-size: 9px; }

/* ============================
   SCREEN 3 — VÍ GIẤY TỜ
   ============================ */
#screen3 { background: #f0ece2; padding-bottom: 72px; }
.s3-body { padding: 48px 18px 20px; }
.s3-title { font-size: 20px; font-weight: 700; color: #111; margin-bottom: 16px; }

.s3-card {
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    margin-bottom: 14px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.12);
}
.s3-card-img {
    width: 100%;
    border-radius: 12px;
    display: block;
    margin-bottom: 14px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.12);
}
.card-bg-img { position: absolute; inset: 0; }
.card-bg { width: 100%; height: 100%; object-fit: cover; }
.card-content {
    position: relative; z-index: 2;
    padding: 14px 14px 16px;
    background: rgba(255,255,255,0.08);
}

.btn-detail {
    display: flex; align-items: center; gap: 8px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 25px;
    padding: 10px 24px;
    font-size: 14px; font-weight: 600; color: #333;
    cursor: pointer;
    margin: 0 auto 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.s3-account-level {
    background: #fff;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 18px;
}
.s3-level-title { display: flex; align-items: center; gap: 7px; font-size: 15px; margin-bottom: 5px; }
.s3-level-desc { font-size: 13px; color: #555; }

.s3-section-title { font-size: 15px; font-weight: 700; color: #222; margin-bottom: 12px; }
.s3-int-cards { display: flex; gap: 14px; margin-bottom: 12px; }
.s3-int-card {
    flex: 1; background: #fff;
    border-radius: 12px; padding: 20px 10px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.s3-int-img { margin-bottom: 10px; }
.s3-int-label { font-size: 13px; font-weight: 600; color: #333; }
.s3-waiting {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: #333;
}
.s3-waiting strong { color: #c62828; }

/* ============================
   SCREEN 4 — PASSCODE
   ============================ */
#screen4 { background: transparent; }
.s4-bg-section {
    position: absolute;
    inset: 0;
    background: #f0ece2;
}
.s4-bg-title {
    position: absolute; top: 48px; left: 18px;
    font-size: 20px; font-weight: 700; color: #111; z-index: 1;
}
.s4-card-img {
    position: absolute;
    top: 90px; left: 18px; right: 18px;
    width: calc(100% - 36px);
    border-radius: 12px;
    display: block;
    box-shadow: 0 4px 18px rgba(0,0,0,0.12);
    z-index: 1;
}
.s4-dim {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 5;
}

.s4-sheet {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top-left-radius: 22px;
    border-top-right-radius: 22px;
    z-index: 10;
    padding: 22px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.15);
}
.s4-sheet-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 22px; margin-bottom: 26px;
}
.s4-sheet-title { font-size: 18px; font-weight: 700; color: #111; }
.s4-close {
    background: #eee; border: none;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 16px; color: #555;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}

.s4-dots {
    display: flex; justify-content: center; gap: 18px;
    margin-bottom: 18px;
}
.dot {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #e0e0e0;
    border: 1px solid #ccc;
    transition: background 0.15s, border-color 0.15s;
}
.dot.filled { background: #555; border-color: #333; }

.s4-forgot {
    text-align: center; font-size: 14px; color: #666;
    margin-bottom: 26px; font-weight: 500;
}

.s4-keypad-wrap { background: #f5f5f5; padding: 20px 16px 36px; }
.s4-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 320px;
    margin: 0 auto;
}
.key {
    background: #fff;
    border: none;
    border-radius: 10px;
    height: 56px;
    font-size: 26px; font-weight: 600; color: #111;
    display: flex; justify-content: center; align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: background 0.1s;
}
.key:active { background: #f0f0f0; }
.key-empty { background: transparent !important; box-shadow: none !important; pointer-events: none; }
.key-del { background: #e0e0e0 !important; }

/* ============================
   SCREEN 5 — CHI TIẾT
   ============================ */
#screen5 { background: #f9f7f4; padding-bottom: 30px; }
.s5-header {
    display: flex; align-items: center; gap: 16px;
    padding: 48px 18px 16px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
}
.s5-back { font-size: 20px; color: #333; cursor: pointer; }
.s5-title { font-size: 18px; font-weight: 700; color: #111; }
.s5-body { padding: 18px 18px 30px; }

.s5-card {
    border-radius: 12px; overflow: hidden;
    position: relative; margin-bottom: 22px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.12);
}
.s5-card-img {
    width: 100%;
    border-radius: 12px;
    display: block;
    margin-bottom: 22px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.12);
}
.s5-id { font-size: 16px !important; }
.s5-name { font-size: 14px !important; text-transform: uppercase; }

.s5-details { margin-bottom: 20px; }
.s5-row {
    font-size: 14px; color: #111; font-weight: 500;
    margin-bottom: 12px; line-height: 1.5;
}
.s5-lbl { color: #0077b6; font-weight: 700; }
.s5-row-flex { display: flex; gap: 20px; }
.s5-half { flex: 1; }

.s5-update {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 13px;
    padding: 14px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
}
.s5-update-label { color: #888; }
.s5-update-val { font-weight: 600; color: #333; }

.s5-action-list { list-style: none; }
.s5-action-list li {
    display: flex; align-items: center; gap: 12px;
    font-size: 14px; font-weight: 600; color: #c62828;
    padding: 14px 0;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}
.s5-action-list li i { font-size: 20px; flex-shrink: 0; }
