/* -------------------------------------------------------------
 * VNeID Style Sheet - Mobile Emulator Simulator
 * ------------------------------------------------------------- */

/* Nền và khung bao giả lập trên màn hình PC */
.phone-frame-wrapper {
    min-height: 100vh;
    width: 100vw;
    background: linear-gradient(135deg, #1e1e24 0%, #111115 100%);
    background-image: radial-gradient(circle at 20% 30%, rgba(161, 26, 26, 0.15) 0%, transparent 50%),
                      radial-gradient(circle at 80% 70%, rgba(245, 158, 11, 0.08) 0%, transparent 50%);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 20px 0;
}

/* Nút quay lại góc trên bên trái màn hình PC */
.floating-back-btn {
    position: absolute;
    top: 25px;
    left: 25px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 30px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    z-index: 10;
}

.floating-back-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(161, 26, 26, 0.4);
    transform: translateX(-3px);
}

/* Thân máy điện thoại */
.phone-device {
    width: 375px;
    height: 780px;
    background-color: #000000;
    border: 12px solid #2e2e2e;
    border-radius: 48px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.8),
                inset 0 0 10px rgba(255,255,255,0.2);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Giữ nguyên tỉ lệ viewport di động */
}

/* Tai thỏ / Notch */
.phone-notch {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 25px;
    background-color: #2e2e2e;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
    z-index: 999;
}

/* Thanh trạng thái (Status Bar) */
.phone-status-bar {
    height: 40px;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 24px 6px 24px;
    font-size: 0.8rem;
    font-weight: 500;
    z-index: 998;
    user-select: none;
}

.status-icons {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Màn hình hiển thị nội dung app */
.phone-screen-content {
    flex: 1;
    background-color: #f4f6f8;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    margin-bottom: 60px; /* Chừa không gian cho bottom nav */
}

/* CÁC MÀN HÌNH CHUYỂN TAB TRÊN DI ĐỘNG */
.mobile-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    padding-bottom: 20px;
}

.mobile-screen.active {
    display: flex;
    animation: slideInScreen 0.25s ease-out;
}

@keyframes slideInScreen {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* =====================================================================
 * HEADER DI ĐỘNG VNEID STYLE
 * ===================================================================== */
.vneid-mobile-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #6e0d0d 100%);
    color: white;
    padding: 1.25rem 1rem;
    text-align: center;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.vneid-mobile-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('/image/heritage-pattern.svg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 70%;
    opacity: 0.04;
}

.header-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.header-emblem {
    width: 60px;
    height: 60px;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.3));
}

.banner-texts h3 {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.8px;
    opacity: 0.9;
}

.banner-texts h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-color);
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* THẺ CHÀO MỪNG AD */
.mobile-welcome-card {
    background-color: white;
    margin: -15px 12px 12px 12px;
    border-radius: 12px;
    padding: 0.8rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    position: relative;
    border: 1px solid var(--border-color);
}

.welcome-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-user {
    display: flex;
    flex-direction: column;
}

.welcome-user span {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.welcome-user strong {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.online-badge {
    background-color: #d1fae5;
    color: var(--success-dark);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

/* THỐNG KÊ NHANH */
.mobile-stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 0 12px;
    margin-bottom: 12px;
}

.m-stat-box {
    background-color: white;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.m-stat-num {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
}

.m-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* MENU CHỨC NĂNG LƯỚI */
.mobile-menu-section {
    padding: 0 12px;
    margin-top: 5px;
}

.mobile-menu-section h4 {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.mobile-menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.menu-grid-item {
    background-color: white;
    border-radius: 12px;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.menu-grid-item:active {
    transform: scale(0.97);
    background-color: var(--bg-main);
}

.grid-icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.icon-scanner { background: linear-gradient(135deg, var(--primary-color) 0%, #db3a3a 100%); }
.icon-users { background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%); }
.icon-catalogs { background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%); }
.icon-settings { background: linear-gradient(135deg, #64748b 0%, #94a3b8 100%); }

.menu-grid-item span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}

/* =====================================================================
 * SUBPAGES (Duyệt Đại biểu, Nhóm trên di động)
 * ===================================================================== */
.mobile-subpage-header {
    height: 50px;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-subpage-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.m-back-btn, .m-add-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.m-back-btn:active, .m-add-btn:active {
    background-color: rgba(255,255,255,0.15);
    border-radius: 50%;
}

.m-search-wrapper {
    padding: 8px 12px;
    background-color: white;
    border-bottom: 1px solid var(--border-color);
}

.m-search-wrapper input {
    width: 100%;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.8rem;
    outline: none;
}

/* DANH SÁCH THẺ DI ĐỘNG */
.mobile-card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
}

.mobile-item-card {
    background-color: white;
    border-radius: 10px;
    padding: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.m-card-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-color);
}

.m-card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 0.65rem;
}

.m-card-details {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.m-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    margin-top: 4px;
}

/* =====================================================================
 * SCANNER TRÊN ĐIỆN THOẠI
 * ===================================================================== */
.mobile-scanner-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
}

#m-reader-container {
    width: 100%;
    max-width: 280px;
    aspect-ratio: 1;
    border: 3px dashed var(--accent-color);
    border-radius: 16px;
    overflow: hidden;
    background-color: #000;
    margin-bottom: 1rem;
}

#m-reader {
    width: 100%;
    height: 100%;
}

.scanner-tip {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.5rem;
}

.mobile-scan-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 280px;
}

