/* ============================================================
   ePASS GATEPASS MANAGEMENT SYSTEM - MOBILE-FIRST STYLESHEET
   ============================================================ */

:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --secondary: #475569;
  --dark-bg: #0f172a;
  --dark-surface: #1e293b;
  --dark-border: #334155;
  --light-bg: #f8fafc;
  --light-surface: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #f8fafc;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--light-bg);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================
   AUTHENTICATION MODAL / SCREEN
   ========================================== */
.auth-container {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top right, #1e293b, #0f172a);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
}

.auth-card {
  background: rgba(30, 41, 59, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid var(--dark-border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  width: 100%;
  max-width: 420px;
  color: var(--text-light);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@media (min-width: 640px) {
  .auth-card { padding: 40px; }
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-header img { height: 52px; margin-bottom: 12px; }
.auth-header h2 { font-size: 22px; font-weight: 700; color: #fff; }
.auth-header p { font-size: 13px; color: #94a3b8; margin-top: 4px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #cbd5e1;
}

.input-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--light-surface);
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  transition: var(--transition);
}

.input-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.auth-card .input-control {
  background: #0f172a;
  border-color: #334155;
  color: #fff;
}

.auth-card .input-control:focus { border-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  touch-action: manipulation;
}

.btn-primary { background-color: var(--primary); color: #fff; }
.btn-primary:hover { background-color: var(--primary-hover); transform: translateY(-1px); }

.btn-secondary { background-color: #e2e8f0; color: #334155; }
.btn-secondary:hover { background-color: #cbd5e1; }

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

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

.btn-block { width: 100%; }

.demo-box {
  margin-top: 20px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #94a3b8;
}
.demo-box strong { color: #f1f5f9; }

/* ==========================================
   MOBILE-FIRST APP LAYOUT
   ========================================== */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

@media (min-width: 768px) {
  .app-container { flex-direction: row; }
}

.mobile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  background: var(--dark-bg);
  color: #fff;
  padding: 0 16px;
  z-index: 1001;
}

@media (min-width: 768px) {
  .mobile-bar { display: none; }
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
}

.mobile-brand img { height: 32px; }

.mobile-toggle {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: -280px;
  width: 270px;
  background: var(--dark-bg);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  transition: left 0.3s ease;
  z-index: 999;
  box-shadow: 4px 0 20px rgba(0,0,0,0.3);
}

.sidebar.open { left: 0; }

@media (min-width: 768px) {
  .sidebar {
    position: static;
    left: 0;
    width: 260px;
    box-shadow: none;
  }
  .sidebar-backdrop { display: none; }
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--dark-border);
}

.sidebar-header img { height: 38px; }
.sidebar-header h1 { font-size: 16px; font-weight: 700; color: #fff; }
.sidebar-header span { font-size: 11px; color: #94a3b8; display: block; }

.nav-menu {
  padding: 16px 12px;
  flex: 1;

  nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item i { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--dark-border);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--dark-surface);
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: #94a3b8; text-transform: capitalize; }

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--light-bg);
}

.top-bar {
  height: 60px;
  background: var(--light-surface);
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

@media (min-width: 768px) { .top-bar { padding: 0 24px; } }
.page-title { font-size: 16px; font-weight: 700; color: var(--text-main); }
@media (min-width: 640px) { .page-title { font-size: 18px; } }

.content-body { padding: 16px; flex: 1; overflow-y: auto; }
@media (min-width: 768px) { .content-body { padding: 24px; } }

.tab-view { display: none; }
.tab-view.active { display: block; }

/* Dashboard Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 640px) {
  .metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
  }
}

.metric-card {
  background: var(--light-surface);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 640px) { .metric-card { padding: 20px; gap: 16px; } }

.metric-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

@media (min-width: 640px) { .metric-icon { width: 48px; height: 48px; font-size: 20px; } }

.metric-icon.blue { background: #e0f2fe; color: #0284c7; }
.metric-icon.green { background: #d1fae5; color: #10b981; }
.metric-icon.purple { background: #ede9fe; color: #8b5cf6; }
.metric-icon.amber { background: #fef3c7; color: #f59e0b; }

.metric-info h3 { font-size: 20px; font-weight: 700; color: var(--text-main); }
@media (min-width: 640px) { .metric-info h3 { font-size: 24px; } }
.metric-info p { font-size: 12px; color: var(--text-muted); }

.card {
  background: var(--light-surface);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  flex-wrap: wrap;
  gap: 10px;
}

.card-header h3 { font-size: 15px; font-weight: 700; color: var(--text-main); }
.card-body { padding: 16px; }
@media (min-width: 640px) { .card-body { padding: 20px; } }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
@media (min-width: 640px) { .data-table { font-size: 14px; } }
.data-table th { background: #f1f5f9; color: #475569; font-weight: 600; padding: 10px 12px; border-bottom: 1px solid #e2e8f0; white-space: nowrap; }
.data-table td { padding: 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }

.badge { display: inline-block; padding: 3px 8px; font-size: 10px; font-weight: 600; border-radius: 9999px; text-transform: uppercase; }
.badge-success { background: #d1fae5; color: #047857; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-primary { background: #e0f2fe; color: #0369a1; }

/* Form Section Badges */
.form-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #0284c7;
  background: #f0f9ff;
  padding: 6px 12px;
  border-radius: 6px;
  margin: 16px 0 12px 0;
  border-left: 3px solid #0284c7;
}

.input-control {
  width: 100%;
  height: 44px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  transition: all 0.2s ease-in-out;
}

textarea.input-control {
  height: auto;
  min-height: 60px;
}

.input-control:focus {
  outline: none;
  border-color: #0284c7;
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.14);
}

.dropzone {
  border: 2px dashed #93c5fd;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone:hover {
  border-color: #0284c7;
  background: #f0f9ff;
}

.photo-preview-box {
  width: 76px;
  height: 92px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  margin: 10px auto 0;
  overflow: hidden;
  background: #eee;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.photo-preview-box img { width: 100%; height: 100%; object-fit: cover; }

/* Mobile View Switcher (Edit Form vs Live Preview) */
.mobile-view-tabs {
  display: flex;
  gap: 8px;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 16px;
}

@media (min-width: 1100px) {
  .mobile-view-tabs {
    display: none;
  }
}

.mobile-view-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.mobile-view-btn.active {
  background: #ffffff;
  color: #0284c7;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.generator-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 1100px) {
  .generator-split {
    grid-template-columns: 440px 1fr;
  }
}

@media (max-width: 1099px) {
  .generator-split.show-form .preview-container {
    display: none !important;
  }
  .generator-split.show-preview .generator-form-card {
    display: none !important;
  }
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 480px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Sticky Mobile Action Button Bar */
.mobile-sticky-action {
  position: sticky;
  bottom: 12px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12);
  margin-top: 16px;
}

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  font-weight: 700;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  background: linear-gradient(135deg, #047857, #059669);
  transform: translateY(-1px);
}

/* Document Preview Container */
.preview-container {
  background: #334155;
  padding: 16px;
  border-radius: var(--radius-lg);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 600px;
  box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.2);
}

/* Mobile Responsive Page Wrapper Scaling */
.preview-scaler {
  transform-origin: top center;
  transition: transform 0.25s ease;
}

@media (max-width: 860px) {
  .preview-scaler {
    transform: scale(0.85);
    margin-bottom: -15%;
  }
}

@media (max-width: 640px) {
  .preview-scaler {
    transform: scale(0.68);
    margin-bottom: -32%;
  }
}

@media (max-width: 480px) {
  .preview-scaler {
    transform: scale(0.52);
    margin-bottom: -48%;
  }
}

@media (max-width: 380px) {
  .preview-scaler {
    transform: scale(0.42);
    margin-bottom: -58%;
  }
}

/* ==========================================
   EXACT SINGLE PAGE A4 DOCUMENT TEMPLATE
   ========================================== */
.page {
  width: 210mm;
  height: 297mm;
  max-height: 297mm;
  background: #fff;
  padding: 8mm 12mm;
  position: relative;
  box-shadow: 0 3px 24px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  flex-shrink: 0;
  box-sizing: border-box;
  page-break-after: avoid !important;
  page-break-inside: avoid !important;
}

.page .watermark {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 440px;
  height: 440px;
  opacity: 0.1;
  z-index: 0;
  pointer-events: none;
}
.page .watermark img { width: 100%; height: 100%; object-fit: fill !important; }

.page .content { position: relative; z-index: 2; }

/* Header */
.page .header { display: flex; align-items: center; gap: 12px; padding-bottom: 2px; }
.page .header .arms { width: 68px; height: 68px; flex-shrink: 0; }
.page .header .arms img { width: 100%; height: 100%; object-fit: contain; display: block; }
.page .header .title-block { line-height: 1.2; margin-top: 14px; }
.page .header .title-block .t1 { font-size: 18px; font-weight: 700; color: #111; }
.page .header .title-block .t2 { font-size: 18px; font-weight: 700; color: #111; }
.page .header .epass-logo { margin-left: auto; width: 105px; height: 56px; display: flex; align-items: center; justify-content: center; }
.page .header .epass-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }

.page .rule-full { border: none; border-top: 2px solid #111; margin: 4px 0 14px; }

/* Top Band */
.page .top-band { display: flex; align-items: stretch; gap: 8px; margin-top: 6px; padding-bottom: 10px; }

/* Vertical ePASS Barcode Text - Rotated Sideways Orientation (Compatible with HTML DOM & html2pdf) */
.page .vbarcode-container {
  width: 18px;
  height: 130px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-top: 10px;
}

.page .vbarcode {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #111;
  white-space: nowrap;
  writing-mode: horizontal-tb !important;
  transform: rotate(90deg);
  transform-origin: center center;
  line-height: 1;
}

.page .qr { width: 135px; height: 135px; flex-shrink: 0; margin-top: 6px; position: relative; }
.page .qr canvas, .page .qr img { width: 135px; height: 135px; display: block; object-fit: contain; }

.page .imm-text { flex: 1; display: flex; align-items: center; gap: 10px; padding-top: 2px; }
.page .imm-text .seal { width: 56px; height: 56px; flex-shrink: 0; align-self: flex-start; margin-top: 0; position: relative; left: 40px; }
.page .imm-text .seal img { width: 100%; height: 100%; object-fit: contain; }
.page .imm-text .imm-details { flex: 1; }
.page .imm-text .upper-info { text-align: center; padding-left: 45px; }
.page .imm-text .h { font-size: 12px; font-weight: 700; color: #111; letter-spacing: 0.3px; }
.page .imm-text .s { font-size: 9px; color: #111; font-weight: 700; margin-top: 1px; }
.page .imm-text .p { font-size: 8px; color: #222; margin-top: 2px; line-height: 1.25; }
.page .imm-text b, .page .imm-text #visaExpiry { font-weight: 800; color: #000; }
.page .imm-text .divider { border-top: 2px solid #111; margin: 4px 0 0; }
.page .imm-text .regulation { text-align: center; padding-right: 45px; font-size: 9.5px; color: #111; line-height: 1.3; padding-top: 3px; }

.page .imm13 { width: 56px; flex-shrink: 0; text-align: center; padding-top: 2px; }
.page .imm13 .lbl { font-size: 8.5px; font-style: italic; font-weight: 700; color: #111; }
.page .imm13 .tri { width: 50px; height: 40px; margin: 4px auto 0; position: relative; display: flex; align-items: center; justify-content: center; }
.page .imm13 .tri img { width: 100%; height: 100%; object-fit: contain; display: block; }
.page .imm13 .tri span { position: absolute; top: 65%; left: 50%; transform: translate(-50%, -50%); font-size: 13px; font-weight: normal; color: #111; z-index: 1; }

.page .sec-title { font-size: 20px; font-weight: 700; color: #111; padding-bottom: 3px; border-bottom: 2px solid #111; margin-top: 18px; margin-bottom: 12px; }

.page .body-area { position: relative; }
.page .photo-col { position: absolute; right: 0; top: 12px; width: 125px; text-align: center; }
.page .photo-box { width: 92px; height: 112px; margin: 0 auto; border: none; overflow: hidden; background: #eee; }
.page .photo-box img { width: 100%; height: 100%; object-fit: cover; }
.page .signature { width: 85px; height: 15px; margin: 8px auto -2px; }
.page .signature img { width: 100%; height: 100%; object-fit: contain; display: block; }
.page .sig-line { border-top: 1px solid #444; width: 85px; margin: 4px auto 2px; }
.page .director { font-size: 8px; color: #111; font-style: normal; }
.page .photo-col .vp-no { font-size: 10.5px; color: #111; margin-top: 4px; font-weight: normal; white-space: nowrap; }
.page .photo-col .vp-no b { font-weight: 700; }

.page .info { width: calc(100% - 135px); }
.page .row { display: flex; font-size: 13px; line-height: 1.3; padding: 2.5px 0; color: #111; font-weight: 450; }
.page .row .lab { width: 98px; flex-shrink: 0; color: #111; }
.page .row .col { width: 10px; flex-shrink: 0; }
.page .row .val { flex: 1; }
.page .gap { height: 6px; }

.page .r { color: #000000; }
.page .b { color: #000000; }
.page .bold { font-weight: 400; }

.page .mrz { margin-top: 14px; font-family: 'Inter', sans-serif; font-size: 13.5px; font-weight: 500; letter-spacing: 1px; line-height: 1.5; word-break: break-all; }
.page .mrz .l1 { color: #000000; }
.page .mrz .l2 { color: #000000; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
}

.modal-card {
  background: var(--light-surface);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header { padding: 14px 18px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; background: #f8fafc; }
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 18px; }
.modal-footer { padding: 14px 18px; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 10px; background: #f8fafc; }

/* Print Rules */
@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }
  body { background: none !important; padding: 0 !important; margin: 0 !important; }
  .mobile-bar, .app-container, .top-bar, .sidebar, .btn, .generator-split > *:first-child { display: none !important; }
  .preview-container { background: none !important; padding: 0 !important; min-height: auto !important; box-shadow: none !important; }
  .page { box-shadow: none !important; margin: 0 !important; width: 210mm !important; height: 297mm !important; max-height: 297mm !important; page-break-after: avoid !important; page-break-inside: avoid !important; }
}
