/* EDMS Scanner Pro — PWA Mobile Styles */
:root {
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --primary-light: #e0f2fe;
  --dark: #0f172a;
  --dark2: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --success: #10b981;
  --success-bg: #d1fae5;
  --error: #ef4444;
  --error-bg: #fee2e2;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --nav-h: 68px;
  --top-h: 56px;
  --footer-h: 38px;
  --radius: 16px;
  --radius-sm: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--dark);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

#app { height: 100%; }

/* ============ SPLASH ============ */
.splash {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--dark) 0%, var(--dark2) 100%);
  gap: 16px;
}
.splash-title {
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.splash-sub { color: #94a3b8; font-size: 14px; }
.splash-loader {
  width: 40px; height: 4px;
  background: var(--dark2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 24px;
}
.splash-loader::after {
  content: '';
  display: block;
  width: 40%;
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  animation: load 1.2s ease-in-out infinite;
}
@keyframes load {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ============ LOGO CIRCLE ============ */
.logo-circle {
  width: 80px; height: 80px;
  background: var(--primary);
  border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  box-shadow: 0 8px 24px rgba(14,165,233,0.4);
}
.logo-circle.small { width: 52px; height: 52px; border-radius: 14px; }
.logo-circle.tiny  { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; }

/* ============ LOGIN ============ */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--dark) 0%, var(--dark2) 60%, #0c2340 100%);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-header {
  text-align: center;
  margin-bottom: 28px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.login-header h1 { font-size: 22px; font-weight: 800; color: var(--dark); }
.login-header p  { font-size: 13px; color: var(--muted); }

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--dark2); margin-bottom: 8px;
}
.form-group input {
  width: 100%; padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px; color: var(--dark);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--primary); background: #fff; }
.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 48px; }
.pwd-eye {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  font-size: 18px; padding: 4px;
}

/* ============ BUTTONS ============ */
.btn-primary {
  width: 100%; padding: 16px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-primary:active { transform: scale(0.98); background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  width: 100%; padding: 14px;
  background: transparent; color: var(--dark);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600;
  cursor: pointer; margin-top: 12px;
}
.btn-secondary:active { background: var(--bg); }

.btn-refresh {
  display: block; width: 100%; padding: 14px;
  background: var(--bg); color: var(--primary);
  border: 1.5px solid var(--primary-light);
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600;
  cursor: pointer; margin-top: 16px; text-align: center;
}

.sync-now-btn {
  background: var(--primary); color: white;
  border: none; border-radius: 6px;
  padding: 6px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; margin-left: 8px;
}

.error-msg {
  color: var(--error); font-size: 13px;
  background: var(--error-bg); border-radius: 8px;
  padding: 10px 14px; margin-top: 12px; text-align: center;
}
.hidden { display: none !important; }

/* ============ APP SHELL ============ */
.app-shell {
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}

/* Topbar */
.topbar {
  height: var(--top-h);
  background: var(--dark);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 10;
}
.topbar-left  { display: flex; align-items: center; gap: 10px; }
.topbar-title { color: #fff; font-size: 16px; font-weight: 700; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.online-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: #94a3b8;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.status-dot.online  { background: var(--success); box-shadow: 0 0 0 2px rgba(16,185,129,0.3); }
.status-dot.offline { background: var(--error);   box-shadow: 0 0 0 2px rgba(239,68,68,0.3); }

.btn-logout {
  background: rgba(255,255,255,0.1); color: #fff;
  border: none; border-radius: 8px;
  width: 36px; height: 36px; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* Main content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-h) + var(--footer-h));
  -webkit-overflow-scrolling: touch;
}

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: var(--footer-h); left: 0; right: 0;
  height: var(--nav-h);
  background: #fff;
  border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(3, 1fr);
  z-index: 100;
}
.nav-btn {
  background: none; border: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-size: 11px; font-weight: 600;
  color: var(--muted); cursor: pointer;
  padding: 8px 4px;
  position: relative;
  transition: color 0.2s;
}
.nav-btn.active { color: var(--primary); }
.nav-btn.active svg { stroke: var(--primary); }
.nav-btn svg { stroke: var(--muted); }
.nav-btn.active::before {
  content: '';
  position: absolute; top: 0; left: 20%; right: 20%;
  height: 3px; background: var(--primary); border-radius: 0 0 4px 4px;
}
.sync-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--error); color: #fff;
  width: 16px; height: 16px; border-radius: 50%;
  font-size: 10px; font-weight: 700;
  position: absolute; top: 8px; right: 18px;
}

/* Footer signature */
.footer-sig {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--footer-h);
  background: var(--dark);
  color: #64748b;
  font-size: 11px; text-align: center;
  display: flex; align-items: center; justify-content: center;
  z-index: 101;
}
.footer-sig strong { color: var(--primary); }

/* ============ SCANNER HOME ============ */
.scanner-home { padding: 20px 16px; }