.m-btn {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-align: center;
}

.m-btn-primary { background-color: var(--primary-color); color: white; }
.m-btn-danger { background-color: var(--danger-color); color: white; }
.m-btn-secondary { background-color: #e2e8f0; color: var(--text-secondary); }

.m-btn-sm {
    padding: 8px;
    font-size: 0.8rem;
}

/* =====================================================================
 * BOTTOM NAV (Thanh điều hướng dưới chân)
 * ===================================================================== */
.phone-bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #ffffff;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 997;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 600;
    gap: 4px;
    flex: 1;
}

.nav-btn.active {
    color: var(--primary-color);
}

/* Nút quét QR tròn nổi ở giữa (VNeID style) */
.qr-nav-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: -30px;
    cursor: pointer;
    flex: 1;
    z-index: 10;
}

.qr-floating-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent-color) 100%);
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    border: 3px solid white;
    transition: transform 0.2s;
}

.qr-floating-btn:active {
    transform: scale(0.9);
}

.qr-nav-wrapper span {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: 4px;
}

/* =====================================================================
 * MODALS OVERLAYS (Di động)
 * ===================================================================== */
.m-modal-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    padding: 15px;
}

.m-modal-overlay.active {
    display: flex;
}

.m-modal-dialog {
    background-color: white;
    border-radius: 16px;
    width: 100%;
    max-width: 320px;
    padding: 1rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    animation: mScaleUp 0.2s ease-out;
}

@keyframes mScaleUp {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.m-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.m-modal-header h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-color);
}

.m-modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
}

.m-modal-body {
    max-height: 450px;
    overflow-y: auto;
}

/* Form di động */
.m-form-group {
    margin-bottom: 10px;
}

.m-form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.m-form-group input, .m-form-group select, .m-form-group textarea {
    width: 100%;
    padding: 7px 10px;
    font-size: 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    outline: none;
}

/* =====================================================================
 * ĐÁP ỨNG THIẾT BỊ DI ĐỘNG THỰC TẾ (RESPONSIVE IN PRODUCTION)
 * Nếu truy cập thực tế bằng điện thoại di động: Ẩn khung điện thoại,
 * cho chiếm toàn bộ chiều rộng và chiều cao của trình duyệt.
 * ===================================================================== */
@media (max-width: 480px) {
    .phone-frame-wrapper {
        padding: 0;
        background: none;
    }
    
    .floating-back-btn {
        display: none !important; /* Ẩn nút quay lại của PC */
    }
    
    .phone-device {
        width: 100vw;
        height: 100vh;
        border: none;
        border-radius: 0;
    }
    
    .phone-notch {
        display: none; /* Ẩn tai thỏ vì thiết bị thật có riêng */
    }
    
    .phone-status-bar {
        display: none; /* Trình duyệt di động có thanh trạng thái rồi */
    }
}

/* =====================================================================
 * LOGIN OVERLAY CHO GIẢ LẬP DI ĐỘNG (XÁC THỰC CÁN BỘ BẰNG QR)
 * ===================================================================== */
.m-login-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #a11a1a 0%, #3a0000 100%);
    background-image: radial-gradient(circle at 20% 30%, rgba(161, 26, 26, 0.15) 0%, transparent 50%),
                      radial-gradient(circle at 80% 70%, rgba(245, 158, 11, 0.08) 0%, transparent 50%);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 15px;
}

.m-login-overlay.active {
    display: flex;
}

.m-login-card {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: 20px;
    width: 100%;
    max-width: 280px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 2px solid var(--accent-color);
    text-align: center;
}

.m-login-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.m-login-card p {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

#m-login-reader-wrapper {
    width: 180px;
    height: 180px;
    border: 3px dashed var(--primary-color);
    border-radius: 12px;
    overflow: hidden;
    background-color: #000000;
    margin: 12px auto;
}

#m-login-reader {
    width: 100%;
    height: 100%;
}

#m-login-reader button, #m-login-reader select {
    display: none !important;
}

.m-login-error {
    color: var(--danger-color);
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 8px;
}
