@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─────────────────────────────────────────────
   CSS Variables & Reset
───────────────────────────────────────────── */
:root {
  --bg-primary:     #0a0f1e;
  --bg-secondary:   #0f1729;
  --bg-card:        #131d35;
  --bg-card-hover:  #172040;
  --bg-input:       #1a2540;
  --border:         #1e2d4a;
  --border-light:   #253558;

  --accent:         #3b82f6;
  --accent-hover:   #2563eb;
  --accent-light:   rgba(59,130,246,0.12);
  --accent-glow:    rgba(59,130,246,0.3);

  --green:          #10b981;
  --green-light:    rgba(16,185,129,0.12);
  --red:            #ef4444;
  --red-light:      rgba(239,68,68,0.12);
  --yellow:         #f59e0b;
  --yellow-light:   rgba(245,158,11,0.12);
  --purple:         #8b5cf6;
  --purple-light:   rgba(139,92,246,0.12);
  --cyan:           #06b6d4;
  --cyan-light:     rgba(6,182,212,0.12);

  --text-primary:   #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted:     #4a6080;

  --sidebar-w:      260px;
  --radius:         12px;
  --radius-sm:      8px;
  --radius-lg:      16px;
  --shadow:         0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:      0 8px 48px rgba(0,0,0,0.6);

  --transition:     all 0.2s ease;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.6;
}

/* ─────────────────────────────────────────────
   Scrollbar
───────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ─────────────────────────────────────────────
   Layout
───────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─────────────────────────────────────────────
   Sidebar
───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin-bottom: 10px;
  box-shadow: 0 0 20px var(--accent-glow);
}

.logo-title {
  font-size: 15px; font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.logo-sub {
  font-size: 11px; color: var(--text-muted);
  margin-top: 2px;
}

.device-badge {
  margin: 12px 20px;
  background: var(--green-light);
  border: 1px solid rgba(16,185,129,0.3);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--green);
}

.device-badge .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.8); }
}

.device-badge.offline { background: var(--red-light); border-color: rgba(239,68,68,0.3); color: var(--red); }
.device-badge.offline .dot { background: var(--red); animation: none; }

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  font-size: 13.5px; font-weight: 500;
  position: relative;
  user-select: none;
}

.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-item .icon { font-size: 18px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.sync-info {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
}

/* ─────────────────────────────────────────────
   Main Content
───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-primary);
}

/* ─────────────────────────────────────────────
   Top Bar
───────────────────────────────────────────── */
.topbar {
  height: 64px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}

.topbar-title {
  font-size: 18px; font-weight: 700;
  flex: 1;
}

.topbar-time {
  font-size: 13px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary   { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 16px var(--accent-glow); }

.btn-success   { background: var(--green); color: white; }
.btn-success:hover { background: #059669; }

.btn-danger    { background: var(--red); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-ghost     { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-card-hover); border-color: var(--border-light); }

.btn-sm        { padding: 5px 11px; font-size: 12px; }
.btn-icon      { padding: 8px; }
.btn-icon:hover { background: var(--bg-card-hover); }

.btn:disabled  { opacity: 0.5; cursor: not-allowed; }

/* ─────────────────────────────────────────────
   Page Content
───────────────────────────────────────────── */
.page {
  display: none;
  padding: 28px;
  flex: 1;
  animation: fadeIn 0.2s ease;
}

.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap; gap: 12px;
}

.page-header h2 {
  font-size: 22px; font-weight: 800;
}

.page-header p {
  font-size: 13px; color: var(--text-muted);
  margin-top: 2px;
}

/* ─────────────────────────────────────────────
   Stats Grid
───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 0 var(--radius) 0 80px;
  opacity: 0.08;
}

.stat-card.blue::before   { background: var(--accent); }
.stat-card.green::before  { background: var(--green); }
.stat-card.red::before    { background: var(--red); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.yellow::before { background: var(--yellow); }

.stat-icon {
  font-size: 26px; margin-bottom: 12px;
  display: block;
}

.stat-value {
  font-size: 32px; font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card.blue   .stat-value { color: var(--accent); }
.stat-card.green  .stat-value { color: var(--green); }
.stat-card.red    .stat-value { color: var(--red); }
.stat-card.purple .stat-value { color: var(--purple); }
.stat-card.yellow .stat-value { color: var(--yellow); }

.stat-label {
  font-size: 12px; color: var(--text-muted); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* ─────────────────────────────────────────────
   Cards
───────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}

.card-body { padding: 0; }

/* ─────────────────────────────────────────────
   Tables
───────────────────────────────────────────── */
.table-container { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--bg-secondary);
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: rgba(255,255,255,0.02); }

.td-emp {
  display: flex; align-items: center; gap: 10px;
}

.emp-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}

.emp-name    { font-weight: 600; }
.emp-dept    { font-size: 11px; color: var(--text-muted); }
.emp-no      { font-size: 11px; color: var(--text-muted); font-family: monospace; }