.datetime-card {
  background: var(--dark);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  text-align: center;
}
.datetime-card .date {
  color: #94a3b8; font-size: 13px;
  text-transform: capitalize; margin-bottom: 4px;
}
.datetime-card .time {
  color: #fff; font-size: 40px; font-weight: 800;
  letter-spacing: -1px; line-height: 1;
}
.online-indicator {
  margin-top: 12px; font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: 20px; display: inline-block;
}
.online-indicator.online  { background: rgba(16,185,129,0.2); color: #34d399; }
.online-indicator.offline { background: rgba(239,68,68,0.2);  color: #f87171; }

.scan-btn {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 28px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(14,165,233,0.35);
  transition: transform 0.1s, box-shadow 0.2s;
}
.scan-btn:active { transform: scale(0.98); box-shadow: 0 4px 12px rgba(14,165,233,0.2); }
.scan-btn svg { stroke: rgba(255,255,255,0.9); }
.scan-btn span { font-size: 20px; font-weight: 800; }
.scan-btn small { font-size: 13px; opacity: 0.75; }

.pending-banner {
  background: var(--warning-bg); color: #92400e;
  border: 1px solid #fcd34d; border-radius: var(--radius-sm);
  padding: 14px 16px; margin-top: 16px;
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
}

/* ============ SCANNER ACTIVE ============ */
.scanner-active { padding: 16px; }
.scanner-header { text-align: center; margin-bottom: 16px; }
.scanner-header h2 { font-size: 20px; font-weight: 700; color: var(--dark); }
.scanner-header p  { font-size: 13px; color: var(--muted); margin-top: 4px; }

.qr-reader { border-radius: var(--radius); overflow: hidden; background: #000; }
#qr-reader video { border-radius: var(--radius); }
#qr-reader { border: none !important; }
#qr-reader__dashboard_section_csr button {
  background: var(--primary) !important;
  color: white !important;
  border-radius: 8px !important;
  padding: 10px 20px !important;
  font-weight: 600 !important;
}

/* ============ SCAN RESULT ============ */
.scan-result {
  padding: 24px 16px;
  text-align: center;
}
.scan-result.success .result-icon { font-size: 64px; margin-bottom: 12px; }
.scan-result.error   .result-icon { font-size: 64px; margin-bottom: 12px; }
.scan-result h2 { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.scan-result.success h2 { color: var(--success); }
.scan-result.error h2   { color: var(--error); }
.scan-result p { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

.offline-note {
  background: var(--warning-bg); color: #92400e;
  border-radius: 8px; padding: 8px 14px;
  font-size: 13px; font-weight: 600;
  display: inline-block; margin-bottom: 16px;
}

.result-card {
  background: var(--bg); border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 4px 0; margin: 16px 0; text-align: left;
}
.result-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.result-row:last-child { border-bottom: none; }
.result-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.result-value { font-size: 15px; font-weight: 700; color: var(--dark); }
.mono { font-family: 'Courier New', monospace; }

/* ============ HISTORY ============ */
.history-page { padding: 16px; }
.queue-page   { padding: 16px; }

.page-header { margin-bottom: 16px; }
.page-header h2 { font-size: 20px; font-weight: 800; color: var(--dark); }
.page-header p  { font-size: 13px; color: var(--muted); margin-top: 4px; }

.history-item {
  background: var(--card); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 14px 16px; margin-bottom: 8px;
}
.history-item.unsynced { border-left: 3px solid var(--warning); }
.history-main {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.history-name { font-weight: 700; font-size: 15px; color: var(--dark); }
.history-time { font-size: 16px; font-weight: 800; color: var(--primary); }
.history-sub  { display: flex; align-items: center; gap: 8px; }
.history-mat  { font-size: 12px; color: var(--muted); }
.unsynced-tag {
  background: var(--warning-bg); color: #92400e;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px;
}

.empty-state { text-align: center; padding: 48px 24px; }
.empty-icon  { font-size: 48px; margin-bottom: 12px; }
.empty-state p { color: var(--muted); font-size: 15px; }

/* ============ QUEUE PAGE ============ */
.queue-status {
  display: flex; align-items: center; gap: 14px;
  padding: 18px; border-radius: var(--radius);
  margin-bottom: 16px;
}
.queue-status.online  { background: #d1fae5; border: 1px solid #6ee7b7; }
.queue-status.offline { background: var(--error-bg); border: 1px solid #fca5a5; }
.queue-status-icon { font-size: 32px; }
.queue-status strong { font-size: 16px; font-weight: 700; color: var(--dark); }
.queue-status p { font-size: 13px; color: var(--muted); margin-top: 2px; }

.queue-info {
  background: var(--bg); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 16px; font-size: 14px; color: var(--muted);
  text-align: center; margin-top: 12px;
}

/* ============ TOAST ============ */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + var(--footer-h) + 12px);
  left: 16px; right: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  text-align: center;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #065f46; color: #d1fae5; }
.toast.error   { background: #7f1d1d; color: #fee2e2; }
.toast.warning { background: #78350f; color: #fef3c7; }
.toast.offline { background: var(--dark2); color: #94a3b8; }
.toast.info    { background: var(--dark2); color: #e2e8f0; }

/* ============ LOGIN FOOTER ============ */
.login-card .footer-sig {
  position: static;
  background: none;
  color: #94a3b8;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
  height: auto;
  font-size: 11px;
  line-height: 1.6;
}
.login-card .footer-sig strong { color: var(--primary); }
