/* ==========================================================================
   NFC Attendance System — Minimalist Floating UI
   ========================================================================== */

:root{
  --bg-1: #eef1f8;
  --bg-2: #e6ecf7;
  --card-bg: rgba(255,255,255,0.78);
  --card-bg-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.06);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow-soft: 0 10px 40px rgba(30, 41, 59, 0.08);
  --shadow-lift: 0 24px 60px rgba(30, 41, 59, 0.14);
  --text-main: #1b2233;
  --text-muted: #6b7584;
  --text-faint: #99a2b3;
  --accent: #5b6bf5;
  --accent-2: #22c7c3;
  --accent-grad: linear-gradient(135deg, #6a73f1 0%, #22c7c3 100%);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: var(--font);
  color: var(--text-main);
  background: radial-gradient(circle at 10% 10%, #f3f6ff 0%, transparent 45%),
              radial-gradient(circle at 90% 20%, #e8fbf9 0%, transparent 40%),
              radial-gradient(circle at 50% 100%, #eef0ff 0%, transparent 50%),
              linear-gradient(160deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection{ background: var(--accent); color:#fff; }

a{ color: inherit; text-decoration:none; }
button{ font-family: inherit; }

/* Scrollbar */
::-webkit-scrollbar{ width:8px; height:8px; }
::-webkit-scrollbar-thumb{ background: rgba(100,110,140,0.25); border-radius: 10px; }
::-webkit-scrollbar-track{ background: transparent; }

/* ---------------- Floating window primitive ---------------- */
.window{
  background: var(--card-bg);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: var(--shadow-soft);
  transition: transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s ease;
}
.window.solid{ background: var(--card-bg-solid); backdrop-filter:none; }
.window.hover-lift:hover{ transform: translateY(-4px); box-shadow: var(--shadow-lift); }

.fade-in{ animation: fadeIn .5s ease both; }
.fade-up{ animation: fadeUp .55s cubic-bezier(.2,.8,.2,1) both; }
.pop-in{ animation: popIn .4s cubic-bezier(.34,1.56,.64,1) both; }

@keyframes fadeIn{ from{opacity:0;} to{opacity:1;} }
@keyframes fadeUp{ from{opacity:0; transform: translateY(18px);} to{opacity:1; transform:none;} }
@keyframes popIn{ from{opacity:0; transform: scale(.88);} to{opacity:1; transform:scale(1);} }
@keyframes pulseRing{
  0%{ box-shadow: 0 0 0 0 rgba(91,107,245,.35); }
  70%{ box-shadow: 0 0 0 28px rgba(91,107,245,0); }
  100%{ box-shadow: 0 0 0 0 rgba(91,107,245,0); }
}
@keyframes floatY{
  0%,100%{ transform: translateY(0); }
  50%{ transform: translateY(-8px); }
}
@keyframes spin{ to{ transform: rotate(360deg); } }

/* ---------------- Buttons ---------------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding: 11px 20px;
  border-radius: 14px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, opacity .18s;
  background: rgba(100,110,140,0.08);
  color: var(--text-main);
}
.btn:hover{ transform: translateY(-2px); }
.btn:active{ transform: translateY(0); }
.btn-primary{ background: var(--accent-grad); color:#fff; box-shadow: 0 10px 24px rgba(91,107,245,0.35); }
.btn-primary:hover{ box-shadow: 0 14px 30px rgba(91,107,245,0.45); }
.btn-danger{ background: rgba(239,68,68,0.1); color:#dc2626; }
.btn-danger:hover{ background: rgba(239,68,68,0.18); }
.btn-ghost{ background: transparent; color: var(--text-muted); }
.btn-ghost:hover{ background: rgba(100,110,140,0.08); }
.btn-sm{ padding: 7px 13px; font-size: 12.5px; border-radius: 10px; }
.btn[disabled]{ opacity:.5; cursor:not-allowed; transform:none; }
.btn-icon{ width:40px; height:40px; padding:0; border-radius: 12px; }

/* ---------------- Inputs ---------------- */
.field{ display:flex; flex-direction:column; gap:6px; margin-bottom:16px; }
.field label{ font-size: 12.5px; font-weight:600; color: var(--text-muted); letter-spacing:.2px; }
.input, .select, .textarea{
  padding: 11px 14px;
  border-radius: 12px;
  border: 1.5px solid rgba(100,110,140,0.14);
  background: rgba(255,255,255,0.7);
  font-size: 14px;
  color: var(--text-main);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s;
  font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus{
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(91,107,245,0.12);
  background: #fff;
}
.textarea{ resize: vertical; min-height: 64px; line-height:1.5; }
.hint{ font-size:11.5px; color: var(--text-faint); }

.toggle{ position:relative; width:46px; height:26px; flex:none; }
.toggle input{ opacity:0; width:0; height:0; }
.toggle .slider{
  position:absolute; inset:0; background: rgba(100,110,140,0.25); border-radius: 30px; cursor:pointer;
  transition: background .25s ease;
}
.toggle .slider::before{
  content:''; position:absolute; width:20px; height:20px; left:3px; top:3px;
  background:#fff; border-radius:50%; transition: transform .25s cubic-bezier(.2,.8,.2,1); box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.toggle input:checked + .slider{ background: var(--accent-grad); }
.toggle input:checked + .slider::before{ transform: translateX(20px); }

/* ---------------- Badges ---------------- */
.badge{ display:inline-flex; align-items:center; gap:5px; padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight:700; letter-spacing:.3px; }
.badge-success{ background: rgba(34,197,94,0.12); color:#15803d; }
.badge-danger{ background: rgba(239,68,68,0.12); color:#b91c1c; }
.badge-muted{ background: rgba(100,110,140,0.12); color: var(--text-muted); }
.badge-warn{ background: rgba(245,158,11,0.14); color:#b45309; }
.badge-info{ background: rgba(91,107,245,0.12); color:#3b45c7; }

/* ==========================================================================
   KIOSK PAGE
   ========================================================================== */
.kiosk-wrap{
  min-height:100vh;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding: 32px 20px;
  position: relative;
}
.kiosk-topbar{
  position:fixed; top:24px; left:0; right:0;
  display:flex; justify-content:space-between; align-items:center;
  padding: 0 32px;
  z-index: 5;
}
.brand{ display:flex; align-items:center; gap:10px; font-weight:700; font-size:15px; color: var(--text-main); }
.brand .dot{ width:10px; height:10px; border-radius:50%; background: var(--accent-grad); }
.clock-chip{
  padding: 8px 18px; border-radius: 20px; font-size:13px; font-weight:600; color: var(--text-muted);
}
.admin-link{
  width:40px; height:40px; border-radius:14px; display:flex; align-items:center; justify-content:center;
  color: var(--text-muted); font-size:16px;
}
.admin-link:hover{ color: var(--accent); }

.kiosk-card{
  width: min(480px, 92vw);
  padding: 56px 40px 44px;
  text-align:center;
  position:relative;
}
.scan-ring{
  width:140px; height:140px; border-radius:50%;
  margin: 0 auto 28px;
  display:flex; align-items:center; justify-content:center;
  background: var(--accent-grad);
  color:#fff; font-size:54px;
  animation: pulseRing 2.4s infinite, floatY 4s ease-in-out infinite;
}
.scan-ring i{ filter: drop-shadow(0 4px 10px rgba(0,0,0,0.15)); }
.kiosk-card h1{ font-size: 22px; margin: 0 0 8px; font-weight:800; }
.kiosk-card p.sub{ color: var(--text-muted); font-size: 14.5px; margin:0 0 26px; }
.org-name{ font-size:13px; letter-spacing:1.5px; text-transform:uppercase; color: var(--text-faint); font-weight:700; margin-bottom:6px; }

#scan-input{
  position:absolute; opacity:0; pointer-events:none; width:1px; height:1px;
}
.manual-entry{ margin-top: 18px; }
.manual-entry summary{ cursor:pointer; font-size:12.5px; color: var(--text-faint); }
.manual-row{ display:flex; gap:8px; margin-top: 10px; }

.recent-panel{
  width: min(480px, 92vw);
  margin-top: 20px;
  padding: 18px 20px;
}
.recent-panel h3{ font-size: 12.5px; text-transform:uppercase; letter-spacing:.8px; color: var(--text-faint); margin: 0 0 12px; }
.recent-item{
  display:flex; align-items:center; justify-content:space-between;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  animation: fadeUp .4s ease both;
}
.recent-item:last-child{ border-bottom:none; }
.recent-item .ri-name{ font-weight:600; }
.recent-item .ri-meta{ color: var(--text-faint); font-size:12px; }
.recent-empty{ color: var(--text-faint); font-size:13px; text-align:center; padding: 10px 0; }

/* Scan result overlay */
.result-overlay{
  position:fixed; inset:0; z-index: 50;
  display:flex; align-items:center; justify-content:center;
  background: rgba(20,24,38,0.35);
  backdrop-filter: blur(6px);
  opacity:0; pointer-events:none; transition: opacity .3s ease;
}
.result-overlay.show{ opacity:1; pointer-events:all; }
.result-card{
  width: min(420px, 90vw);
  padding: 44px 36px;
  text-align:center;
  transform: scale(.9);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
}
.result-overlay.show .result-card{ transform: scale(1); }
.result-icon{
  width:84px; height:84px; border-radius:50%; margin: 0 auto 20px;
  display:flex; align-items:center; justify-content:center; font-size:38px; color:#fff;
}
.result-icon.ok{ background: linear-gradient(135deg,#34d399,#10b981); }
.result-icon.err{ background: linear-gradient(135deg,#f87171,#ef4444); }
.result-title{ font-size:20px; font-weight:800; margin-bottom:6px; }
.result-msg{ color: var(--text-muted); font-size:14.5px; margin-bottom: 4px; }
.result-time{ color: var(--text-faint); font-size:12.5px; }

.access-denied{
  min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px;
}
.access-denied .window{ max-width:460px; padding:44px; text-align:center; }
.access-denied i{ font-size:40px; color:var(--danger); margin-bottom:16px; }

/* ==========================================================================
   ADMIN PAGE
   ========================================================================== */
.admin-shell{ display:flex; min-height:100vh; }
.sidebar{
  width: 250px; flex: none;
  margin: 20px 0 20px 20px;
  padding: 22px 16px;
  display:flex; flex-direction:column;
  height: calc(100vh - 40px);
  position: sticky; top:20px;
}
.sidebar .brand{ padding: 4px 10px 22px; font-size:16px; }
.nav-item{
  display:flex; align-items:center; gap:12px;
  padding: 12px 14px; border-radius: 14px; margin-bottom:4px;
  font-size:14px; font-weight:600; color: var(--text-muted);
  cursor:pointer; transition: all .2s ease;
}
.nav-item i{ width:18px; text-align:center; }
.nav-item:hover{ background: rgba(100,110,140,0.08); color: var(--text-main); }
.nav-item.active{ background: var(--accent-grad); color:#fff; box-shadow: 0 8px 20px rgba(91,107,245,0.3); }
.sidebar-foot{ margin-top:auto; padding-top: 16px; }

.main-area{ flex:1; padding: 20px; overflow-x:hidden; }
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding: 16px 24px; margin-bottom: 20px;
}
.topbar h2{ margin:0; font-size:20px; font-weight:800; }
.topbar .sub{ color: var(--text-muted); font-size:13px; margin-top:2px; }

.tab-panel{ display:none; }
.tab-panel.active{ display:block; animation: fadeUp .4s ease both; }

.grid{ display:grid; gap:18px; }
.grid-4{ grid-template-columns: repeat(4, 1fr); }
.grid-3{ grid-template-columns: repeat(3, 1fr); }
.grid-2{ grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px){ .grid-4{ grid-template-columns: repeat(2,1fr);} .grid-3{grid-template-columns: repeat(2,1fr);} }
@media (max-width: 720px){ .grid-4,.grid-3,.grid-2{ grid-template-columns: 1fr; } }

.stat-card{ padding: 22px 24px; }
.stat-card .stat-icon{ width:42px; height:42px; border-radius:12px; display:flex; align-items:center; justify-content:center; color:#fff; font-size:17px; margin-bottom:14px; }
.stat-card .stat-val{ font-size: 26px; font-weight:800; }
.stat-card .stat-label{ font-size:12.5px; color: var(--text-muted); font-weight:600; margin-top:2px; }

.panel{ padding: 24px; margin-bottom: 20px; }
.panel-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; flex-wrap:wrap; gap:10px; }
.panel-head h3{ margin:0; font-size:16px; font-weight:800; }

.table-wrap{ overflow-x:auto; border-radius: 14px; }
table.data-table{ width:100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th{
  text-align:left; padding: 12px 14px; color: var(--text-faint); font-size:11.5px;
  text-transform:uppercase; letter-spacing:.5px; border-bottom: 1.5px solid var(--border); white-space:nowrap;
}
table.data-table td{ padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align:middle; }
table.data-table tr:last-child td{ border-bottom:none; }
table.data-table tr{ transition: background .15s ease; }
table.data-table tbody tr:hover{ background: rgba(100,110,140,0.05); }
.row-actions{ display:flex; gap:6px; }
.empty-row td{ text-align:center; color: var(--text-faint); padding: 30px !important; }

.filters-row{ display:flex; gap:12px; flex-wrap:wrap; align-items:flex-end; margin-bottom: 18px; }
.filters-row .field{ margin-bottom:0; min-width: 160px; }

.search-box{ position:relative; }
.search-box i{ position:absolute; left:14px; top:50%; transform:translateY(-50%); color: var(--text-faint); font-size:13px; }
.search-box .input{ padding-left:36px; }

/* Modal */
.modal-overlay{
  position:fixed; inset:0; background: rgba(20,24,38,0.4); backdrop-filter: blur(6px);
  display:flex; align-items:center; justify-content:center; z-index:100;
  opacity:0; pointer-events:none; transition: opacity .25s ease;
}
.modal-overlay.show{ opacity:1; pointer-events:all; }
.modal-box{
  width: min(520px, 92vw); max-height: 86vh; overflow-y:auto;
  padding: 30px; transform: translateY(14px) scale(.97); transition: transform .3s cubic-bezier(.2,.8,.2,1);
}
.modal-overlay.show .modal-box{ transform:none; }
.modal-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; }
.modal-head h3{ margin:0; font-size:18px; font-weight:800; }
.modal-foot{ display:flex; justify-content:flex-end; gap:10px; margin-top: 10px; }

/* Program NFC */
.scan-zone{
  text-align:center; padding: 40px 20px; border: 2px dashed rgba(100,110,140,0.2); border-radius: 20px;
  transition: all .3s ease;
}
.scan-zone.active{ border-color: var(--accent); background: rgba(91,107,245,0.05); }
.scan-zone .sz-icon{
  width:70px; height:70px; border-radius:50%; margin:0 auto 16px; display:flex; align-items:center; justify-content:center;
  background: var(--accent-grad); color:#fff; font-size:28px;
}
.scan-zone.active .sz-icon{ animation: pulseRing 1.6s infinite; }
.uid-display{
  font-family: 'Courier New', monospace; font-size: 18px; font-weight:700; letter-spacing:1px;
  padding: 10px 18px; border-radius: 10px; background: rgba(100,110,140,0.08); display:inline-block; margin-top:10px;
}

/* Login overlay */
.login-overlay{ position:fixed; inset:0; z-index:200; display:flex; align-items:center; justify-content:center; background: var(--bg-1); }
.login-box{ width:min(380px,90vw); padding:40px; text-align:center; }
.login-box .logo-circle{ width:64px;height:64px;border-radius:50%; background:var(--accent-grad); display:flex;align-items:center;justify-content:center;color:#fff;font-size:26px; margin:0 auto 18px; }

/* Toast */
.toast-stack{ position:fixed; top:20px; right:20px; z-index:300; display:flex; flex-direction:column; gap:10px; }
.toast{
  padding: 13px 18px; border-radius: 14px; font-size:13.5px; font-weight:600; color:#fff;
  display:flex; align-items:center; gap:10px; min-width:220px;
  box-shadow: var(--shadow-lift);
  animation: fadeUp .35s ease both;
}
.toast.ok{ background: linear-gradient(135deg,#34d399,#10b981); }
.toast.err{ background: linear-gradient(135deg,#f87171,#ef4444); }
.toast.info{ background: linear-gradient(135deg,#6a73f1,#5b6bf5); }

.ip-current{ display:flex; align-items:center; gap:10px; padding:14px 16px; border-radius:14px; background: rgba(91,107,245,0.06); margin-bottom: 16px; }

.spinner{ width:16px; height:16px; border-radius:50%; border: 2px solid rgba(255,255,255,0.4); border-top-color:#fff; animation: spin .7s linear infinite; }

.text-muted{ color: var(--text-muted); }
.text-faint{ color: var(--text-faint); }
.mt-0{ margin-top:0; }
.flex{ display:flex; }
.flex-between{ display:flex; align-items:center; justify-content:space-between; }
.gap-8{ gap:8px; }
.gap-12{ gap:12px; }

@media (max-width: 900px){
  .sidebar{ display:none; }
  .main-area{ padding: 14px; }
}
.mobile-tabbar{ display:none; }
@media (max-width: 900px){
  .mobile-tabbar{
    display:flex; overflow-x:auto; gap:8px; padding: 12px; margin: 10px 10px 0;
  }
  .mobile-tabbar .nav-item{ white-space:nowrap; margin-bottom:0; }
}
