/* ============================================================
   Immigration CRM - Design System
   Style: Business Professional / Corporate
   Palette: Navy + Steel + Warm Neutrals
   Responsive: Mobile-first with 4 breakpoints
   Breakpoints: 480px / 768px / 1024px / 1280px
   ============================================================ */

/* --- CSS Variables --- */
:root {
  /* Primary palette */
  --navy-900:  #0C1B2E;
  --navy-800:  #14263F;
  --navy-700:  #1B3355;
  --navy-600:  #23406A;
  --navy-500:  #2E5490;

  /* Steel blue */
  --steel-600: #3D5A80;
  --steel-500: #4A6FA5;
  --steel-400: #5E85B8;
  --steel-300: #8AAED0;
  --steel-200: #B5CDE3;
  --steel-100: #DAE6F0;

  /* Accent - Gold for premium feel */
  --gold-600:  #A67C00;
  --gold-500:  #C49A1B;
  --gold-400:  #D4AD3A;
  --gold-300:  #E5C55E;
  --gold-100:  #FBF2D0;

  /* Neutral */
  --gray-900:  #1A1A1A;
  --gray-800:  #2D2D2D;
  --gray-700:  #404040;
  --gray-600:  #555555;
  --gray-500:  #6B6B6B;
  --gray-400:  #8C8C8C;
  --gray-300:  #ABABAB;
  --gray-200:  #D0D0D0;
  --gray-100:  #E8E8E8;
  --gray-50:   #F5F5F5;

  /* Backgrounds */
  --bg-body:    #F0F2F5;
  --bg-card:    #FFFFFF;
  --bg-sidebar: var(--navy-900);
  --bg-header:  #FFFFFF;
  --bg-hover:   #F7F8FA;
  --bg-active:  #EEF2F8;

  /* Status colors */
  --status-collecting:      #3D5A80;
  --status-lawyer-review:   #6B4FA0;
  --status-hague-translate: #2E7D8C;
  --status-submitted:       #A67C00;
  --status-supplementing:   #C45500;
  --status-resubmitted:     #B86E00;
  --status-approved:        #1B7A3D;
  --status-rejected:        #B91C1C;
  --status-pending:         #6B6B6B;

  /* Review status */
  --review-pending:  #A67C00;
  --review-approved: #1B7A3D;
  --review-rejected: #B91C1C;

  /* Typography */
  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono:  "SF Mono", "Cascadia Code", "Consolas", monospace;

  /* Spacing — responsive */
  --sidebar-w:  240px;
  --header-h:   56px;
  --bottom-nav-h: 60px;
  --radius-sm:  4px;
  --radius-md:  6px;
  --radius-lg:  8px;
  --radius-xl:  12px;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:  0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg:  0 4px 16px rgba(0,0,0,0.1);
  --shadow-xl:  0 8px 32px rgba(0,0,0,0.12);

  /* Transitions */
  --transition: 0.15s ease;
  --transition-slow: 0.25s ease;

  /* Safe area for notched phones */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  /* Prevent pull-to-refresh on mobile */
  overscroll-behavior-y: contain;
}

body {
  font-family: var(--font-sans);
  color: var(--gray-800);
  background: var(--bg-body);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport height for mobile */
}

a { color: var(--steel-500); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--navy-500); }

img { max-width: 100%; display: block; }

/* --- Layout: Sidebar + Main --- */
.layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  color: #FFFFFF;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.sidebar-brand {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--gold-500);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--navy-900);
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.sidebar-brand .brand-sub {
  font-size: 11px;
  color: var(--steel-300);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-nav .nav-group {
  padding: 8px 24px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--steel-400);
  font-weight: 600;
}

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  color: var(--steel-200);
  font-size: 13px;
  font-weight: 400;
  transition: all var(--transition);
  cursor: pointer;
  border-left: 3px solid transparent;
  /* Touch-friendly minimum height */
  min-height: 44px;
}

