/* style.css */

*{ box-sizing:border-box; margin:0; padding:0; }

:root{
    --bg: #f4fbf7;
    --surface: #ffffff;
    --surface2: #e8f6ee;
    --accent: #22c55e;
    --accent2: #16a34a;
    --text: #1f2937;
    --muted: #6b7280;
    --border: rgba(0,0,0,0.07);
    --sidebar-w: 240px;
    --danger: #ef4444;
    --warn: #f59e0b;
}

body{ font-family:'DM Sans',sans-serif; background:var(--bg); color:var(--text); min-height:100vh; }

/* ════════════════════════════════
   LOGIN
════════════════════════════════ */
.login-wrap{
    min-height:100vh; min-height:100dvh;
    display:flex; align-items:center; justify-content:center; padding:20px;
    background:
        radial-gradient(ellipse at 60% 20%, rgba(74,222,128,0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 10% 80%, rgba(34,197,94,0.06) 0%, transparent 50%),
        var(--bg);
}
.login-card{
    width:100%; max-width:400px;
    background:var(--surface); border:1px solid var(--border);
    border-radius:20px; padding:48px 40px; text-align:center;
    box-shadow:0 40px 80px rgba(0,0,0,0.5);
}
.login-logo{ margin-bottom:32px; }
.login-card h1{
    font-family:'Syne',sans-serif; font-size:28px; font-weight:800;
    letter-spacing:3px; color:var(--text); margin-bottom:8px;
}
.login-card p.sub{ color:var(--muted); font-size:13px; margin-bottom:36px; }
.login-card input{
    width:100%; padding:14px;
    background:var(--surface2); border:1px solid var(--border);
    border-radius:10px; color:var(--text);
    font-family:'DM Sans',sans-serif; font-size:15px;
    margin-bottom:14px; transition:border 0.2s; outline:none;
}
.login-card input:focus{ border-color:var(--accent); }
.login-card input::placeholder{ color:var(--muted); }
.btn-login{
    width:100%; padding:14px; background:var(--accent); color:#0f1117;
    border:none; border-radius:10px; font-family:'Syne',sans-serif;
    font-size:15px; font-weight:700; letter-spacing:1px; cursor:pointer;
    transition:background 0.2s, transform 0.1s;
}
.btn-login:hover{ background:var(--accent2); }
.btn-login:active{ transform:scale(0.98); }
.error-msg{
    margin-top:14px; padding:10px 14px;
    background:rgba(239,68,68,0.15); border:1px solid rgba(239,68,68,0.3);
    border-radius:8px; color:#fc8181; font-size:13px;
}
.login-note{ margin-top:20px; font-size:12px; color:var(--muted); line-height:1.6; }
.login-footer{ margin-top:32px; font-size:11px; color:#44485a; }

/* ════════════════════════════════
   LAYOUT
════════════════════════════════ */
.layout{ display:flex; min-height:100vh; }

/* ════════════════════════════════
   SIDEBAR  ← Phần 2
════════════════════════════════ */
.sidebar{
    width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
    position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh;    /* ← dvh quan trọng trên mobile (tránh bị browser bar che) */
    display: flex; flex-direction: column; z-index: 100; transform: translateX(0);
    transition: transform 0.3s cubic-bezier(.4,0,.2,1); overflow-y: auto;   /* ← thêm dòng này */
}
.sidebar-header{ padding:24px 20px; border-bottom:1px solid var(--border); }
.sidebar-header span{ font-family:'Syne',sans-serif; font-size:18px; font-weight:800; color:var(--accent); }
.sidebar-header small{ display:block; font-size:11px; color:var(--muted); margin-top:2px; }
.sidebar nav{ flex:1; padding:12px 0; }
.nav-item{
    display:flex; align-items:center; gap:12px;
    padding:12px 20px; color:var(--muted); text-decoration:none;
    font-family:'DM Sans',sans-serif; font-size:14px; font-weight:500;
    line-height:1.4; transition:color 0.2s, background 0.2s;
}
.nav-item:hover{ color:var(--text); background:var(--surface2); }
.nav-item.active{ color:var(--accent); background:rgba(74,222,128,0.08); }
.nav-item .icon{ font-size:16px; line-height:1; flex-shrink:0; }
.nav-item.logout{ color:#fc8181; }
.nav-item.logout:hover{ background:rgba(239,68,68,0.1); }
.sidebar-bottom { margin-top: auto; flex-shrink: 0; border-top: 1px solid var(--border); }
.sidebar-footer { padding: 10px 20px 16px; font-size: 11px; color: #44485a; }

/* ════════════════════════════════
   TOPBAR  ← Phần 1 + 3
════════════════════════════════ */
.main{ margin-left:var(--sidebar-w); flex:1; min-height:100vh; display:flex; flex-direction:column; }
.topbar{
    padding:26px 28px; border-bottom:1px solid var(--border);
    display:flex; align-items:center; gap:16px;
    background:var(--surface); position:sticky; top:0; z-index:50;
}
.menu-btn{
    display:none; background:none; border:none;
    color:var(--text); font-size:22px; cursor:pointer; padding:4px; line-height:1;
}
.topbar-title{ font-family:'Syne',sans-serif; font-size:16px; font-weight:700; }
.topbar-user{ margin-left:auto; display:flex; align-items:center; gap:10px; font-size:13px; color:var(--muted); }
/* Thay thế block .avatar cũ */
.avatar{
    width:34px; height:34px; border-radius:50%;
    background:linear-gradient(135deg, var(--accent), var(--accent2));
    display:flex; align-items:center; justify-content:center;
    font-family:'Syne',sans-serif; font-size:14px; font-weight:700; color:#0f1117;
    cursor:pointer; -webkit-user-select: none; -moz-user-select: none;
    -ms-user-select: none;user-select:none; transition:opacity 0.15s;
}
.avatar:hover{ opacity:0.85; }

.avatar-wrap{ position:relative; }

.avatar-menu{
    display:none;
    position:absolute;
    top:calc(100% + 10px);
    right:0;
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:12px;
    box-shadow:0 8px 32px rgba(0,0,0,0.12);
    min-width:160px;
    z-index:200;
    overflow:hidden;
    opacity:0;
    transform:translateY(-6px);
    transition:opacity 0.15s ease, transform 0.15s ease;
    pointer-events:none;
}
.avatar-menu.open{ 
    display:block;
    opacity:1;
    transform:translateY(0);
    pointer-events:auto;
 }

.avatar-menu-item{
    display:flex; align-items:center; gap:10px;
    padding:12px 18px;
    font-size:14px; font-family:'DM Sans',sans-serif; font-weight:500;
    text-decoration:none; color:var(--text);
    transition:background 0.15s;
}
.avatar-menu-item:hover{ background:var(--surface2); }
.logout-item{ color:#fc8181; }
.logout-item:hover{ background:rgba(239,68,68,0.08); }

/* ════════════════════════════════
   PAGE CONTENT  ← Phần 4
════════════════════════════════ */
.page-content{ padding:32px 28px; flex:1; }

/* Overlay mobile */
.overlay{
    display:none; position:fixed; inset:0;
    background:rgba(0,0,0,0.6); z-index:99;
    -webkit-backdrop-filter:blur(2px); backdrop-filter:blur(2px);
}

/* ════════════════════════════════
   DASHBOARD
════════════════════════════════ */
.welcome-card{
    background:linear-gradient(135deg, var(--surface2) 0%, rgba(74,222,128,0.08) 100%);
    border:1px solid var(--border); border-radius:16px; padding:32px; max-width:500px;
}
.welcome-card h2{ font-family:'Syne',sans-serif; font-size:24px; font-weight:800; margin-bottom:8px; }
.welcome-card p{ color:var(--muted); font-size:14px; line-height:1.6; }
.quick-links{ display:flex; gap:14px; margin-top:24px; flex-wrap:wrap; }
.quick-link{
    display:flex; align-items:center; gap:8px;
    padding:10px 18px; background:var(--surface);
    border:1px solid var(--border); border-radius:10px;
    color:var(--text); text-decoration:none; font-size:13px; font-weight:500;
    transition:border-color 0.2s, background 0.2s;
}
.quick-link:hover{ border-color:var(--accent); background:rgba(74,222,128,0.06); }

/* ════════════════════════════════
   GETUSER — chips, badges, table
════════════════════════════════ */
.search-bar{
    display:flex; align-items:center; gap:12px;
    background:var(--surface); border:1px solid var(--border);
    border-radius:12px; padding:12px 18px; margin-bottom:20px; max-width:380px;
}
.search-bar input{
    background:none; border:none; outline:none;
    color:var(--text); font-family:'DM Sans',sans-serif; font-size:14px; width:100%;
}
.search-bar input::placeholder{ color:var(--muted); }
.search-bar .icon{ color:var(--muted); font-size:16px; flex-shrink:0; }

.summary-row{ display:flex; gap:10px; margin-bottom:24px; flex-wrap:wrap; }
.chip{
    padding:6px 14px; border-radius:20px; font-size:12px; font-weight:600;
    background:var(--surface2); border:1px solid var(--border);
    display:flex; align-items:center; gap:6px;
}
.chip .dot{ width:8px; height:8px; border-radius:50%; }

.role-badge{
    padding:4px 12px; border-radius:20px;
    font-size:11px; font-weight:700; letter-spacing:0.5px;
    display:inline-flex; align-items:center;
}
.role-Administrator{ background:rgba(239,68,68,0.15);  color:#f87171;   border:1px solid rgba(239,68,68,0.3); }
.role-Manager{       background:rgba(34,197,94,0.15);  color:#4ade80;   border:1px solid rgba(34,197,94,0.3); }
.role-Enroller{      background:rgba(245,158,11,0.15); color:#fbbf24;   border:1px solid rgba(245,158,11,0.3); }
.role-User{          background:rgba(59,130,246,0.15); color:#60a5fa;   border:1px solid rgba(59,130,246,0.3); }
.role-Empty{         background:rgba(107,114,128,0.1); color:var(--muted);border:1px solid rgba(107,114,128,0.2); }

/* Mobile user cards */
.card-list{ display:none; flex-direction:column; gap:10px; }
.user-card{
    background:var(--surface); border:1px solid var(--border);
    border-radius:14px; padding:16px 18px;
    display:flex; align-items:center; gap:14px;
}
.user-card-avatar{
    width:42px; height:42px; border-radius:50%; flex-shrink:0;
    background:var(--surface2); border:1px solid var(--border);
    display:flex; align-items:center; justify-content:center;
    font-family:'Syne',sans-serif; font-size:16px; font-weight:800; color:var(--accent);
}
.user-card-info{ flex:1; min-width:0; }
.user-card-name{ font-weight:600; font-size:15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-card-sub{ display:flex; align-items:center; gap:8px; margin-top:5px; flex-wrap:wrap; }
.user-card-id{ font-size:12px; color:var(--muted); font-family:'Syne',sans-serif; }

/* ════════════════════════════════
   TABLE chung
════════════════════════════════ */
.table-wrap{ background:var(--surface); border:1px solid var(--border); border-radius:16px; overflow:hidden; }
table{ width:100%; border-collapse:collapse; }
thead tr{ background:var(--surface2); }
th{
    padding:13px 16px; text-align:left;
    font-size:11px; font-weight:600; letter-spacing:0.8px;
    color:var(--muted); text-transform:uppercase; white-space:nowrap;
}
td{ padding:12px 16px; border-top:1px solid var(--border); font-size:14px; white-space:nowrap; }
tr:hover td{ background:rgba(0,0,0,0.01); }
.id-cell{ font-family:'Syne',sans-serif; font-weight:700; color:var(--accent); font-size:15px; }
.name-cell{ font-weight:500; }
.pass-cell{ font-family:monospace; font-size:13px; color:var(--muted); letter-spacing:1px; }
.count-bar{
    padding:14px 20px; background:var(--surface2); border-top:1px solid var(--border);
    font-size:13px; color:var(--muted); display:flex; justify-content:space-between;
}
.count-bar strong{ color:var(--text); }

/* ════════════════════════════════
   GETATTENDANCE — filter, report
════════════════════════════════ */
.filter-card{
    background:var(--surface); border:1px solid var(--border);
    border-radius:16px; padding:24px; margin-bottom:28px;
}
.filter-card h2{
    font-family:'Be Vietnam Pro',sans-serif; font-size:20px; font-weight:800;
    margin-bottom:20px; display:flex; align-items:center; gap:10px;
}
.filter-grid{ display:grid; grid-template-columns:1fr 1fr auto; gap:16px; align-items:end; }
.filter-group{ display:flex; flex-direction:column; gap:6px; }
.filter-group label{ font-size:12px; font-weight:500; color:var(--muted); text-transform:uppercase; letter-spacing:0.8px; }

input[type=date], select{
    background:var(--surface2); border:1px solid var(--border);
    border-radius:10px; color:var(--text);
    font-family:'DM Sans',sans-serif; font-size:14px;
    padding:10px 14px; outline:none; transition:border-color 0.2s; width:100%;
}
input[type=date]:focus, select:focus{ border-color:var(--accent); }
input[type=date]::-webkit-calendar-picker-indicator{ filter:invert(0.7); }
select[multiple]{ height:110px; resize:none; font-family:Consolas,monospace; }
select option:checked{ background:rgba(74,222,128,0.2); color:var(--accent); }

.btn-filter{
    padding:11px 28px; background:var(--accent); color:#0f1117;
    border:none; border-radius:10px; font-family:'Syne',sans-serif;
    font-size:14px; font-weight:700; cursor:pointer; white-space:nowrap;
    transition:background 0.2s, transform 0.1s;
}
.btn-filter:hover{ background:var(--accent2); }
.btn-filter:active{ transform:scale(0.97); }

/* ── NGÀY VẮNG ── */
.row-absent td { color: var(--muted, #aaa); background: #fafafa; }
.row-weekend td { background: #f0f4ff; }
.row-weekend.row-absent td { background: #f5f0ff; color: #bbb; }
.absent-badge { color: #ccc; font-style: italic; font-size: 0.85em; }

/* ── NÚT XUẤT EXCEL ── */
.btn-export {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px; border: none; border-radius: 8px;
    background: #1d6f42; color: #fff; font-size: 0.9rem;
    font-weight: 600; cursor: pointer; text-decoration: none;
    transition: background 0.2s;
}
.btn-export:hover { background: #155234; }
.export-bar { display: flex; justify-content: flex-start; margin-bottom: 10px; }

.report-section{ margin-bottom:32px; }
.report-header{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.report-header h3{
    font-family:'Syne',sans-serif; font-size:17px; font-weight:700;
    display:flex; align-items:center; gap:8px;
}
.badge-id{
    background:rgba(74,222,128,0.15); color:var(--accent);
    padding:3px 10px; border-radius:20px; font-size:12px; font-weight:600;
}
.stats-row{ display:flex; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
.stat-pill{
    padding:6px 14px; border-radius:20px; font-size:12px; font-weight:600;
    background:var(--surface2); border:1px solid var(--border);
    display:flex; align-items:center; gap:6px;
}
.stat-pill .dot{ width:8px; height:8px; border-radius:50%; }
.dot-green{ background:var(--accent); }
.dot-yellow{ background:var(--warn); }

.time-in{ color:var(--accent); font-weight:500; }
.time-out{ color:#60a5fa; font-weight:500; }
.time-missing{ color:var(--muted); }

.hours-badge{
    display:inline-flex; align-items:center; gap:4px;
    padding:3px 10px; border-radius:20px; font-size:12px; font-weight:600;
}
.hours-good{ background:rgba(74,222,128,0.15); color:var(--accent); }
.hours-warn{ background:rgba(251,191,36,0.15); color:var(--warn); }
.hours-zero{ background:rgba(148,163,184,0.1); color:var(--muted); }
.tfoot-row td{ background:var(--surface2); font-weight:600; font-family:'Syne',sans-serif; font-size:13px; }

.empty-state{ padding:40px; text-align:center; color:var(--muted); }
.empty-state .big{ font-size:40px; margin-bottom:12px; }

/* Mobile day cards */
.day-card-list{ display:none; flex-direction:column; gap:8px; }
.day-card{
    background:var(--surface); border:1px solid var(--border);
    border-radius:12px; padding:14px 16px;
    display:grid; grid-template-columns:1fr 1fr; gap:6px 10px; align-items:center;
}
.day-card-date{
    grid-column:1/-1; font-family:'Syne',sans-serif;
    font-weight:700; font-size:14px; color:var(--text); margin-bottom:4px;
}
.day-card-row{ display:flex; flex-direction:column; gap:2px; }
.day-card-label{ font-size:10px; color:var(--muted); text-transform:uppercase; letter-spacing:0.7px; }
.day-card-val{ font-size:14px; font-weight:500; }
.day-card-hours{ grid-column:1/-1; margin-top:4px; }

/* ════════════════════════════════
   RESPONSIVE
════════════════════════════════ */
@media(max-width:900px){
    .filter-grid{ grid-template-columns:1fr 1fr; }
    .filter-grid .filter-group:last-child{ grid-column:1/-1; }
    .btn-filter{ width:100%; }
}

@media(max-width:768px){
    .sidebar{ transform:translateX(calc(-1 * var(--sidebar-w))); }
    .sidebar.open{ transform:translateX(0); box-shadow:20px 0 60px rgba(0,0,0,0.5); }
    .overlay.show{ display:block; }
    .main{ margin-left:0; }
    .menu-btn{ display:block; }
    .page-content{ padding:20px 16px; }
    .topbar{ padding:14px 16px; }
    .search-bar{ max-width:100%; }
    .filter-grid{ grid-template-columns:1fr; }
    .filter-grid .filter-group:last-child{ grid-column:auto; }
    /* swap table → cards */
    .table-wrap{ display:none; }
    .card-list{ display:flex; }
    .day-card-list{ display:flex; }
}