/* =========================================================
   Passport & Visa Management Panel — Design System
   ========================================================= */

:root {
  --color-primary: #1c3d5a;
  --color-primary-light: #2d5a80;
  --color-accent: #c9a15a;
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-border: #e3e7ee;
  --color-text: #1f2733;
  --color-text-muted: #6b7684;
  --color-success: #1e8e5a;
  --color-warning: #b6791f;
  --color-danger: #c0392b;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
  --sidebar-width: 250px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  font-size: 14.5px;
}

/* ---------------- App Shell ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-primary);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand i { color: var(--color-accent); font-size: 1.3rem; }

.sidebar-nav { display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 8px;
  color: rgba(255,255,255,0.82);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav a.active { background: var(--color-accent); color: #1c1c1c; }
.sidebar-nav a.text-danger { color: #f2a9a0 !important; margin-top: auto; }
.sidebar-nav a.text-danger:hover { background: rgba(192,57,43,0.2); color: #fff !important; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-size: 1.15rem; font-weight: 700; margin: 0; flex: 1; color: var(--color-primary); }
.topbar-user { display: flex; align-items: center; gap: 8px; color: var(--color-text-muted); font-weight: 500; }
.topbar-user i { font-size: 1.4rem; }

.content-area { padding: 28px; flex: 1; }

/* ---------------- Cards ---------------- */
.card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-body { padding: 22px; }

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  color: #fff;
  flex-shrink: 0;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; color: var(--color-primary); }
.stat-label { color: var(--color-text-muted); font-size: 0.85rem; font-weight: 500; }

/* ---------------- Forms ---------------- */
.form-label { font-weight: 600; font-size: 0.85rem; color: var(--color-text); }
.form-control, .form-select {
  border-radius: 8px;
  border: 1px solid var(--color-border);
  padding: 9px 12px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(45,90,128,0.12);
}
.section-title {
  font-weight: 700;
  color: var(--color-primary);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 28px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border);
}
.section-title:first-child { margin-top: 0; }

.photo-preview {
  width: 130px; height: 160px;
  border-radius: 8px;
  border: 2px dashed var(--color-border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: #f8f9fb;
  color: var(--color-text-muted);
  font-size: 2rem;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------- Buttons ---------------- */
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-light); border-color: var(--color-primary-light); }
.btn-outline-primary { color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline-primary:hover { background: var(--color-primary); border-color: var(--color-primary); }

/* ---------------- Table ---------------- */
.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.records-table { margin: 0; width: 100%; }
table.records-table thead th {
  background: #f8f9fb;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  border-bottom: 1px solid var(--color-border);
  padding: 12px 14px;
  white-space: nowrap;
}
table.records-table tbody td {
  padding: 10px 14px;
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border);
}
table.records-table tbody tr:hover { background: #fafbfc; }
.record-photo-thumb {
  width: 40px; height: 40px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--color-border);
  background: #f0f2f5;
}
.badge-status { font-weight: 600; font-size: 0.75rem; padding: 5px 10px; border-radius: 20px; }

.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .search-box { position: relative; flex: 1; min-width: 240px; }
.toolbar .search-box i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--color-text-muted);
}
.toolbar .search-box input { padding-left: 38px; }

.pagination-wrap {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; flex-wrap: wrap; gap: 10px;
  border-top: 1px solid var(--color-border);
}

/* ---------------- Login ---------------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--color-primary) 0%, #10253b 100%);
  padding: 20px;
}
.auth-card {
  background: var(--color-surface);
  border-radius: 14px;
  padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand i { font-size: 2.4rem; color: var(--color-primary); }
.auth-brand h2 { font-size: 1.2rem; font-weight: 700; margin: 10px 0 2px; color: var(--color-primary); }
.auth-brand p { color: var(--color-text-muted); font-size: 0.85rem; margin: 0; }

/* ---------------- Printable Record ---------------- */
.print-sheet {
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 36px;
}
.print-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 3px solid var(--color-primary);
  padding-bottom: 16px; margin-bottom: 24px;
}
.print-header h2 { color: var(--color-primary); font-weight: 700; margin: 0; }
.print-header .subtitle { color: var(--color-text-muted); font-size: 0.85rem; }
.print-photo { width: 130px; height: 160px; object-fit: cover; border-radius: 6px; border: 1px solid var(--color-border); }
.print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 28px; }
.print-field label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); font-weight: 700; margin-bottom: 2px; }
.print-field .val { font-size: 0.98rem; font-weight: 600; color: var(--color-text); }
.print-qr { text-align: center; }
.print-qr img { width: 140px; height: 140px; }

/* ---------------- A4 Fixed-Layout Print Template ---------------- */
/* Proportions measured from the approved mockup: 5 stacked rows,
   row 3 split into two columns. All sizes are in mm so the printed
   page matches exactly regardless of screen zoom. */
.a4-template {
  width: 220mm;
  height: 297mm;
  margin: 0 auto;
  background: #fff;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border); /* visible on screen only, see @media print */
}
.tpl-row { box-sizing: border-box; }
.tpl-row:last-child { border-bottom: none; }

.tpl-row-1 { height: 51.1mm; }
.tpl-row-2 { height: 39.3mm; }
.tpl-row-3 { height: 137.5mm; display: flex; }
.tpl-row-4 { height: 51.1mm; }
.tpl-row-5 { height: 17.8mm; }

.tpl-col { box-sizing: border-box; height: 100%; }
.tpl-col-left { width: 107.2mm; }
.tpl-col-right { width: 102.8mm; }

.tpl-img-box {
  width: 100%; height: 100%;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #f3f4f6;
}
.tpl-img-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tpl-img-box .tpl-img-empty { color: #9aa4b2; font-size: 0.8rem; }

.tpl-blank { width: 100%; height: 100%; }

/* ---- Row 2: passport photo (left) + reference number & QR (right) ---- */
.tpl-row2-content {
  width: 100%; height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 6mm 8mm;
  box-sizing: border-box;
}
.tpl-passport-photo {
  width: 30mm;
  height: 38.6mm; /* standard 35x45mm passport photo ratio, scaled to fit row height */
  flex-shrink: 0;
  overflow: hidden;
  background: #f3f4f6;
  border: 1px solid var(--color-border);
}
.tpl-passport-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.tpl-ref-block { text-align: right; }
.tpl-ref-number { font-family: 'Times New Roman', Times, serif; font-size: 1.05rem; color: #1f2733; margin-bottom: 4mm; }
.tpl-ref-qr { width: 28mm; height: 28mm; }

@media print {
  body { background: #fff !important; }
  .tpl-img-box, .tpl-blank { background: #fff !important; }
  .no-print { display: none !important; }
  .print-sheet { border: none; box-shadow: none; padding: 0; max-width: 100%; }
  .content-area { padding: 0 !important; }
  .sidebar, .topbar { display: none !important; }
  .a4-template { border: none; }
  .tpl-row, .tpl-col-left { border-color: transparent; } /* hide guide lines when actually printing */
  @page { size: A4; margin: 0; }
}


/* ---------------- Responsive ---------------- */
@media (max-width: 992px) {
  .sidebar {
    position: fixed; left: -260px; top: 0; z-index: 1000;
    transition: left 0.2s ease;
  }
  .sidebar.open { left: 0; }
  .content-area { padding: 18px; }
}