/* ==========================================================================
   KACST Career Circular & Official Letterhead Stylesheet
   Formal Academic & Institutional Theme
   ========================================================================== */

:root {
  --primary-navy: #0d3880;
  --secondary-blue: #1b4d9b;
  --accent-gold: #c97a0a;
  --accent-gold-dark: #b45309;
  --text-dark: #0f172a;
  --text-muted: #334155;
  --border-formal: #475569;
  --border-light: #cbd5e1;
  --table-header-bg: #f1f5f9;
  --subtotal-bg: #f8fafc;
  --font-bn: 'Hind Siliguri', 'Tiro Bangla', sans-serif;
  --font-en: 'Inter', system-ui, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
}

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

body {
  font-family: var(--font-bn);
  color: var(--text-dark);
  background-color: #e2e8f0;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Top Application Toolbar & Controls (Hidden on Print)
   ========================================================================== */

.app-toolbar {
  position: sticky;
  top: 0;
  z-index: 999;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  padding: 10px 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.toolbar-container {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mini-logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  padding: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
  color: #fbbf24;
}

.brand-sub {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
}

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

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px 6px;
  border-radius: 8px;
}

.control-label {
  font-size: 11px;
  color: #cbd5e1;
  font-weight: 600;
  margin-right: 2px;
}

.segmented-control {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  padding: 2px;
}

.seg-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.seg-btn:hover {
  color: #fff;
}

.seg-btn.active {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.tool-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 7px 13px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.tool-btn.active-state {
  background: #f59e0b;
  color: #0f172a;
  border-color: #fbbf24;
  font-weight: 700;
}

.primary-btn {
  background: linear-gradient(135deg, #16a34a, #15803d);
  border: 1px solid #22c55e;
  color: #fff;
  box-shadow: 0 2px 10px rgba(22, 163, 74, 0.35);
}

.primary-btn:hover {
  background: linear-gradient(135deg, #15803d, #166534);
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.45);
}

/* Quick Info Bar */
.quick-info-bar {
  background: #1e293b;
  border-bottom: 1px solid #334155;
  padding: 6px 20px;
  font-size: 12px;
  color: #cbd5e1;
}

.info-bar-inner {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 4px;
}

.highlight-pill {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fef08a;
}

.highlight-pill strong {
  color: #ffffff !important;
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}

.stat-pill strong {
  color: #38bdf8;
}

.keyboard-hint {
  margin-left: auto;
  color: #fbbf24;
}

/* ==========================================================================
   A4 Canvas & Document Viewport
   ========================================================================== */

.page-viewport {
  padding: 20px 12px 60px 12px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: calc(100vh - 120px);
}

.a4-sheet {
  width: 210mm;
  height: 297mm;
  min-height: 297mm;
  max-height: 297mm;
  position: relative;
  background-color: #ffffff;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Letterhead Modes: Pad vs Digital vs Stationery
   ========================================================================== */

/* 1. Official Pad Mode (High-Res 300-DPI Original Letterhead Scan) */
body.mode-pad .a4-sheet {
  background-image: url('letterhead-pad.png');
  background-repeat: no-repeat;
  background-size: 210mm 297mm;
  background-position: top left;
  padding: 40mm 15mm 22mm 15mm;
}

body.mode-pad .digital-letterhead,
body.mode-pad .digital-letterhead-footer,
body.mode-pad .digital-watermark {
  display: none !important;
}

/* In Pad Mode, position Ref & Date precisely after pre-printed text */
body.mode-pad .doc-meta-row {
  margin-top: 0;
  margin-bottom: 2mm;
  height: 7mm;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2mm;
}

body.mode-pad .meta-ref .meta-label,
body.mode-pad .meta-date .meta-label {
  visibility: hidden; /* Hide HTML label because Ref: and Date: are on the pad */
}

body.mode-pad .meta-ref .meta-value {
  margin-left: -54px; /* Seamlessly aligns right after the pre-printed Ref: */
}

/* 2. Digital Header Mode */
body.mode-digital .a4-sheet {
  background-image: none;
  padding: 8mm 15mm 8mm 15mm;
  justify-content: space-between;
}

body.mode-digital .digital-letterhead,
body.mode-digital .digital-letterhead-footer {
  display: block;
}

body.mode-digital .digital-watermark {
  display: flex;
}

body.mode-digital .doc-meta-row {
  margin-top: 2mm;
  margin-bottom: 2mm;
}

/* 3. Pre-Printed Stationery Mode (Print-Only Text) */
body.mode-stationery .a4-sheet {
  background-image: none !important;
  background-color: #ffffff;
  padding: 40mm 15mm 22mm 15mm;
}

body.mode-stationery .digital-letterhead,
body.mode-stationery .digital-letterhead-footer,
body.mode-stationery .digital-watermark {
  display: none !important;
}

body.mode-stationery .meta-ref .meta-label,
body.mode-stationery .meta-date .meta-label {
  visibility: hidden;
}

body.mode-stationery .meta-ref .meta-value {
  margin-left: -54px;
}

/* ==========================================================================
   Digital Letterhead Components (Mode: Digital)
   ========================================================================== */

.digital-letterhead {
  display: none;
  margin-bottom: 2mm;
}

.dh-top-row {
  display: grid;
  grid-template-columns: 76px 1fr 96px;
  align-items: center;
  gap: 8px;
}

.dh-college-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.dh-center-col {
  text-align: center;
}

.dh-affiliation {
  font-size: 10px;
  color: #1e3a8a;
  font-weight: 600;
  margin-bottom: 1px;
}

.dh-english-name {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 800;
  color: #0b377b;
  letter-spacing: 0.3px;
  line-height: 1.15;
  margin-bottom: 2px;
}

.dh-bangla-name {
  font-size: 17.5px;
  font-weight: 700;
  color: #0d3b75;
  line-height: 1.2;
}

.dh-estd-badge {
  font-size: 10px;
  font-weight: 700;
  color: #0d3b75;
  letter-spacing: 0.5px;
  margin-top: 1px;
}

.dh-codes-col {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dh-code-item {
  font-size: 11px;
  font-weight: 700;
  color: #d97706;
}

.dh-code-label {
  color: #b45309;
}

.dh-divider {
  height: 2px;
  background: #f59e0b;
  margin-top: 4px;
  border-radius: 2px;
}

/* Digital Watermark */
.digital-watermark {
  display: none;
  position: absolute;
  right: 15mm;
  bottom: 28mm;
  width: 88mm;
  height: 88mm;
  opacity: 0.07;
  pointer-events: none;
  z-index: 1;
  justify-content: center;
  align-items: center;
}

.wm-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Digital Footer */
.digital-letterhead-footer {
  display: none;
  margin-top: auto;
  padding-top: 2mm;
}

.df-divider {
  height: 2px;
  background: #f59e0b;
  margin-bottom: 4px;
}

.df-content {
  text-align: center;
  font-size: 9.5px;
  color: #1e3a8a;
  line-height: 1.35;
}

.df-line1 strong,
.df-line2 strong {
  color: #0f172a;
}

/* ==========================================================================
   Document Content & Metadata
   ========================================================================== */

.doc-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #0f2b5c;
  z-index: 2;
  margin-bottom: 1.5mm;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.meta-label {
  font-family: var(--font-en);
  font-weight: 700;
  font-style: italic;
  color: #0d3880;
}

.meta-value {
  font-family: var(--font-en);
  font-weight: 600;
  color: #0f172a;
  border-bottom: 1px dotted transparent;
  padding: 1px 4px;
}

/* Circular Title Banner */
.circular-title-wrap {
  text-align: center;
  margin-bottom: 2.2mm;
  z-index: 2;
}

.circular-title-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(135deg, #0d3880, #164e9a);
  color: #ffffff;
  padding: 4px 24px;
  border-radius: 4px;
  border: 1px solid #08285c;
  box-shadow: 0 2px 6px rgba(13, 56, 128, 0.25);
}

.circular-title-badge .bilingual-bn {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.circular-title-badge .bilingual-en {
  font-family: var(--font-heading);
  font-size: 9.8px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: #fcd34d;
}

.circular-lead-text {
  font-size: 10.5px;
  line-height: 1.45;
  color: #1e293b;
  margin-top: 1.6mm;
  text-align: justify;
  text-align-last: center;
}

/* ==========================================================================
   Structured Recruitment Tables (Formal College Style)
   ========================================================================== */

.recruitment-section {
  margin-bottom: 2.2mm;
  z-index: 2;
}

.section-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 9px;
  border-radius: 3px 3px 0 0;
  font-size: 10.8px;
}

.tech-header {
  background: #0f3b75;
  color: #ffffff;
}

.nontech-header {
  background: #065f46;
  color: #ffffff;
}

.sh-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sh-icon {
  font-size: 11.5px;
}

.sh-title-bn {
  font-weight: 700;
  font-size: 11.2px;
}

.sh-title-en {
  font-family: var(--font-en);
  font-size: 9.2px;
  opacity: 0.9;
}

.sh-right-tag {
  font-size: 9.8px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.2);
  padding: 1px 8px;
  border-radius: 3px;
}

.recruitment-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  line-height: 1.32;
  background-color: rgba(255, 255, 255, 0.97);
  border: 1px solid #475569;
}

.recruitment-table th {
  background: #f1f5f9;
  color: #0f172a;
  font-weight: 700;
  font-size: 9.8px;
  padding: 3.5px 6px;
  border: 1px solid #475569;
  text-align: center;
}

.recruitment-table td {
  padding: 3px 6px;
  border: 1px solid #64748b;
  vertical-align: middle;
  color: #0f172a;
}

.recruitment-table tbody tr:nth-child(even) {
  background-color: rgba(248, 250, 252, 0.7);
}

.dept-title-en {
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 10.4px;
  color: #0d3880;
}

.dept-title-bn {
  font-size: 9.4px;
  color: #475569;
  font-weight: 500;
}

.subject-en {
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 10.4px;
  color: #064e3b;
  display: inline-block;
  min-width: 85px;
}

.subject-bn {
  font-size: 9.4px;
  color: #475569;
  font-weight: 500;
}

.role-badge {
  display: inline-block;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 9.2px;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.role-instructor {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.role-lecturer {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.role-bn {
  font-size: 8.8px;
  color: #64748b;
  margin-top: 1px;
}

.vacancy-count {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-weight: 700;
  font-size: 10.2px;
  padding: 1.5px 7px;
  border-radius: 3px;
  border: 1px solid #fde68a;
  white-space: nowrap;
}

.qual-main {
  font-size: 9.6px;
  color: #1e293b;
  font-weight: 600;
  line-height: 1.25;
}

.qual-sub {
  font-size: 8.6px;
  color: #64748b;
  font-style: italic;
  margin-top: 1px;
}

.subtotal-row {
  background: #f1f5f9 !important;
  font-weight: 700;
}

.subtotal-row td {
  padding: 3px 6px;
  border-top: 1.5px solid #475569;
}

/* Unified Qualification Card in Non-Tech table */
.unified-qual-cell {
  background: #fafaf9;
  padding: 4px 7px !important;
  vertical-align: top !important;
}

.qual-card {
  font-size: 9.4px;
  line-height: 1.32;
}

.qual-badge {
  font-weight: 700;
  color: #065f46;
  font-size: 9.8px;
  margin-bottom: 2px;
  text-decoration: underline;
}

.qual-text {
  margin-bottom: 3px;
}

.qual-bullets {
  padding-left: 14px;
  font-size: 8.7px;
  color: #334155;
  margin: 0;
}

.qual-bullets li {
  margin-bottom: 1.5px;
}

.badge-total {
  background: #166534;
  color: #ffffff;
  padding: 1px 7px;
  border-radius: 3px;
  font-weight: 800;
  margin-left: 4px;
}

/* Helpers */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.bold { font-weight: 700; }
.text-primary { color: #1e40af; }
.text-success { color: #15803d; }
.text-muted { color: #64748b; }
.small { font-size: 9px; }

/* ==========================================================================
   Formal Application Instructions Box (01711042194 WhatsApp & chandanceo12@gmail.com)
   ========================================================================== */

.formal-application-box {
  background: #ffffff;
  border: 1.8px solid #0d3880;
  border-radius: 5px;
  padding: 5px 9px 6px 9px;
  margin-top: 2mm;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(13, 56, 128, 0.08);
}

.app-box-header {
  font-size: 10.5px;
  font-weight: 700;
  color: #0d3880;
  border-bottom: 1px solid #cbd5e1;
  padding-bottom: 3px;
  margin-bottom: 5px;
}

.app-details-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 8px;
  margin-bottom: 5px;
}

.app-channel-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  padding: 5px 8px;
}

.channel-icon {
  font-size: 20px;
  line-height: 1;
}

.channel-body {
  flex: 1;
}

.channel-label {
  font-size: 9.2px;
  color: #334155;
  font-weight: 600;
}

.channel-value {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.3px;
}

.email-value {
  color: #b91c1c;
}

.phone-value {
  color: #047857;
}

.channel-hint {
  font-size: 8.4px;
  color: #64748b;
  line-height: 1.25;
  margin-top: 1px;
}

.channel-hint strong {
  color: #0f172a;
}

/* Formal Terms List */
.formal-terms-list {
  background: #fcfcfc;
  border-top: 1px dashed #cbd5e1;
  padding-top: 4px;
  font-size: 9.2px;
  line-height: 1.4;
  color: #1e293b;
}

.term-line {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 2px;
}

.term-num {
  font-weight: 700;
  color: #0d3880;
  min-width: 14px;
}

/* ==========================================================================
   Editable Mode Visual Feedback
   ========================================================================== */

body.edit-mode-active .editable-field {
  outline: 1.5px dashed #f59e0b !important;
  background-color: rgba(254, 243, 199, 0.45) !important;
  cursor: text !important;
  border-radius: 3px;
  transition: all 0.2s ease;
}

body.edit-mode-active .editable-field:focus {
  outline: 2px solid #2563eb !important;
  background-color: #ffffff !important;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast-notify {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #22c55e;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10000;
}

.toast-notify.show {
  transform: translateY(0);
  opacity: 1;
}

/* ==========================================================================
   Language View Toggles
   ========================================================================== */

/* Bengali-only Mode */
body.lang-bn .bilingual-en,
body.lang-bn .sh-title-en,
body.lang-bn .dept-title-en,
body.lang-bn .role-badge {
  display: none !important;
}

/* English-only Mode */
body.lang-en .bilingual-bn,
body.lang-en .sh-title-bn,
body.lang-en .dept-title-bn,
body.lang-en .role-bn,
body.lang-en .subject-bn {
  display: none !important;
}

/* ==========================================================================
   Print Optimization (@media print)
   Strictly fits 1 single A4 page with no second page spillover
   ========================================================================== */

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .no-print {
    display: none !important;
  }

  .page-viewport {
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
  }

  .a4-sheet {
    box-shadow: none !important;
    margin: 0 !important;
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    overflow: hidden !important;
  }

  body.mode-pad .a4-sheet {
    background-image: url('letterhead-pad.png') !important;
    background-size: 210mm 297mm !important;
    -webkit-print-color-adjust: exact !important;
  }

  body.mode-stationery .a4-sheet {
    background-image: none !important;
  }

  body.edit-mode-active .editable-field {
    outline: none !important;
    background-color: transparent !important;
  }
}