.sidebar-nav .nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: #FFFFFF;
}

.sidebar-nav .nav-item.active {
  background: rgba(255,255,255,0.08);
  color: #FFFFFF;
  border-left-color: var(--gold-500);
  font-weight: 500;
}

.sidebar-nav .nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 14px;
  opacity: 0.7;
  flex-shrink: 0;
}

.sidebar-nav .nav-item.active .nav-icon {
  opacity: 1;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  color: var(--steel-300);
}

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-footer .user-avatar {
  width: 32px;
  height: 32px;
  background: var(--steel-600);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  color: #FFFFFF;
  flex-shrink: 0;
}

.sidebar-footer .user-name {
  font-weight: 500;
  color: #FFFFFF;
}

.sidebar-footer .user-role {
  font-size: 11px;
  color: var(--steel-300);
}

/* Main content area */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Header */
.header {
  height: var(--header-h);
  background: var(--bg-header);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0; /* Allow truncation */
}

.header-left .page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray-700);
  padding: 6px;
  border-radius: var(--radius-md);
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.mobile-menu-btn:active {
  background: var(--gray-100);
}

/* Content */
.content {
  flex: 1;
  padding: 20px 24px;
  padding-bottom: calc(20px + var(--safe-bottom));
}

/* --- Login Page --- */
.login-wrapper {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-900);
  position: relative;
  overflow: hidden;
  padding: 16px;
}

.login-wrapper::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -15%;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: rgba(62, 90, 128, 0.15);
  pointer-events: none;
}

.login-wrapper::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(196, 154, 27, 0.06);
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 40px 32px;
  position: relative;
  z-index: 1;
}

.login-card .login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-card .login-logo .logo-mark {
  width: 52px;
  height: 52px;
  background: var(--gold-500);
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
  color: var(--navy-900);
  margin-bottom: 14px;
}

.login-card .login-logo h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-900);
}

