/* =========================================
   ID Card Generator — Main Styles
   ========================================= */

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

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-panel: #20242f;
  --bg-input: #2a2f3d;
  --border: #2e3447;
  --border-light: #3a4055;
  --accent: #4f7df3;
  --accent-hover: #3d6be0;
  --accent-success: #22c55e;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --text: #e8eaf0;
  --text-muted: #8892a4;
  --text-dim: #5a6272;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: 0.2s ease;
}

html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* =========================================
   NAVBAR
   ========================================= */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.brand-icon { font-size: 20px; }
.brand-name { font-size: 15px; font-weight: 600; color: var(--text); }
.brand-name-link {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.brand-name-link:hover {
  color: #fff;
}
.navbar-links { display: flex; align-items: center; gap: 8px; }
.navbar-links form { margin: 0; }
.nav-contact {
  font-size: 12px;
  color: #93c5fd;
  text-decoration: none;
  padding: 6px 10px;
  border: 1px dashed rgba(147, 197, 253, 0.45);
  border-radius: 999px;
  white-space: nowrap;
}
.nav-contact:hover {
  color: #bfdbfe;
  border-color: rgba(191, 219, 254, 0.75);
}
.nav-contact-brand {
  padding: 4px 9px;
}
.nav-badge {
  font-size: 11px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 20px;
}
.nav-badge-session {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.45);
}
.nav-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all var(--transition);
}
.nav-link:hover {
  color: var(--text);
  border-color: var(--accent);
}
.nav-link-active {
  color: #fff;
  border-color: var(--accent);
  background: rgba(79, 125, 243, 0.15);
}
.nav-link-primary {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}
.nav-link-primary:hover {
  color: #fff;
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}
.nav-link-button {
  font-size: 12px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all var(--transition);
}
.nav-link-button:hover {
  color: var(--accent-danger);
  border-color: var(--accent-danger);
}
.retention-banner {
  background: rgba(245, 158, 11, 0.12);
  border-bottom: 1px solid rgba(245, 158, 11, 0.35);
  color: #fcd34d;
  font-size: 12px;
  text-align: center;
  padding: 8px 12px;
}

/* =========================================
   UPLOAD SECTION
   ========================================= */
.upload-section {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 88px);
  padding: 40px 16px;
}
.upload-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
}
.upload-header { text-align: center; margin-bottom: 32px; }
.upload-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.upload-header p { color: var(--text-muted); font-size: 13px; line-height: 1.6; }

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-sm);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-panel);
  margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(79, 125, 243, 0.05);
}
.drop-zone-icon { font-size: 36px; margin-bottom: 12px; }
.drop-zone-text { display: flex; flex-direction: column; gap: 4px; }
.drop-zone-text strong { font-size: 14px; color: var(--text); }
.drop-zone-text span { font-size: 12px; color: var(--text-muted); }

/* File Info */
.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.file-info-icon { font-size: 22px; }
.file-info-details { flex: 1; min-width: 0; }
.file-name { display: block; font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11px; color: var(--text-muted); }

/* Password Section */
.password-field {
  margin-bottom: 16px;
  border: 1px solid var(--accent-warning);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: rgba(245, 158, 11, 0.05);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.password-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--accent-warning);
  font-weight: 500;
}
.lock-icon { font-size: 16px; }

