:root {
    --primary: #4361ee;
    --success: #2ec4b6;
    --danger: #e71d36;
    --bg: #f0f2f5;
    --card: #ffffff;
}

body { margin: 0; font-family: 'Segoe UI', sans-serif; background: var(--bg); color: #2b2d42; overflow-x: hidden; }
.hidden { display: none !important; }
.screen { min-height: 100vh; display: flex; justify-content: center; align-items: center; padding: 15px; position: relative; }

/* Login */
.login-card { background: var(--card); padding: 40px; border-radius: 24px; box-shadow: 0 10px 30px rgba(0,0,0,0.08); width: 100%; max-width: 360px; text-align: center; }
.logo-area { font-size: 50px; color: var(--primary); margin-bottom: 10px; }
.input-group { background: #f8f9fa; display: flex; align-items: center; padding: 12px 15px; border-radius: 12px; margin-bottom: 15px; border: 1px solid #eee; }
.input-group input { border: none; background: transparent; outline: none; margin-left: 10px; width: 100%; font-size: 1rem; }
.btn-login { width: 100%; background: var(--primary); color: white; border: none; padding: 15px; border-radius: 12px; font-weight: bold; cursor: pointer; transition: 0.3s; }

/* Nút ẩn hiện mật khẩu */
.toggle-password { 
    cursor: pointer; 
    color: #7d8597; 
    margin-left: 10px; 
    user-select: none; 
    transition: 0.2s;
}
.toggle-password:hover { color: var(--primary); }

/* Main App */
.app-container { background: var(--card); width: 100%; max-width: 400px; border-radius: 28px; padding: 25px; box-shadow: 0 10px 40px rgba(0,0,0,0.05); z-index: 10; }
.user-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.welcome { font-size: 0.8rem; color: #7d8597; margin: 0; }
#display-name { margin: 5px 0 0 0; font-size: 1.2rem; }
.date-tag { background: #eef2ff; padding: 5px 12px; border-radius: 10px; font-weight: bold; color: var(--primary); }

.status-card { background: #f8f9fa; padding: 15px; border-radius: 15px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.gps-info { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 500; }
.dist-badge { background: var(--primary); color: white; padding: 3px 10px; border-radius: 8px; font-size: 0.8rem; }

.action-area { text-align: center; margin-bottom: 30px; }
.btn-main { 
    width: 170px; height: 170px; border-radius: 50%; border: 10px solid #f0f4ff; 
    background: var(--primary); color: white; cursor: pointer; transition: 0.3s;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    margin: 0 auto;
}
.btn-main:disabled { background: #bdc1c6; border-color: #f1f1f1; }
#btn-icon { font-size: 3rem; margin-bottom: 5px; }

.progress-section { margin-bottom: 25px; }
.progress-header { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 8px; font-weight: 600; }
.progress-bar-bg { height: 8px; background: #eee; border-radius: 4px; overflow: hidden; }
#progress-bar-fill { height: 100%; background: var(--success); width: 0%; transition: 0.5s; }

.history-item { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #f1f1f1; font-size: 0.9rem; }

/* --- NÚT MENU & SIDEBAR --- */
.menu-btn { font-size: 2rem; cursor: pointer; color: var(--primary); transition: 0.2s; }
.menu-btn:hover { color: #2b2d42; }

/* Lớp phủ mờ khi mở menu */
.sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.4); z-index: 99;
    opacity: 0; visibility: hidden; transition: 0.3s ease;
}
.sidebar-overlay.active { opacity: 1; visibility: visible; }

/* Thanh menu trượt */
.sidebar {
    position: fixed; top: 0; right: -300px; /* Ẩn sang bên phải */
    width: 280px; height: 100vh; background: var(--card);
    box-shadow: -5px 0 15px rgba(0,0,0,0.1); z-index: 100;
    transition: right 0.3s ease; display: flex; flex-direction: column;
}
.sidebar.active { right: 0; }

.sidebar-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 25px 20px; border-bottom: 1px solid #f1f1f1;
}
.sidebar-header h3 { margin: 0; font-size: 1.3rem; color: var(--primary); }
.close-btn { cursor: pointer; font-size: 1.8rem; color: #7d8597; transition: 0.2s; }
.close-btn:hover { color: var(--danger); }

/* Danh sách chức năng */
.sidebar-menu { list-style: none; padding: 0; margin: 0; flex-grow: 1; }
.sidebar-menu li {
    padding: 18px 20px; display: flex; align-items: center; gap: 15px;
    font-size: 1rem; color: #2b2d42; font-weight: 500;
    cursor: pointer; border-bottom: 1px solid #f9f9f9; transition: all 0.2s;
}
.sidebar-menu li:hover { background: #f0f4ff; color: var(--primary); padding-left: 25px; }
.sidebar-menu li span { font-size: 1.4rem; color: var(--primary); }

/* Nút đăng xuất */
.sidebar-menu li.logout-item { color: var(--danger); border-bottom: none; margin-top: auto; }
.sidebar-menu li.logout-item span { color: var(--danger); }
.sidebar-menu li.logout-item:hover { background: #ffe3e6; color: var(--danger); }
/* --- TRẠNG THÁI LOADING TOÀN CỤC --- */
#global-loading {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(255, 255, 255, 0.9); z-index: 9999;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.spinner {
    width: 50px; height: 50px; border: 5px solid #f0f4ff;
    border-top: 5px solid var(--primary); border-radius: 50%;
    animation: spin 1s linear infinite; margin-bottom: 15px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
#loading-text { font-weight: bold; color: var(--primary); font-size: 1.1rem; }

/* --- TRẠNG THÁI LỖI GPS --- */
.gps-error { color: var(--danger); }
.gps-error-icon { color: var(--danger) !important; }

/* --- CAMERA MODAL --- */
#camera-modal {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.8); z-index: 1000;
    display: flex; justify-content: center; align-items: center; padding: 20px;
}
.camera-container {
    background: #fff; padding: 20px; border-radius: 20px; width: 100%; max-width: 400px; text-align: center;
}
#camera-stream {
    width: 100%; border-radius: 12px; background: #000; margin: 15px 0; max-height: 400px; object-fit: cover;
}
.camera-actions { display: flex; gap: 10px; }
.camera-actions button {
    flex: 1; padding: 15px; border: none; border-radius: 12px; font-weight: bold; cursor: pointer; color: white;
}
.btn-cancel { background: #7d8597; }
.btn-capture { background: var(--success); }