.login-card .login-logo p {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* --- Typography --- */
h1, h2, h3, h4 { font-weight: 600; color: var(--gray-900); line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

.text-muted { color: var(--gray-500); }
.text-small { font-size: 12px; }
.text-right { text-align: right; }

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 48px;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* --- Stat Cards (Dashboard) --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-100);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat-card .stat-label {
  font-size: 11px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}

.stat-card .stat-sub {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

.stat-card .stat-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.stat-card .stat-icon.icon-blue { background: var(--steel-100); color: var(--steel-600); }
.stat-card .stat-icon.icon-green { background: #D4EDDA; color: #1B7A3D; }
.stat-card .stat-icon.icon-amber { background: var(--gold-100); color: var(--gold-600); }
.stat-card .stat-icon.icon-red { background: #F8D7DA; color: #B91C1C; }

/* --- Forms --- */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group label .required {
  color: #B91C1C;
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 14px; /* Prevents iOS zoom on focus */
  font-family: var(--font-sans);
  color: var(--gray-800);
  background: #FFFFFF;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  min-height: 44px; /* Touch-friendly */
  -webkit-appearance: none;
}

.form-control:focus {
  border-color: var(--steel-500);
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.12);
}

.form-control::placeholder {
  color: var(--gray-300);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B6B6B' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

.form-hint {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

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

.form-error {
  font-size: 12px;
  color: #B91C1C;
  margin-top: 4px;
}

/* File upload */
.file-upload-area {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.file-upload-area:hover {
  border-color: var(--steel-400);
  background: var(--bg-active);
}

.file-upload-area .upload-icon {
  font-size: 28px;
  color: var(--gray-300);
  margin-bottom: 8px;
}

.file-upload-area .upload-text {
  font-size: 13px;
  color: var(--gray-500);
}

.file-upload-area .upload-hint {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
  min-height: 36px; /* Touch-friendly */
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--navy-600);
  color: #FFFFFF;
  border-color: var(--navy-600);
}
.btn-primary:hover {
  background: var(--navy-700);
  border-color: var(--navy-700);
  color: #FFFFFF;
}

.btn-secondary {
  background: #FFFFFF;
  color: var(--gray-700);
  border-color: var(--gray-200);
}
.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.btn-success {
  background: #1B7A3D;
  color: #FFFFFF;
  border-color: #1B7A3D;
}
.btn-success:hover {
  background: #15632F;
  border-color: #15632F;
  color: #FFFFFF;
}

.btn-danger {
  background: #FFFFFF;
  color: #B91C1C;
  border-color: #F5C6CB;
}
.btn-danger:hover {
  background: #FEF2F2;
  border-color: #F87171;
}

.btn-warning {
  background: var(--gold-500);
  color: #FFFFFF;
  border-color: var(--gold-500);
}
.btn-warning:hover {
  background: var(--gold-600);
  border-color: var(--gold-600);
  color: #FFFFFF;
}

.btn-outline-primary {
  background: transparent;
  color: var(--steel-500);
  border-color: var(--steel-300);
}
.btn-outline-primary:hover {
  background: var(--steel-100);
  color: var(--steel-600);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  min-height: 30px;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 15px;
  min-height: 48px;
}

.btn-block {
  width: 100%;
}

.btn-group {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px; /* Allow slight overflow on mobile */
  padding: 0 4px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 480px; /* Ensure table doesn't collapse too much */
}

.table thead th {
  background: var(--gray-50);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-50);
  color: var(--gray-800);
  vertical-align: middle;
}

.table tbody tr:hover {
  background: var(--bg-hover);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table .col-actions {
  text-align: right;
  white-space: nowrap;
}

/* Mobile card-view for tables */
.table-card-view {
  display: none;
}

.table-card-item {
  background: var(--bg-card);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}

.table-card-item .card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.table-card-item .card-row + .card-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-50);
}

.table-card-item .card-label {
  font-size: 11px;
  color: var(--gray-500);
  flex-shrink: 0;
}

.table-card-item .card-value {
  font-size: 13px;
  color: var(--gray-800);
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-card-item .card-value a {
  font-weight: 500;
}

.table-card-item .card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 10px;
  border-top: 1px solid var(--gray-100);
  margin-top: 10px;
}

/* --- Status Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-collecting      { background: #E8EDF4; color: var(--status-collecting); }
.badge-lawyer-review   { background: #EDE8F4; color: var(--status-lawyer-review); }
.badge-hague-translate { background: #E4F0F2; color: var(--status-hague-translate); }
.badge-submitted       { background: #FBF2D0; color: var(--status-submitted); }
.badge-supplementing   { background: #FBE8DE; color: var(--status-supplementing); }
.badge-resubmitted     { background: #FBF0DE; color: var(--status-resubmitted); }
.badge-approved        { background: #D4EDDA; color: var(--status-approved); }
.badge-rejected        { background: #F8D7DA; color: var(--status-rejected); }

.badge-warning        { background: #FFF3CD; color: #856404; font-weight: 500; }
.badge-info           { background: #E8EDF4; color: #3D5A80; font-weight: 500; }

/* Review status badges */
.badge-pending         { background: #FBF2D0; color: var(--review-pending); }
.badge-approved-review { background: #D4EDDA; color: var(--review-approved); }
.badge-rejected-review { background: #F8D7DA; color: var(--review-rejected); }

/* Role badges */
.badge-role-admin      { background: #FBE8DE; color: #C45500; }
.badge-role-supervisor { background: #E8EDF4; color: var(--steel-600); }
.badge-role-agent      { background: #D4EDDA; color: #1B7A3D; }
.badge-role-lawyer     { background: #EDE8F4; color: #6B4FA0; }

/* Required indicator */
.badge-required {
  background: #FEF2F2;
  color: #B91C1C;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.badge-optional {
  background: var(--gray-50);
  color: var(--gray-500);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

/* --- Timeline / Workflow Stepper --- */
.workflow-timeline {
  position: relative;
  padding-left: 28px;
}

.workflow-timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--gray-200);
}

.timeline-item {
  position: relative;
  padding-bottom: 18px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item .timeline-dot {
  position: absolute;
  left: -28px;
  top: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  background: #FFFFFF;
  z-index: 1;
}

.timeline-item.completed .timeline-dot {
  border-color: var(--status-approved);
  background: var(--status-approved);
}

.timeline-item.completed .timeline-dot::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 4px;
  border-left: 2px solid #FFFFFF;
  border-bottom: 2px solid #FFFFFF;
  transform: rotate(-45deg);
}

.timeline-item.current .timeline-dot {
  border-color: var(--steel-500);
  background: var(--steel-500);
  box-shadow: 0 0 0 4px rgba(74, 111, 165, 0.15);
}

.timeline-item.rejected .timeline-dot {
  border-color: var(--status-rejected);
  background: var(--status-rejected);
}

.timeline-item .timeline-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
}

.timeline-item.completed .timeline-label {
  color: var(--gray-400);
}

.timeline-item.current .timeline-label {
  color: var(--steel-600);
  font-weight: 600;
}

.timeline-item .timeline-time {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}

/* --- Material Checklist --- */
.checklist-grid {
  display: grid;
  gap: 8px;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  background: #FFFFFF;
  transition: background var(--transition);
  flex-wrap: wrap; /* Allow wrapping on small screens */
}

.checklist-item:hover {
  background: var(--bg-hover);
}

.checklist-item .check-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}

.checklist-item .check-icon.done {
  background: #D4EDDA;
  color: #1B7A3D;
}

.checklist-item .check-icon.pending {
  background: var(--gold-100);
  color: var(--gold-600);
}

.checklist-item .check-icon.missing {
  background: #FEF2F2;
  color: #B91C1C;
}

.checklist-item .item-name {
  flex: 1;
  font-size: 13px;
  color: var(--gray-800);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.checklist-item .item-status {
  flex-shrink: 0;
}

.checklist-item .item-action {
  flex-shrink: 0;
}

/* --- Alert / Message --- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alert-success {
  background: #D4EDDA;
  color: #15632F;
  border: 1px solid #B8DFC4;
}

.alert-danger {
  background: #F8D7DA;
  color: #842029;
  border: 1px solid #F5C2C7;
}

.alert-warning {
  background: var(--gold-100);
  color: #7A5C00;
  border: 1px solid #E5C55E;
}

.alert-info {
  background: var(--steel-100);
  color: var(--navy-600);
  border: 1px solid var(--steel-200);
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.pagination a, .pagination span {
  padding: 6px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--gray-700);
  background: #FFFFFF;
  transition: all var(--transition);
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pagination a:hover {
  background: var(--bg-active);
  border-color: var(--steel-300);
}

.pagination .active {
  background: var(--navy-600);
  color: #FFFFFF;
  border-color: var(--navy-600);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}

.empty-state .empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state h3 {
  color: var(--gray-500);
  font-weight: 500;
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 13px;
  color: var(--gray-400);
}

/* --- Breadcrumb --- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--gray-400);
  margin-bottom: 14px;
  flex-wrap: wrap;
  min-height: 0;
}

.breadcrumb a {
  color: var(--gray-500);
}

.breadcrumb a:hover {
  color: var(--steel-500);
}

.breadcrumb .sep {
  color: var(--gray-300);
}

/* --- Toolbar --- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box {
  position: relative;
}

.search-box input {
  padding-left: 32px;
  width: 220px;
}

.search-box .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 13px;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 0;
  margin-top: 8px;
}

.pagination-info {
  font-size: 13px;
  color: var(--gray-500);
}

.pagination .btn-sm {
  min-width: 80px;
}

/* Filter dropdown */
.filter-select {
  min-width: 130px;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  padding: 16px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: #FFFFFF;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 480px;
  max-width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #FFFFFF;
  z-index: 1;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header h3 {
  font-size: 16px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: background var(--transition);
}

.modal-close:hover {
  color: var(--gray-700);
  background: var(--gray-50);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: #FFFFFF;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* --- Tabs --- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 20px;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-item {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.tab-item:hover {
  color: var(--gray-800);
}

.tab-item.active {
  color: var(--navy-600);
  border-bottom-color: var(--navy-600);
}

/* --- Review Layout (two-column: left narrow, right wide) --- */
.review-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
  margin-bottom: 24px;
  align-items: stretch;   /* left + right same height */
}

.review-info-card {
  /* fill the grid cell (stretch alignment) instead of sticky */
  display: flex;
  flex-direction: column;
}

.review-result {
  margin-bottom: 16px;
}

.review-result .alert {
  margin-bottom: 0;
}

.review-actions.btn-group {
  flex-wrap: nowrap;
  gap: 10px;
}

.review-actions .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.review-preview-card {
  min-height: 500px;
}

.review-preview-card .card-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 500px;
  overflow: auto;
}

.preview-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F8F9FA;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Image preview */
.preview-image-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
}

.preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

/* PDF.js viewer */
.preview-pdfjs-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.pdfjs-viewport {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  background: #525659; /* dark bg like Adobe Reader */
}

.pdfjs-viewport canvas {
  box-shadow: 0 2px 16px rgba(0,0,0,0.35);
  border-radius: 2px;
}

.pdfjs-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #F3F4F6;
  border-top: 1px solid #E5E7EB;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  flex-shrink: 0;
}

.pdfjs-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #D1D5DB;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--gray-700);
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.pdfjs-btn:hover {
  background: #E5E7EB;
}
.pdfjs-btn:active {
  background: #D1D5DB;
}

.pdfjs-page-info,
.pdfjs-zoom-info {
  font-size: 13px;
  color: var(--gray-600);
  min-width: 90px;
  text-align: center;
  user-select: none;
}
.pdfjs-zoom-info { min-width: 48px; }

.pdfjs-spacer {
  flex: 1;
}

/* PDF.js loading overlay (reuses .preview-loading — kept above) */
.preview-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(248, 249, 250, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.preview-loading-content {
  text-align: center;
  padding: 32px;
}

.preview-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--steel-100);
  border-top-color: var(--steel-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.preview-loading-text {
  font-size: 14px;
  color: var(--gray-700);
  font-weight: 500;
  margin-bottom: 4px;
}

.preview-loading-hint {
  font-size: 12px;
  color: var(--gray-400);
  margin-bottom: 16px;
}

.preview-progress-bar {
  width: 240px;
  height: 4px;
  background: var(--gray-100);
  border-radius: 2px;
  margin: 0 auto;
  overflow: hidden;
}

.preview-progress-fill {
  width: 0%;
  height: 100%;
  background: var(--steel-500);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Office document iframe */
.preview-office-frame {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: #fff;
}

/* Unsupported preview placeholder */
.preview-placeholder {
  text-align: center;
  padding: 48px 32px;
}

.preview-placeholder-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  background: var(--steel-100);
  color: var(--steel-600);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.preview-placeholder-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.preview-placeholder-name {
  word-break: break-all;
}

.preview-placeholder-size {
  margin-top: 2px;
}

/* --- Detail Layout --- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.detail-grid .full-width {
  grid-column: 1 / -1;
}

/* Info list */
.info-list {
  display: grid;
  gap: 10px;
}

.info-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.info-item .info-label {
  font-size: 12px;
  color: var(--gray-500);
  min-width: 70px;
  flex-shrink: 0;
}

.info-item .info-value {
  font-size: 13px;
  color: var(--gray-900);
  font-weight: 500;
  word-break: break-all;
}

/* --- Quick Action Bar (workflow) --- */
.action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  background: var(--bg-active);
  border-radius: var(--radius-lg);
  border: 1px solid var(--steel-100);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.action-bar .action-label {
  font-size: 13px;
  color: var(--gray-600);
  font-weight: 500;
  margin-right: 4px;
}

/* --- Bottom Navigation (Mobile) --- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--gray-100);
  z-index: 90;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}

.bottom-nav-inner {
  display: flex;
  align-items: stretch;
  height: var(--bottom-nav-h);
  max-width: 500px;
  margin: 0 auto;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  color: var(--gray-500);
  text-decoration: none;
  transition: color var(--transition);
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:active {
  color: var(--navy-600);
}

.bottom-nav-item.active {
  color: var(--navy-600);
}

.bottom-nav-item .bnav-icon {
  font-size: 20px;
  line-height: 1;
}

.bottom-nav-item .bnav-label {
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* --- Utility --- */
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================================================================
   RESPONSIVE BREAKPOINTS
   ================================================================ */

/* --- Tablet landscape (≤ 1024px) --- */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }

  .main {
    margin-left: 0;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .content {
    padding: 16px 20px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* --- Review stacking (≤ 900px) --- */
@media (max-width: 900px) {
  .review-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .review-actions.btn-group {
    flex-wrap: wrap;
  }

  .review-preview-card .card-body {
    height: 60vh;
    min-height: 400px;
  }
}

/* --- Tablet portrait (≤ 768px) --- */
@media (max-width: 768px) {
  html {
    font-size: 13px;
  }

  .header {
    padding: 0 16px;
    height: 52px;
  }

  .header-left .page-title {
    font-size: 15px;
  }

  .header-right .text-small {
    display: none; /* Hide user info text on small screens */
  }

  .content {
    padding: 14px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 14px 16px;
  }

  .stat-card .stat-value {
    font-size: 22px;
  }

  .stat-card .stat-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .card-header {
    padding: 12px 16px;
  }

  .card-body {
    padding: 16px;
  }

  .search-box input {
    width: 180px;
  }

  .toolbar-left {
    width: 100%;
  }

  .toolbar-right {
    width: 100%;
    justify-content: flex-end;
  }

  /* Show card view, hide table */
  .table-card-view {
    display: block;
  }

  .table-wrapper {
    display: none;
  }

  /* Modal becomes bottom sheet on tablet */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transform: translateY(100%);
  }

  .modal-overlay.active .modal {
    transform: translateY(0);
  }
}

/* --- Mobile (≤ 480px) --- */
@media (max-width: 480px) {
  html {
    font-size: 13px;
  }

  .content {
    padding: 12px 14px;
    padding-bottom: calc(80px + var(--safe-bottom)); /* Space for bottom nav */
  }

  /* Bottom navigation */
  .bottom-nav {
    display: block;
  }

  /* Sidebar becomes full-screen overlay */
  .sidebar {
    width: 85vw;
    max-width: 300px;
  }

  /* Stats: single column on very small phones */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-card {
    padding: 12px 14px;
  }

  .stat-card .stat-value {
    font-size: 20px;
  }

  .stat-card .stat-label {
    font-size: 10px;
  }

  /* Smaller action bar */
  .action-bar {
    padding: 10px 12px;
    gap: 6px;
  }

  .action-bar .action-label {
    width: 100%;
    margin-bottom: 4px;
  }

  .action-bar .btn-group {
    width: 100%;
    display: flex;
  }

  .action-bar .btn-group .btn {
    flex: 1;
    font-size: 12px;
    padding: 7px 8px;
  }

  /* Login page */
  .login-card {
    padding: 32px 24px;
    border-radius: var(--radius-lg);
  }

  .login-card .login-logo .logo-mark {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .login-card .login-logo h1 {
    font-size: 18px;
  }

  /* Buttons: full-width on mobile */
  .btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Checklist items */
  .checklist-item {
    padding: 10px 12px;
    gap: 8px;
  }

  .checklist-item .item-action .btn {
    min-height: 32px;
    font-size: 11px;
    padding: 4px 10px;
  }

  /* Info items */
  .info-item {
    flex-direction: column;
    gap: 2px;
  }

  .info-item .info-label {
    min-width: unset;
  }

  .info-item .info-value {
    font-size: 13px;
  }

  /* Breadcrumb compact */
  .breadcrumb {
    font-size: 11px;
    margin-bottom: 10px;
  }

  /* Toolbar */
  .toolbar {
    gap: 8px;
  }

  .toolbar-left {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .search-box input {
    width: 100%;
  }

  .filter-select {
    width: 100%;
  }

  /* Workflow timeline */
  .workflow-timeline {
    padding-left: 24px;
  }

  /* Card view items */
  .table-card-item {
    padding: 12px 14px;
  }

  .table-card-item .card-actions {
    gap: 6px;
  }

  .table-card-item .card-actions .btn {
    flex: 1;
    justify-content: center;
    font-size: 12px;
  }
}

/* --- Very small phones (≤ 360px) --- */
@media (max-width: 360px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .stat-card .stat-value {
    font-size: 18px;
  }

  .stat-card .stat-icon {
    width: 28px;
    height: 28px;
    font-size: 12px;
    top: 10px;
    right: 10px;
  }

  .btn {
    font-size: 12px;
    padding: 6px 12px;
  }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 99;
  transition: opacity 0.3s ease;
  opacity: 0;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* --- Desktop enhancement (≥ 1280px) --- */
@media (min-width: 1280px) {
  .stats-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .content {
    padding: 28px 36px;
  }

  .search-box input {
    width: 280px;
  }
}

/* --- Touch device optimizations --- */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .btn {
    min-height: 40px;
  }

  .btn-sm {
    min-height: 34px;
  }

  /* Remove hover effects that stick on touch */
  .sidebar-nav .nav-item:hover {
    background: transparent;
    color: var(--steel-200);
  }

  .sidebar-nav .nav-item:active {
    background: rgba(255,255,255,0.05);
    color: #FFFFFF;
  }

  .table tbody tr:hover {
    background: transparent;
  }

  .checklist-item:hover {
    background: #FFFFFF;
  }
}

/* --- Dark mode / system preference support --- */
@media (prefers-color-scheme: dark) {
  /* Placeholder for future dark mode support */
}

/* --- Landscape mobile --- */
@media (max-height: 500px) and (orientation: landscape) {
  .login-wrapper {
    align-items: flex-start;
    padding-top: 16px;
  }

  .login-card {
    max-width: 500px;
    padding: 24px 32px;
  }

  .login-card .login-logo {
    margin-bottom: 16px;
  }

  .modal {
    max-height: 95vh;
  }

  .bottom-nav {
    display: none;
  }
}

/* --- Print --- */
@media print {
  .sidebar, .header, .action-bar, .btn, .bottom-nav { display: none !important; }
  .main { margin-left: 0 !important; }
  .card { border: 1px solid #DDD !important; box-shadow: none !important; }
  .content { padding: 0 !important; }
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease;
}

.animate-slide-up {
  animation: slideUp 0.3s ease;
}

/* Staggered animation for stat cards */
.stats-grid .stat-card:nth-child(1) { animation: slideUp 0.3s ease 0.0s both; }
.stats-grid .stat-card:nth-child(2) { animation: slideUp 0.3s ease 0.05s both; }
.stats-grid .stat-card:nth-child(3) { animation: slideUp 0.3s ease 0.1s both; }
.stats-grid .stat-card:nth-child(4) { animation: slideUp 0.3s ease 0.15s both; }
.stats-grid .stat-card:nth-child(5) { animation: slideUp 0.3s ease 0.2s both; }
.stats-grid .stat-card:nth-child(6) { animation: slideUp 0.3s ease 0.25s both; }