/* Filename suggestion chip */
.password-suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
}
.suggestion-label {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}
.btn-suggestion {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1.5px dashed var(--accent);
  color: var(--accent);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-suggestion::before { content: '🔑 '; font-size: 12px; }
.btn-suggestion:hover {
  background: rgba(79, 125, 243, 0.12);
  border-style: solid;
}
.btn-suggestion.used {
  border-color: var(--accent-success);
  color: var(--accent-success);
  border-style: solid;
}
.btn-suggestion.used::before { content: '✓ '; }

/* Inline password submit */
.btn-password-submit {
  width: 100%;
  justify-content: center;
  padding: 11px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}
.input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Upload Status */
.upload-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-radius: 6px;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}
.status-dot.success { background: var(--accent-success); animation: none; }
.status-dot.error { background: var(--accent-danger); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* =========================================
   BUTTONS
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; padding: 10px 20px; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border-light); padding: 8px 16px; }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-success { background: var(--accent-success); color: #fff; padding: 8px 16px; }
.btn-success:hover { background: #16a34a; }
.btn-danger { background: transparent; color: #ef4444; border-color: #ef4444 !important; transition: background var(--transition), color var(--transition); }
.btn-danger:hover { background: #ef4444; color: #fff; }
.btn-large { padding: 14px 28px; font-size: 15px; border-radius: var(--radius-sm); width: 100%; justify-content: center; }
.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-icon { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: all var(--transition); }
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-micro { background: var(--bg-input); border: 1px solid var(--border); color: var(--text-muted); width: 26px; height: 26px; border-radius: 4px; cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.btn-micro:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon-left { font-size: 16px; }

.upload-actions { margin-top: 8px; }

.upload-modal-box {
  max-width: min(94vw, 560px);
}
.upload-modal-body {
  padding: 0;
}
.upload-modal-body .upload-section {
  min-height: auto;
  padding: 0;
}
.upload-modal-body .upload-card {
  max-width: none;
  border: none;
  box-shadow: none;
  background: transparent;
  border-radius: 0;
  padding: 20px;
}
.upload-modal-body .upload-header {
  margin-bottom: 22px;
}

/* =========================================
   FORM INPUTS
   ========================================= */
.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 13px;
  transition: border-color var(--transition);
  outline: none;
}
.form-input:focus { border-color: var(--accent); }
textarea.form-input { resize: vertical; }

/* =========================================
   PROCESSING OVERLAY
   ========================================= */
.processing-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.processing-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  text-align: center;
  min-width: 340px;
  box-shadow: var(--shadow-lg);
}
.spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-box h3 { font-size: 17px; margin-bottom: 8px; }
.processing-box p { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.progress-bar { background: var(--bg-input); border-radius: 20px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 20px; transition: width 0.4s ease; }

/* =========================================
   EDITOR SECTION
   ========================================= */
.editor-section { display: flex; flex-direction: column; height: calc(100vh - 56px); overflow: hidden; }

/* Action Bar */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}
.action-bar-left, .action-bar-right { display: flex; align-items: center; gap: 10px; }
.action-crop-toggle {
  display: flex;
  align-items: center;
}
.action-crop-toggle .toggle-label {
  padding: 0;
  font-size: 11px;
}
.doc-badge {
  font-size: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 20px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-type-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.doc-type-aadhaar   { color: #1a73e8; background: rgba(26,115,232,.1); }
.doc-type-aadhaar_e { color: #1a73e8; background: rgba(26,115,232,.1); }
.doc-type-voter_id  { color: #0d7041; background: rgba(13,112,65,.1);  }
.doc-type-mukh_mantri { color: #a35b00; background: rgba(245, 158, 11, .18); }
.doc-type-unknown   { color: var(--text-muted); background: transparent; }

/* Password stem hint */
.password-stem-hint {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(var(--accent-rgb, 99,102,241), 0.07);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.5;
}
.password-stem-hint em  { font-style: italic; color: var(--text-dim); }
.password-stem-hint code {
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

/* Settings Bar */
.settings-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 16px;
  padding: 12px 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.batch-queue-panel {
  padding: 12px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.batch-queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.batch-queue-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-dim);
  font-weight: 700;
}

.batch-queue-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.batch-queue-note {
  font-size: 12px;
  color: var(--text-muted);
}

.batch-queue-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.batch-queue-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: grab;
  user-select: none;
}

.batch-queue-item.dragging {
  opacity: 0.5;
  border-color: var(--accent);
}

.batch-queue-item-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.batch-queue-item-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-queue-item-remove {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.batch-queue-item-remove:hover {
  border-color: var(--accent-danger);
  color: var(--accent-danger);
}

.batch-queue-empty {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 0;
}
.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  width: 100%;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child {
  padding-bottom: 0;
  border-bottom: none;
}
.settings-row-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-dim);
  width: 100%;
  margin-bottom: 2px;
}
.settings-group { display: flex; flex-direction: column; gap: 3px; white-space: nowrap; }
.settings-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.stepper-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
}
.stepper-value {
  min-width: 48px;
  text-align: center;
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
}
.settings-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.settings-select:hover, .settings-select:focus { border-color: var(--accent); }
.settings-divider { display: none; }
.settings-toggle { flex-direction: row; align-items: center; gap: 0; }
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 0;
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle-track {
  width: 32px; height: 18px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  position: relative;
  transition: all var(--transition);
  flex-shrink: 0;
}
.toggle-track::after {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 12px; height: 12px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all var(--transition);
}
.toggle-label input:checked + .toggle-track { background: rgba(79, 125, 243, 0.2); border-color: var(--accent); }
.toggle-label input:checked + .toggle-track::after { background: var(--accent); left: 16px; }

/* Info Bar */
.info-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
}
.info-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
}
.chip-icon { font-size: 12px; }
.chip-label { color: var(--text-dim); }
.chip-value { color: var(--text); font-weight: 500; }

/* =========================================
   CARD PREVIEW AREA
   ========================================= */
.card-preview-area {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 40px;
  padding: 32px 24px;
  overflow-y: auto;
  background: var(--bg);
  position: relative;
}
.dashboard-empty-note {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 7px 14px;
  border: 1px dashed var(--border-light);
  background: rgba(15, 17, 23, 0.55);
  border-radius: 999px;
}
.main-card-preview {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 40px;
  transition: transform 0.25s ease, gap 0.25s ease;
}
.card-preview-area.with-batch-side .main-card-preview {
  transform: translateX(-10px);
  gap: 26px;
}
.main-card-preview.crop-only-mode {
  gap: 0;
}
.main-card-preview.crop-only-mode .card-panel {
  width: min(92vw, 720px);
}
.card-frame.crop-strip {
  width: min(92vw, 720px);
  height: auto;
  aspect-ratio: 3.2 / 1;
}

.batch-side-preview {
  width: 290px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: stretch;
  max-height: 100%;
}
.batch-side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.batch-side-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.batch-side-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.batch-side-note {
  font-size: 11px;
  color: var(--text-muted);
}
.batch-side-preview #addToPdfBtn {
  width: 100%;
  justify-content: center;
}
.batch-side-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}
.batch-side-item-btn {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: border-color var(--transition), transform var(--transition);
}
.batch-side-item-btn:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}
.batch-side-more {
  font-size: 11px;
  color: var(--text-dim);
  padding-left: 4px;
}
.batch-side-empty {
  font-size: 12px;
  color: var(--text-dim);
}