/* ─────────────────────────────────────────────
   Badges
───────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}

.badge-green  { background: var(--green-light);  color: var(--green); }
.badge-red    { background: var(--red-light);    color: var(--red); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.badge-blue   { background: var(--accent-light); color: var(--accent); }
.badge-purple { background: var(--purple-light); color: var(--purple); }

/* ─────────────────────────────────────────────
   Forms
───────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }

.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  width: 100%;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control option { background: var(--bg-card); }

/* ─────────────────────────────────────────────
   Search Bar
───────────────────────────────────────────── */
.search-bar {
  position: relative;
}

.search-bar input {
  padding-left: 36px;
}

.search-bar .search-icon {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
}

/* ─────────────────────────────────────────────
   Modal
───────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(20px);
  transition: transform 0.2s ease;
}

.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-title { font-size: 16px; font-weight: 700; }

.modal-close {
  background: var(--bg-input); border: none;
  color: var(--text-muted); cursor: pointer;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  transition: var(--transition);
}

.modal-close:hover { color: var(--text-primary); background: var(--bg-card-hover); }

.modal-body    { padding: 24px; }
.modal-footer  { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ─────────────────────────────────────────────
   Live Attendance Timeline
───────────────────────────────────────────── */
.live-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--green);
  font-weight: 600;
}

.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 1.5s infinite;
}

.attendance-list { max-height: 400px; overflow-y: auto; }

.att-item {
  display: flex; align-items: center;
  padding: 12px 20px;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.att-item:hover { background: rgba(255,255,255,0.02); }
.att-item:last-child { border-bottom: none; }

.att-time {
  font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  min-width: 80px;
}

.att-info { flex: 1; }
.att-name  { font-weight: 600; font-size: 13px; }
.att-dept  { font-size: 11px; color: var(--text-muted); }

/* ─────────────────────────────────────────────
   Progress Bar
───────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  transition: width 0.5s ease;
}

/* ─────────────────────────────────────────────
   Salary Slip
───────────────────────────────────────────── */
.slip-container {
  background: white;
  color: #1a1a2e;
  border-radius: var(--radius);
  padding: 32px;
  font-size: 13px;
  line-height: 1.6;
}

.slip-header { text-align: center; margin-bottom: 24px; }
.slip-header h2 { font-size: 20px; font-weight: 800; color: #1e3a8a; }
.slip-header p  { color: #64748b; }

.slip-divider { border: none; border-top: 2px solid #e2e8f0; margin: 20px 0; }

.slip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.slip-label { color: #64748b; }
.slip-value { font-weight: 600; text-align: right; }

.slip-earnings, .slip-deductions {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

.slip-earnings th, .slip-deductions th {
  background: #f1f5f9;
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.slip-earnings td, .slip-deductions td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
}

.slip-total {
  background: #1e3a8a;
  color: white;
  padding: 14px 16px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 16px;
}

/* ─────────────────────────────────────────────
   Toast Notifications
───────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  min-width: 260px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  font-size: 13px;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }
.toast.warning { border-left: 3px solid var(--yellow); }

.toast-icon { font-size: 18px; }

/* ─────────────────────────────────────────────
   Loading
───────────────────────────────────────────── */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  gap: 10px;
  flex-direction: column;
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 12px;
}

.empty-state .empty-icon { font-size: 48px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ─────────────────────────────────────────────
   Filter Bar
───────────────────────────────────────────── */
.filter-bar {
  display: flex; align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

/* ─────────────────────────────────────────────
   Settings
───────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.settings-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}

.settings-card-body { padding: 20px; }

.connection-status {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600;
  margin-top: 12px;
}

.connection-status.connected { background: var(--green-light); color: var(--green); }
.connection-status.error     { background: var(--red-light);   color: var(--red); }

/* ─────────────────────────────────────────────
   Responsive
───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar        { width: 0; overflow: hidden; }
  .sidebar.open   { width: var(--sidebar-w); }
  .main-content   { margin-left: 0; }
  .stats-grid     { grid-template-columns: 1fr 1fr; }
  .page           { padding: 16px; }
}

/* ─────────────────────────────────────────────
   Misc
───────────────────────────────────────────── */
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue   { color: var(--accent); }
.text-muted  { color: var(--text-muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.font-mono   { font-family: 'Courier New', monospace; }
.font-bold   { font-weight: 700; }
.fw-600      { font-weight: 600; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.d-flex      { display: flex; }
.ai-center   { align-items: center; }
.jc-between  { justify-content: space-between; }
.mt-4        { margin-top: 4px; }
.mt-8        { margin-top: 8px; }
.mt-12       { margin-top: 12px; }
.mt-16       { margin-top: 16px; }
.w-full      { width: 100%; }

/* View Toggle Pills */
.pill-nav {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.05);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 2px;
}

.pill-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.pill-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}
