/* =========================================================
   CPMS / URPTS - Modern Responsive Stylesheet
   ========================================================= */
:root {
  --primary: #004b87;
  --primary-dark: #003366;
  --primary-light: #0066b3;
  --accent: #f37021;
  --success: #138808;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #cbd5e1;
  --radius: 4px;
  --radius-sm: 2px;
  --shadow: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-lg: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

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

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--primary-dark), var(--primary)); /* Default Blue */
  color: #e0f2fe;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform .25s ease;
}
/* Role-Specific Sidebar Colors */
.sidebar-cltc { background: linear-gradient(180deg, #003366, #004b87); } /* Blue */
.sidebar-ulb  { background: linear-gradient(180deg, #064e3b, #047857); } /* Green */
.sidebar-sltc { background: linear-gradient(180deg, #4c1d95, #6d28d9); } /* Purple */
.sidebar-ouhm { background: linear-gradient(180deg, #14532d, #15803d); } /* Forest Green */
.sidebar-ced  { background: linear-gradient(180deg, #0f172a, #1e293b); } /* Slate/Dark */
.sidebar .brand {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar .brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px rgba(249,115,22,.25);
}
.sidebar nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: #cbe7f3; font-size: .93rem; font-weight: 500;
  margin-bottom: 3px; transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar .user-box {
  padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.12);
  font-size: .82rem;
}
.sidebar .user-box .name { font-weight: 600; color: #fff; }
.sidebar .user-box .role { color: #93c5fd; }
.sidebar .logout-btn {
  display: block; margin-top: 10px; text-align: center;
  padding: 8px; border-radius: var(--radius-sm);
  background: #ef4444; color: #fff; font-size: .8rem;
  font-weight: 600; transition: background 0.2s ease;
}
.sidebar .logout-btn:hover { background: #dc2626; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
  box-shadow: 0 4px 20px -2px rgba(0,0,0,0.03);
}
.topbar h1 {
  font-size: 1.4rem;
  margin: 0;
  font-weight: 800;
  background: linear-gradient(90deg, var(--primary-dark), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}
.topbar .right-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: linear-gradient(135deg, #ffffff, #f1f5f9);
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.8), 0 2px 4px rgba(0,0,0,0.02);
}
.topbar .menu-toggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--primary); }
.content { padding: 22px 24px 60px; flex: 1; }

/* ---------- Cards / Grid ---------- */
.grid { display: grid; gap: 18px; }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border: 1px solid var(--border);
}
.card h3 { margin: 0 0 14px; font-size: 1rem; font-weight: 700; }

.stat-card { display: flex; align-items: center; gap: 14px; }
a.card.stat-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
}
a.card.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}
.stat-card .icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-card .icon.blue { background: #e0f2fe; color: var(--primary); }
.stat-card .icon.green { background: #dcfce7; color: var(--success); }
.stat-card .icon.orange { background: #ffedd5; color: var(--accent); }
.stat-card .icon.red { background: #fee2e2; color: var(--danger); }
.stat-card .value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-card .label { color: var(--text-muted); font-size: .82rem; margin-top: 2px; }

.stat-card-sm { padding: 12px 16px; gap: 12px; }
.stat-card-sm .icon { width: 40px; height: 40px; font-size: 1.2rem; border-radius: 10px; }
.stat-card-sm .value { font-size: 1.3rem; }
.stat-card-sm .label { font-size: 0.75rem; margin-top: 1px; }
/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: none; cursor: pointer; font-size: .9rem; font-weight: 600;
  transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
input, select, textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: .92rem; background: #fff; color: var(--text);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(8,145,178,.15); }
.input-hint { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 600px; }
thead { background: #f8fafc; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-muted { background: #f1f5f9; color: #475569; }

/* ---------- Login Page Redesign ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f2eef6 0%, #e2e8f8 50%, #d3daf3 100%);
  padding: 40px 20px;
  font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
}
.login-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
}
.login-card-new {
  background: #f4f3f9;
  border-radius: 36px;
  padding: 45px 45px 35px 45px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.4);
  position: relative;
}
.login-logo-container {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
}
.login-logo {
  max-height: 85px;
  max-width: 100%;
  object-fit: contain;
}
.input-group-new {
  display: flex;
  align-items: center;
  background: #2e435a;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
  border: 1px solid rgba(255, 255, 255, 0.05);
  height: 56px;
}
.input-icon-box {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #203042;
  color: #fff;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}
.input-icon-box svg {
  width: 20px;
  height: 20px;
  opacity: 0.9;
}
.input-field-new {
  flex: 1;
  background: transparent;
  border: none !important;
  color: #ffffff !important;
  padding: 0 18px;
  font-size: 1.05rem;
  height: 100%;
  font-family: inherit;
}
.input-field-new::placeholder {
  color: #8c9ba5;
  opacity: 1;
}
.input-field-new:focus {
  outline: none;
  box-shadow: none;
  border-color: transparent;
}
/* For Chrome autofill color overrides */
.input-field-new:-webkit-autofill,
.input-field-new:-webkit-autofill:hover, 
.input-field-new:-webkit-autofill:focus {
  -webkit-text-fill-color: #ffffff !important;
  -webkit-box-shadow: 0 0 0px 1000px #2e435a inset !important;
  transition: background-color 5000s ease-in-out 0s;
}
.password-toggle {
  background: transparent;
  border: none;
  color: #8c9ba5;
  cursor: pointer;
  padding: 0 18px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}
.password-toggle:hover {
  color: #ffffff;
}
.password-toggle svg {
  width: 20px;
  height: 20px;
}
.remember-forgot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  margin-bottom: 30px;
}
.remember-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  color: #1e293b;
  font-size: 0.92rem;
}
.remember-checkbox-label input {
  display: none;
}
.checkbox-custom {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #1e293b;
  display: inline-block;
  position: relative;
  transition: background 0.2s;
}
.remember-checkbox-label input:checked + .checkbox-custom::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 4px;
  height: 9px;
  border: solid white;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.forgot-password-link {
  color: #1e293b;
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
}
.forgot-password-link:hover {
  text-decoration: underline;
}
.secured-text {
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: #8a96a3;
  letter-spacing: 0.1em;
  margin-bottom: 25px;
}
.login-btn-container {
  display: flex;
  justify-content: center;
  margin-bottom: -62px;
}
.btn-login {
  background: linear-gradient(to bottom, #ffffff, #e3e6eb);
  color: #000000;
  font-weight: 700;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 18px;
  padding: 15px 75px;
  border: 1px solid #d3d7de;
  box-shadow: 0 10px 20px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, background 0.2s;
  font-family: inherit;
}
.btn-login:hover {
  background: linear-gradient(to bottom, #ffffff, #dcdfe6);
  box-shadow: 0 12px 24px rgba(0,0,0,0.15), 0 4px 6px rgba(0,0,0,0.08);
}
.btn-login:active {
  transform: scale(0.98);
}
.info-box-new {
  background: #e6e4f3;
  border: 1px solid #d8d4ec;
  border-radius: 20px;
  padding: 18px 22px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 35px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}
.info-icon {
  color: #1e293b;
  flex-shrink: 0;
  margin-top: 2px;
}
.info-icon svg {
  width: 20px;
  height: 20px;
}
.info-text {
  font-size: 0.92rem;
  color: #2e354f;
  line-height: 1.45;
}
.info-text strong {
  font-weight: 700;
}
.login-footer-new {
  text-align: center;
  font-size: 0.85rem;
  color: #7d899c;
  margin-top: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: none; align-items: center; justify-content: center; z-index: 200; padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: #fff; border-radius: var(--radius); padding: 26px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-box h3 { margin-top: 0; }
.modal-close { float: right; cursor: pointer; font-size: 1.3rem; color: var(--text-muted); line-height: 1; }

/* ---------- Face capture ---------- */
.face-wrap { position: relative; width: 100%; max-width: 320px; margin: 0 auto; border-radius: var(--radius); overflow: hidden; background: #000; }
.face-wrap video, .face-wrap canvas { width: 100%; display: block; }
.face-status { text-align: center; font-size: .85rem; margin-top: 10px; font-weight: 600; }
.face-status.ok { color: var(--success); }
.face-status.fail { color: var(--danger); }

/* Futuristic Face Scan HUD Overlay */
.face-scan-hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
  font-family: 'Courier New', Courier, monospace;
  --hud-color: #00f0ff;
  --hud-glow: rgba(0, 240, 255, 0.4);
  transition: all 0.3s ease;
}

.face-scan-hud.success {
  --hud-color: #00ff66;
  --hud-glow: rgba(0, 255, 102, 0.4);
}

.face-scan-hud.fail {
  --hud-color: #ff003c;
  --hud-glow: rgba(255, 0, 60, 0.4);
}

/* Corner Brackets */
.hud-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--hud-color);
  transition: border-color 0.3s ease;
  filter: drop-shadow(0 0 4px var(--hud-glow));
}

.hud-corner.top-left {
  top: 20px;
  left: 20px;
  border-right: none;
  border-bottom: none;
}

.hud-corner.top-right {
  top: 20px;
  right: 20px;
  border-left: none;
  border-bottom: none;
}

.hud-corner.bottom-left {
  bottom: 20px;
  left: 20px;
  border-right: none;
  border-top: none;
}

.hud-corner.bottom-right {
  bottom: 20px;
  right: 20px;
  border-left: none;
  border-top: none;
}

/* Scanning Line */
.hud-scan-line {
  position: absolute;
  left: 10px;
  right: 10px;
  height: 3px;
  background: linear-gradient(to right, transparent, var(--hud-color), transparent);
  box-shadow: 0 0 10px 2px var(--hud-color);
  animation: scan-animation 2.5s ease-in-out infinite;
  opacity: 0.8;
}

@keyframes scan-animation {
  0%, 100% { top: 15%; }
  50% { top: 85%; }
}

/* Target Reticle */
.hud-target-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 150px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hud-ring {
  border-radius: 50%;
  position: absolute;
  transition: border-color 0.3s ease;
}

.hud-ring.ring-outer {
  width: 100%;
  height: 100%;
  border: 1px dashed var(--hud-color);
  opacity: 0.35;
  animation: rotate-outer 25s linear infinite;
}

.hud-ring.ring-inner {
  width: 70%;
  height: 70%;
  border: 1.5px solid var(--hud-color);
  opacity: 0.6;
  filter: drop-shadow(0 0 3px var(--hud-glow));
  animation: pulse-inner 2s ease-in-out infinite;
}

@keyframes rotate-outer {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse-inner {
  0%, 100% { transform: scale(0.95); opacity: 0.45; }
  50% { transform: scale(1.05); opacity: 0.75; }
}

/* HUD details / telemetry */
.hud-details {
  position: absolute;
  bottom: 18px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  font-weight: bold;
  color: var(--hud-color);
  text-shadow: 0 0 3px var(--hud-glow);
  letter-spacing: 0.08em;
  transition: color 0.3s ease;
}

.hud-data-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-label {
  opacity: 0.6;
}

.hud-value {
  font-weight: 800;
}

/* Vignette and grid backgrounds for realism */
.hud-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, transparent 40%, rgba(0, 0, 0, 0.5) 100%);
  pointer-events: none;
}

.hud-grid-bg {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(0, 240, 255, 0.015) 1px, transparent 1px), 
    linear-gradient(90deg, rgba(0, 240, 255, 0.015) 1px, transparent 1px);
  background-size: 16px 16px;
  background-position: center;
  pointer-events: none;
  opacity: 0.5;
}


/* ---------- Timer ---------- */
.timer-display { font-size: 2.2rem; font-weight: 800; color: var(--primary); letter-spacing: .03em; }

/* ---------- Toast ---------- */
#toast-container { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: .85rem; min-width: 220px; animation: slideIn .25s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Map ---------- */
#map-canvas { width: 100%; height: 420px; border-radius: var(--radius); border: 1px solid var(--border); }

@keyframes pulse-yellow {
  0% { transform: scale(0.85); box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.8); }
  70% { transform: scale(1); box-shadow: 0 0 0 14px rgba(234, 179, 8, 0); }
  100% { transform: scale(0.85); box-shadow: 0 0 0 0 rgba(234, 179, 8, 0); }
}
.blinking-yellow-marker {
  background-color: #facc15 !important;
  border: 3px solid #ffffff !important;
  border-radius: 50% !important;
  width: 22px !important;
  height: 22px !important;
  animation: pulse-yellow 1.5s infinite !important;
  box-shadow: 0px 0px 4px rgba(0,0,0,0.5);
  margin-top: -11px; /* Center alignment fallback */
  margin-left: -11px;
}

/* ---------- Utility ---------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-10 { gap: 10px; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar .menu-toggle { display: block; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .login-card { padding: 28px 22px; }
  
  /* Mobile responsive login card spacing */
  .login-card-new { padding: 32px 28px 24px 28px; border-radius: 28px; }
  .btn-login { padding: 12px 50px; font-size: 1rem; }
  .login-btn-container { margin-bottom: -50px; }
}
@media (max-width: 480px) {
  .login-card-new { padding: 24px 20px 16px 20px; border-radius: 22px; }
  .btn-login { padding: 11px 40px; font-size: 0.95rem; }
  .login-btn-container { margin-bottom: -43px; }
  .input-group-new { height: 50px; margin-bottom: 14px; }
  .input-icon-box { width: 48px; height: 50px; }
  .input-field-new { padding: 0 14px; font-size: 0.95rem; }
  .password-toggle { padding: 0 14px; }
  .info-box-new { padding: 14px 16px; gap: 10px; margin-top: 25px; }
  .info-text { font-size: 0.85rem; }
}