/* Card Panel */
.card-panel { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 4px;
}
.panel-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
}
.front-badge { background: rgba(79, 125, 243, 0.15); color: var(--accent); border: 1px solid rgba(79, 125, 243, 0.3); }
.back-badge { background: rgba(34, 197, 94, 0.12); color: var(--accent-success); border: 1px solid rgba(34, 197, 94, 0.3); }
.panel-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.orientation-badge {
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.orientation-badge.landscape { color: var(--accent-warning); border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.07); }
.orientation-badge.portrait  { color: #a78bfa; border-color: rgba(167,139,250,0.3); background: rgba(167,139,250,0.07); }

/* Card Frame */
.card-frame-wrapper {
  filter: drop-shadow(0 16px 40px rgba(0,0,0,0.6));
}
.card-frame {
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
.card-frame.cr80 {
  /* CR80 landscape: 85.6 × 53.98mm */
  width: 340px;
  height: 214px;
}
.card-frame.cr80-portrait {
  /* CR80 portrait: 53.98 × 85.6mm */
  width: 214px;
  height: 340px;
}
.card-frame.a4 {
  width: 240px;
  height: 339px;
}
.card-frame.a4-landscape {
  width: 339px;
  height: 240px;
}
.card-frame.a6 {
  width: 240px;
  height: 170px;
}

.backend-preview-box {
  width: 100%;
  height: 100%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.backend-preview-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.preview-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(15, 17, 23, 0.46);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(1px);
}

.preview-loader-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

/* Card Inner (Template Styles) */
.card-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  font-family: var(--font);
}

/* No Background Template */
.template-none { background: #1e2230; border: 1px solid #3a4055; }

/* Print Background OFF — plain white card (pre-printed blank card mode) */
.template-none.bg-off { background: #ffffff; border: 1px solid #ccc; }
.template-none.bg-off .field-label { color: #555; }
.template-none.bg-off .field-value { color: #111; }
.template-none.bg-off .card-footer-tag,
.template-none.bg-off .card-org-name { color: rgba(255,255,255,0.9); }

/* Blue Gradient Template */
.template-blue_gradient { background: linear-gradient(135deg, #1a3a6e 0%, #0d1f3c 100%); }

/* Dark Solid Template */
.template-dark_solid { background: #1a1a2e; }

/* Govt White Template */
.template-govt_white { background: #f5f5f0; color: #111; }
.template-govt_white .card-header-strip { background: #1a3a6e; }
.template-govt_white .card-footer-strip { background: #1a3a6e; }
.template-govt_white .field-label { color: #555; }
.template-govt_white .field-value { color: #111; }

/* Maroon Template */
.template-maroon { background: linear-gradient(135deg, #3d0a0a 0%, #1a0505 100%); }
.template-maroon .card-header-strip { background: rgba(0,0,0,0.3); }

/* Header Strip */
.card-header-strip {
  background: rgba(79, 125, 243, 0.2);
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.card-org-name {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.85);
}

/* Card Body */
.card-body { flex: 1; display: flex; gap: 10px; padding: 8px 10px; overflow: hidden; }
.card-back-body { flex-direction: row; align-items: flex-start; }

/* Photo Block */
.card-photo-block { flex-shrink: 0; display: flex; align-items: center; }
.card-photo-frame {
  width: 58px; height: 72px;
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-photo-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: rgba(255,255,255,0.04);
}
.card-photo-placeholder img { width: 100%; height: 100%; object-fit: cover; }

/* Details Block */
.card-details-block { flex: 1; display: flex; flex-direction: column; gap: 4px; justify-content: center; min-width: 0; }
.card-field { display: flex; flex-direction: column; gap: 1px; }
.field-label { font-size: 7px; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 0.5px; }
.field-value { font-size: 10px; color: rgba(255,255,255,0.9); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field-value.mono { font-family: 'Courier New', monospace; letter-spacing: 1px; font-size: 9px; }
.card-name .field-value { font-size: 11px; font-weight: 700; }

/* Footer Strip */
.card-footer-strip {
  background: rgba(0,0,0,0.25);
  padding: 3px 10px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.card-footer-tag { font-size: 7px; letter-spacing: 1px; text-transform: uppercase; color: rgba(255,255,255,0.4); }

/* Address Block */
.card-address-block { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.address-text { font-size: 9px; line-height: 1.5; color: rgba(255,255,255,0.75); white-space: pre-wrap; }

/* QR Block */
.card-qr-block { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; margin-left: 8px; }
.qr-placeholder { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.qr-grid {
  width: 52px; height: 52px;
  background: white;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
}
.qr-inner {
  width: 100%; height: 100%;
  background: repeating-conic-gradient(#333 0% 25%, #fff 0% 50%) 0 0 / 6px 6px;
  border-radius: 1px;
}
.qr-label { font-size: 7px; color: rgba(255,255,255,0.4); letter-spacing: 0.5px; }

/* Magnetic Stripe */
.card-mag-stripe-strip { flex-shrink: 0; padding: 4px 0; }
.mag-stripe { height: 22px; background: #1a1000; margin: 0; }

/* =========================================
   MODAL
   ========================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.batch-modal-box {
  max-width: min(96vw, 720px);
}
.batch-modal-body {
  max-height: min(72vh, 760px);
  overflow: auto;
}
.batch-modal-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.batch-modal-list-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.batch-modal-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.batch-modal-item {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel);
  padding: 10px;
  transition: transform 0.2s ease, opacity 0.2s ease, margin 0.2s ease, max-height 0.2s ease, padding 0.2s ease;
  max-height: 360px;
}
.batch-modal-item.removing {
  opacity: 0;
  transform: translateX(26px);
  max-height: 0;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
}
.batch-modal-item-content {
  border: none;
  background: transparent;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  color: inherit;
  flex: 1 1 auto;
  min-width: 0;
}
.batch-modal-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.batch-modal-item-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.batch-modal-item-meta strong {
  font-size: 13px;
  color: var(--text);
}
.batch-modal-item-meta span {
  font-size: 11px;
  color: var(--text-muted);
}
.batch-modal-card-pair {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 8px;
}
.batch-modal-card-pair.single {
  width: 100%;
}
.batch-modal-card-img {
  flex: 1 1 0;
  min-width: 120px;
  max-width: 240px;
  aspect-ratio: 340 / 214;
  height: auto;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
}
.batch-modal-card-pair.single .batch-modal-card-img {
  max-width: min(100%, 560px);
  width: 100%;
  aspect-ratio: 3.2 / 1;
  object-fit: contain;
}
.batch-modal-remove-btn {
  align-self: center;
  margin-left: auto;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  min-width: 86px;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.batch-modal-remove-btn:hover {
  color: var(--accent-danger);
  border-color: var(--accent-danger);
}
.batch-modal-remove-btn.confirm {
  border-color: var(--accent-warning);
  color: var(--accent-warning);
  background: rgba(245, 158, 11, 0.1);
}
.batch-modal-empty {
  font-size: 12px;
  color: var(--text-dim);
}

.photo-enhance-preview-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.photo-enhance-preview-image {
  width: 180px;
  height: 220px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: #fff;
}

.form-input-range {
  width: 100%;
  accent-color: var(--accent);
}

/* =========================================
   SCROLLBAR
   ========================================= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 900px) {
  .navbar {
    height: auto;
    min-height: 56px;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px;
  }
  .navbar-brand {
    width: 100%;
  }
  .navbar-links {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .nav-contact {
    font-size: 11px;
  }
  .nav-badge-session {
    display: none;
  }
  .card-preview-area { flex-direction: column; align-items: center; gap: 24px; }
  .main-card-preview { flex-direction: column; align-items: center; gap: 24px; }
  .card-preview-area.with-batch-side .main-card-preview { transform: none; }
  .batch-side-preview { width: min(94vw, 420px); max-height: none; }
  .action-bar { flex-wrap: wrap; gap: 8px; }
  .card-frame.cr80 { width: 300px; height: 189px; }
  .card-frame.cr80-portrait { width: 189px; height: 300px; }
  .batch-modal-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .batch-modal-preview-row {
    width: 100%;
    align-items: flex-start;
    flex-direction: column;
  }
  .batch-modal-card-pair {
    flex-wrap: wrap;
  }
  .batch-modal-card-img {
    flex: 1 1 120px;
    max-width: 260px;
  }
}

/* =========================================
   GENERIC LAYOUT WRAPPER
   ========================================= */
.generic-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* =========================================
   VOTER ID (e-EPIC) — pixel-accurate overlay
   Card frame: 340×214px  (PDF card: 245×154pt)
   Scale: x×1.3878  y×1.3896
   ========================================= */
.vi-card {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.vi-bg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
}
/* Clipping container — positioned absolutely, clips its child text span */
.vi-clip {
  position: absolute;
  overflow: hidden;
}
/* Text overlay span — sits at 0,0 inside its .vi-clip parent */
.vi-ov {
  position: absolute;
  top: 0;
  left: 0;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.3;
  white-space: nowrap;
}
.vi-bold  { font-weight: bold; }
.vi-white { color: #fff !important; }
.vi-wrap  { white-space: normal; }
