/* ===== GLOBAL RESET & VARS ===== */
:root {
  --bg: #f0f2f8;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-light: #eef2f7;

  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #eef2ff;
  --primary-glow: rgba(79,70,229,0.15);

  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;

  --success: #10b981;
  --success-bg: #ecfdf5;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;

  --sidebar-width: 240px;
  --radius: 14px;
  --radius-sm: 8px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.15);
  --shadow-modal: 0 24px 80px rgba(15,23,42,0.25);

  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== SPINNER ===== */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(79,70,229,0.4); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }

.btn-ghost-modal {
  background: #f1f5f9;
  color: var(--text-muted);
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s;
}
.btn-ghost-modal:hover { background: #e2e8f0; color: var(--text); }

.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input, select {
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.18s, box-shadow 0.18s;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

input:disabled { background: #f8fafc; color: var(--text-soft); cursor: not-allowed; }
select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.error-text { color: var(--danger); font-size: 13px; font-weight: 500; }
.attempt-text { color: var(--warning); font-size: 12px; font-weight: 600; text-align: center; margin-top: 4px; }

/* ===== INPUT WRAP (password show/hide) ===== */
.input-wrap { position: relative; }
.input-wrap input { width: 100%; padding-right: 44px; }
.eye-btn {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer; color: var(--text-soft);
  padding: 4px;
  transition: color 0.15s;
}
.eye-btn:hover { color: var(--text-muted); }

/* ===== LOGIN PAGE ===== */
.auth-page { min-height: 100vh; }

.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.auth-left {
  background: linear-gradient(145deg, #312e81, #4f46e5, #6366f1);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 50px;
  position: relative;
  overflow: hidden;
}

.auth-left::before {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  top: -100px; right: -100px;
}
.auth-left::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  bottom: -80px; left: -80px;
}

.auth-left-content { max-width: 440px; position: relative; z-index: 1; }

.brand-tag {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 28px;
}

.brand-logo-sm {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
}

.auth-left h1 {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 16px;
}

.auth-left > .auth-left-content > p {
  font-size: 15px;
  opacity: 0.8;
  margin-bottom: 40px;
}

.auth-info-grid { display: grid; gap: 14px; }

.info-card {
  display: flex;
  gap: 14px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 16px;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  transition: background 0.2s;
}
.info-card:hover { background: rgba(255,255,255,0.15); }
.info-icon { font-size: 22px; flex-shrink: 0; }
.info-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.info-card p { font-size: 13px; opacity: 0.75; }

.auth-right {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  padding: 40px 30px;
}

.login-card {
  background: var(--surface);
  padding: 40px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 400px;
  max-width: 100%;
}

.badge-soft-tag {
  display: inline-block;
  padding: 5px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.login-header h2 { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.login-header p { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

.login-form { display: flex; flex-direction: column; gap: 18px; }

.btn-login {
  padding: 12px 18px;
  font-size: 15px;
  border-radius: 10px;
  margin-top: 4px;
}




/* ===== DASHBOARD PAGE ===== */
.dashboard-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand-box {
  display: flex; align-items: center; gap: 12px;
  padding: 0 8px;
  margin-bottom: 28px;
}

.brand-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(79,70,229,0.3);
}

.brand-box h2 { font-size: 15px; font-weight: 700; line-height: 1.2; }
.brand-box p { font-size: 11px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.08em; }

/* Sidebar nav */
.side-nav {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 24px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

.side-card {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  color: white;
}
.side-card-icon { font-size: 24px; margin-bottom: 8px; }
.side-card h4 { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.side-card p { font-size: 12px; opacity: 0.85; line-height: 1.5; }

.side-rules {
  padding: 14px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid var(--border-light);
}
.side-rules h5 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 10px; }
.side-rules ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.side-rules li { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.side-rules li svg { color: var(--success); flex-shrink: 0; }

/* ===== MAIN PANEL ===== */
.main-panel { padding: 32px 28px; display: flex; flex-direction: column; gap: 20px; }

/* ===== HEADER ===== */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.page-label {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--primary);
  margin-bottom: 6px;
}

.top-header h1 { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.top-header p { font-size: 14px; color: var(--text-muted); }

.top-actions { display: flex; align-items: center; gap: 12px; padding-top: 4px; }

.session-badge {
  display: flex; align-items: center; gap: 8px;
  background: var(--success-bg);
  color: var(--success);
  padding: 7px 14px;
  border-radius: 100px;
  font-size: 12px; font-weight: 700;
  border: 1px solid rgba(16,185,129,0.2);
}

.pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

/* ===== TOOLBAR ===== */
.toolbar-card {
  background: var(--surface);
  padding: 18px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.toolbar { display: flex; align-items: flex-end; gap: 14px; }
.filter-group { flex: 1; max-width: 280px; }

/* ===== TABLE CARD ===== */
.table-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

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

.table-card-header h2 { font-size: 16px; font-weight: 700; margin-bottom: 3px; }
.table-card-header p { font-size: 13px; color: var(--text-muted); }

.table-meta { font-size: 12px; color: var(--text-soft); font-weight: 500; }

.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead { background: #f8fafc; }
th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 14px 16px;
  border-top: 1px solid var(--border-light);
  font-size: 13.5px;
  vertical-align: middle;
}

tbody tr { transition: background 0.12s; }
tbody tr:hover { background: #f8f9ff; }

.user-id { font-family: var(--mono); font-size: 12px; color: var(--text-soft); }

/* Avatar + name */
.avatar-name { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}

.name-cell { font-weight: 500; }
.email-cell { color: var(--primary); font-size: 13px; }

.group-pill {
  background: #eef2ff;
  color: var(--primary);
  border: 1px solid rgba(79,70,229,0.15);
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.joined-text { color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }

/* Role */
.role-badge {
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.role-admin { background: #fce7f3; color: #be185d; border: 1px solid rgba(190,24,93,0.2); }

.role-select {
  padding: 7px 32px 7px 10px;
  font-size: 13px;
  border-radius: 7px;
  min-width: 100px;
}

/* Save button */
.save-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--text);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
}
.save-btn:hover { background: #1e293b; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.save-btn:active { transform: none; }
.save-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.not-editable { color: var(--text-soft); font-size: 12px; font-style: italic; }

/* Table states */
.loading-row, .empty-row, .error-row {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.error-row { color: var(--danger); }

/* ===== MODAL OVERLAY ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-modal);
  animation: slideUp 0.25s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
  overflow: hidden;
}

@keyframes slideUp {
  from { transform: translateY(30px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Shake for wrong PIN */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(8px); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(3px); }
}
.shake { animation: shake 0.4s ease-out; }

/* ===== PIN MODAL ===== */
.pin-modal {
  width: 380px;
  padding: 32px;
  text-align: center;
}

.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: #f1f5f9; border: none;
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
  transition: background 0.15s;
}
.modal-close:hover { background: #e2e8f0; color: var(--text); }

.modal-icon-wrap {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  margin: 0 auto 20px;
}

.modal-header-text h3 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.modal-header-text p { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }

/* PIN dots */
.pin-dots-row {
  display: flex; justify-content: center; gap: 14px;
  margin-bottom: 20px;
}
.pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.2);
  box-shadow: 0 0 10px var(--primary-glow);
}

/* PIN input */
.pin-group { margin-bottom: 8px; }
#pinInput {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 12px;
  text-align: center;
  padding: 14px 12px;
  width: 100%;
}

.modal-actions {
  display: flex; gap: 10px; margin-top: 20px;
}
.btn-verify {
  flex: 1;
  justify-content: center;
}


/* ===== SUCCESS MODAL ===== */
.success-modal {
  width: 340px;
  padding: 40px 32px;
  text-align: center;
}

.success-anim { margin: 0 auto 20px; }

/* Animated SVG checkmark */
.checkmark {
  width: 72px; height: 72px;
}
.checkmark-circle {
  stroke: var(--success);
  stroke-width: 2;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-miterlimit: 10;
  animation: stroke 0.6s cubic-bezier(0.65,0,0.45,1) forwards;
}
.checkmark-check {
  stroke: var(--success);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: stroke 0.3s cubic-bezier(0.65,0,0.45,1) 0.5s forwards;
}
@keyframes stroke {
  100% { stroke-dashoffset: 0; }
}

.success-modal h3 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.success-message { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.success-message strong { color: var(--primary); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .dashboard-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-panel { padding: 20px 16px; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-left { display: none; }
  .login-card { width: 100%; padding: 30px 24px; }
  .auth-right { padding: 20px 16px; align-items: flex-start; padding-top: 60px; }
  .toolbar { flex-direction: column; }
  .filter-group { max-width: 100%; width: 100%; }
  .top-header { flex-direction: column; gap: 16px; }
}
