/* ==========================================
   CSS variables & Reset Styles
   ========================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Kantumruy+Pro:ital,wght@0,100..700;1,100..700&family=Koh+Santepheap:wght@300;400;700&family=Moul&display=swap');

:root {
  /* HSL Color Palette */
  --primary-hue: 220;
  --primary: hsl(var(--primary-hue), 85%, 28%);
  /* Elegant Royal Blue */
  --primary-light: hsl(var(--primary-hue), 80%, 40%);
  --primary-dark: hsl(var(--primary-hue), 90%, 18%);
  --primary-alpha: hsla(var(--primary-hue), 85%, 28%, 0.08);

  --accent-hue: 38;
  --accent: hsl(var(--accent-hue), 95%, 48%);
  /* Warm Gold */
  --accent-dark: hsl(var(--accent-hue), 95%, 38%);
  --accent-light: hsl(var(--accent-hue), 95%, 58%);

  --bg-main: #f5f7fb;
  --bg-card: #ffffff;
  --text-dark: #1e293b;
  --text-muted: #64748b;

  /* Status Colors */
  --color-pending: hsl(35, 95%, 50%);
  --color-processing: hsl(195, 95%, 43%);
  --color-ready: hsl(175, 80%, 35%);
  --color-approved: hsl(150, 80%, 38%);
  --color-completed: hsl(210, 90%, 40%);
  --color-rejected: hsl(0, 85%, 55%);

  /* Shadows and Borders */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 10px 25px -5px rgba(30, 41, 59, 0.08), 0 8px 16px -6px rgba(30, 41, 59, 0.04);
  --shadow-lg: 0 20px 30px -10px rgba(30, 41, 59, 0.12);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-khmer: 'Kantumruy Pro', 'Koh Santepheap', sans-serif;
  --font-moul: 'Khmer Mool1', 'Moul', 'Khmer OS Moul', serif;
  --font-latin: 'Inter', sans-serif;
}

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

body {
  font-family: var(--font-khmer);
  background-color: var(--bg-main);
  color: var(--text-dark);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}

ul {
  list-style: none;
}

/* ==========================================
   Header & Navigation
   ========================================== */
.header-wrapper {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.8rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.logo-section img {
  height: 50px;
  width: auto;
}

.logo-text h1 {
  font-family: 'Koh Santepheap', var(--font-khmer);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.logo-text p {
  font-size: 0.8rem;
  color: var(--accent-dark);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links a {
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links a:hover {
  color: var(--primary-light);
  background-color: var(--primary-alpha);
}

.nav-links a.active {
  color: #fff;
  background-color: var(--primary);
}

.nav-links a.btn-admin {
  border: 1px solid var(--primary-light);
  color: var(--primary);
}

.nav-links a.btn-admin:hover {
  background-color: var(--primary);
  color: #fff;
}

/* ==========================================
   Hero Section
   ========================================== */
.hero-section {
  background: radial-gradient(circle at 10% 20%, rgba(30, 58, 138, 0.05) 0%, rgba(255, 255, 255, 0) 90%), var(--bg-card);
  padding: 4rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary-light));
}

.hero-container {
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.hero-emblem {
  width: 90px;
  height: auto;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.hero-container h2 {
  font-family: 'Koh Santepheap', var(--font-khmer);
  font-size: 2.2rem;
  color: var(--primary);
  margin-bottom: 1rem;
  font-weight: 700;
}

.hero-container p.subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 2rem auto;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ==========================================
   Buttons UI
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.75rem 1.8rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(30, 58, 138, 0.2);
}

.btn-primary:hover {
  background-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(30, 58, 138, 0.3);
}

.btn-secondary {
  background-color: #fff;
  color: var(--text-dark);
  border: 1px solid #cbd5e1;
}

.btn-secondary:hover {
  background-color: #f8fafc;
  transform: translateY(-2px);
}

.btn-accent {
  background-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2);
}

.btn-accent:hover {
  background-color: var(--accent-dark);
  transform: translateY(-2px);
}

/* ==========================================
   Home Services Cards
   ========================================== */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.section-title {
  text-align: center;
  margin-bottom: 2.5rem;
}

.section-title h3 {
  font-family: 'Koh Santepheap', var(--font-khmer);
  font-size: 1.75rem;
  color: var(--primary);
  position: relative;
  display: inline-block;
  padding-bottom: 0.75rem;
}

.section-title h3::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 25%;
  width: 50%;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 2rem;
}

.service-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 2rem;
  border: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.service-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(30, 58, 138, 0.15);
}

.service-icon-box {
  width: 60px;
  height: 60px;
  background-color: var(--primary-alpha);
  color: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  font-size: 1.5rem;
}

.service-card h4 {
  font-family: 'Koh Santepheap', var(--font-khmer);
  font-size: 1.2rem;
  color: var(--primary);
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.service-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  flex: 1;
}

.service-meta {
  border-top: 1px dashed #e2e8f0;
  padding-top: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.service-meta span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-dark);
}

.service-meta span i {
  color: var(--accent-dark);
}

/* ==========================================
   Forms Layout
   ========================================== */
.card-container {
  max-width: 700px;
  margin: 0 auto;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(226, 232, 240, 0.8);
  overflow: hidden;
}

.card-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  padding: 1.5rem 2rem;
  position: relative;
}

.card-header h3 {
  font-family: 'Koh Santepheap', var(--font-khmer);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.card-header p {
  font-size: 0.85rem;
  opacity: 0.85;
}

.card-body {
  padding: 2rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.form-group label span.required {
  color: var(--color-rejected);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid #9CA3AF !important;
  font-family: var(--font-khmer);
  font-size: 0.9rem;
  color: var(--primary) !important;
  background-color: #F3F4F6 !important;
  transition: var(--transition);
}

.form-control:hover {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 1px var(--primary) !important;
}

.form-control:focus,
.form-control.has-value {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 1px var(--primary), 0 0 0 3px var(--primary-alpha) !important;
  color: #d84315 !important; /* ប្តូរទៅពណ៌ទឹកក្រូចចាស់ពេលបញ្ចូលទិន្នន័យរួច ឬកំពុងបញ្ចូល */
}

/* Global data entry input fields styling */
input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
select,
textarea {
  background-color: #F3F4F6 !important;
  border: 1px solid #9CA3AF !important;
  color: var(--primary) !important;
  transition: var(--transition);
}

input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):hover,
select:hover,
textarea:hover {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 1px var(--primary) !important;
}

input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):focus,
input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]).has-value,
select:focus,
select.has-value,
textarea:focus,
textarea.has-value {
  border-color: var(--primary) !important;
  outline: none !important;
  box-shadow: 0 0 0 1px var(--primary), 0 0 0 3px var(--primary-alpha) !important;
  color: #d84315 !important; /* ប្តូរទៅពណ៌ទឹកក្រូចចាស់ពេលបញ្ចូលទិន្នន័យរួច ឬកំពុងបញ្ចូល */
}

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

/* Custom File Upload Input */
.file-upload-wrapper {
  position: relative;
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  text-align: center;
  background-color: #f8fafc;
  cursor: pointer;
  transition: var(--transition);
}

.file-upload-wrapper:hover {
  border-color: var(--primary-light);
  background-color: var(--primary-alpha);
}

.file-upload-wrapper input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload-info i {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.file-upload-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Alert Boxes */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-left: 4px solid;
}

.alert-success {
  background-color: hsl(150, 80%, 95%);
  color: hsl(150, 80%, 25%);
  border-left-color: var(--color-approved);
}

.alert-danger {
  background-color: hsl(0, 85%, 96%);
  color: hsl(0, 85%, 35%);
  border-left-color: var(--color-rejected);
}

/* ==========================================
   Success and Tracking Results
   ========================================== */
.success-card {
  text-align: center;
  padding: 2.5rem 2rem;
}

.success-icon-box {
  width: 80px;
  height: 80px;
  background-color: hsl(150, 80%, 95%);
  color: var(--color-approved);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto 1.5rem auto;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.15);
}

.success-card h3 {
  font-family: 'Koh Santepheap', var(--font-khmer);
  color: var(--color-approved);
  font-size: 1.6rem;
  margin-bottom: 1rem;
}

.tracking-code-display {
  background-color: #f1f5f9;
  border: 1px dashed #cbd5e1;
  padding: 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-latin);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--primary);
  margin: 1.5rem 0;
  display: inline-block;
  width: 100%;
  max-width: 320px;
}

.success-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

/* Tracking Result Card */
.tracking-result-box {
  margin-top: 2rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 2rem;
}

.status-timeline {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
  padding-left: 1.5rem;
}

.status-timeline::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: #e2e8f0;
}

.timeline-item {
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #cbd5e1;
  border: 2px solid #fff;
}

.timeline-item.active::before {
  background-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-alpha);
}

.tracking-details-table {
  width: 100%;
  margin-top: 1.5rem;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.tracking-details-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
}

.tracking-details-table td.label {
  font-weight: 600;
  color: var(--text-muted);
  width: 40%;
}

.tracking-details-table td.value {
  color: var(--text-dark);
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 30px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-badge.pending {
  background-color: hsl(35, 95%, 95%);
  color: var(--color-pending);
}

.status-badge.processing {
  background-color: hsl(195, 95%, 95%);
  color: var(--color-processing);
}

.status-badge.ready {
  background-color: hsl(175, 80%, 94%);
  color: var(--color-ready);
}

.status-badge.approved {
  background-color: hsl(150, 80%, 94%);
  color: var(--color-approved);
}

.status-badge.completed {
  background-color: hsl(210, 90%, 94%);
  color: var(--color-completed);
}

.status-badge.rejected {
  background-color: hsl(0, 85%, 95%);
  color: var(--color-rejected);
}

/* ==========================================
   Admin View & Dashboard
   ========================================== */
.admin-container {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 2rem;
}

@media (max-width: 900px) {
  .admin-container {
    grid-template-columns: 1fr;
  }
}

.admin-sidebar {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  border: 1px solid rgba(226, 232, 240, 0.8);
  height: fit-content;
}

.admin-sidebar h4 {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 1rem;
}

.sidebar-menu li {
  margin-bottom: 0.5rem;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
  background-color: var(--primary-alpha);
  color: var(--primary);
}

.admin-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
  overflow: hidden;
}

.admin-card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.admin-card-header h3 {
  font-family: 'Koh Santepheap', var(--font-khmer);
  font-size: 1.2rem;
  color: var(--primary);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-item {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.stat-icon.blue {
  background-color: rgba(30, 58, 138, 0.1);
  color: var(--primary);
}

.stat-icon.orange {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--color-pending);
}

.stat-icon.green {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-approved);
}

.stat-icon.red {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--color-rejected);
}

.stat-info h5 {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-info p {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-dark);
}

/* Data Table UI */
.table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  padding: 1rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
}

.data-table th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
}

.data-table tbody tr {
  transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
  background-color: rgba(14, 42, 109, 0.12);
}

.btn-action {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-view {
  background-color: var(--primary-alpha);
  color: var(--primary);
}

.btn-view:hover {
  background-color: var(--primary);
  color: #fff;
}

/* Modal / Request Detail Dialog */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-content {
  background: var(--bg-card);
  width: 100%;
  max-width: 650px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  background-color: var(--primary);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-family: 'Koh Santepheap', var(--font-khmer);
  font-size: 1.15rem;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.8;
}

.modal-close-btn:hover {
  opacity: 1;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.admin-update-form {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
}

/* ==========================================
   Footer Section
   ========================================== */
footer {
  background-color: var(--primary-dark);
  color: rgba(255, 255, 255, 0.7);
  padding: 3rem 1.5rem 1.5rem 1.5rem;
  border-top: 4px solid var(--accent);
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1.2fr;
  gap: 2.5rem;
}

@media (max-width: 768px) {
  .footer-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

.footer-info h4 {
  font-family: 'Koh Santepheap', var(--font-khmer);
  color: #fff;
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.footer-info p {
  font-size: 0.88rem;
  line-height: 1.7;
}

.footer-links h5,
.footer-contact h5 {
  color: #fff;
  font-size: 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a:hover {
  color: var(--accent);
  padding-left: 4px;
}

.footer-contact li {
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.footer-contact li i {
  color: var(--accent);
}

.footer-bottom {
  max-width: 1200px;
  margin: 2.5rem auto 0 auto;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  font-size: 0.8rem;
}

/* ==========================================
   Print and Report Custom Styles
   ========================================== */
.data-table th[colspan] {
  text-align: center;
  border-bottom: 1px solid #cbd5e1;
}

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

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  body {
    background-color: #fff !important;
    color: #1e293b !important;
    font-size: 11pt !important;
    padding: 0.5in !important;
  }

  .header-wrapper,
  .admin-sidebar,
  footer,
  .btn,
  .btn-action,
  .admin-stats,
  .admin-card-header form,
  .logo-section svg,
  .logo-text p {
    display: none !important;
  }

  .main-content {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  .admin-container {
    display: block !important;
  }

  .admin-card {
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .admin-card-header {
    border-bottom: 2px solid #1e3a8a !important;
    padding: 0 0 1rem 0 !important;
    margin-bottom: 2rem !important;
  }

  .admin-card-header h3 {
    font-size: 1.6rem !important;
    color: #1e3a8a !important;
  }

  .data-table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  .data-table th,
  .data-table td {
    padding: 0.5rem 0.75rem !important;
    border: 1px solid #cbd5e1 !important;
    color: #000 !important;
  }

  .data-table th {
    background-color: #f1f5f9 !important;
    font-weight: bold !important;
  }

  tr[style*="background-color: #f1f5f9"] {
    background-color: #f1f5f9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

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

  .print-only {
    display: block !important;
  }

  .table-wrapper {
    overflow: visible !important;
  }
}

.btn-excel {
  background-color: #16a34a;
  color: #fff;
  box-shadow: 0 4px 10px rgba(22, 163, 74, 0.2);
}

.btn-excel:hover {
  background-color: #15803d;
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(22, 163, 74, 0.3);
  color: #fff;
}

/* ==========================================
   Administrative Forms Styles (Split Layout)
   ========================================== */
.forms-dashboard {
  display: block;
}

@media (max-width: 1024px) {
  .forms-dashboard {
    grid-template-columns: 1fr;
  }
}

.forms-sidebar {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  border: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.forms-sidebar h4 {
  font-family: 'Koh Santepheap', var(--font-khmer);
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.5rem;
}

#form_inputs_container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem 1.5rem;
}

.form-section-header {
  grid-column: span 2;
  font-family: 'Koh Santepheap', var(--font-khmer);
  color: var(--primary);
  font-weight: 700;
  font-size: 1.05rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.25rem;
}

.form-section-header:first-child {
  margin-top: 0;
}

@media (max-width: 768px) {
  #form_inputs_container {
    grid-template-columns: 1fr;
  }

  .form-section-header {
    grid-column: span 1;
  }
}

.forms-preview-container {
  display: flex;
  justify-content: center;
  overflow-x: auto;
  padding: 1rem;
  background-color: #cbd5e1;
  border-radius: var(--radius-md);
  min-height: 80vh;
  position: absolute;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  pointer-events: none;
}

/* Simulated A4 Sheet */
.a4-sheet {
  background: #ffffff;
  width: 210mm;
  min-height: 297mm;
  padding: 0.7in;
  /* Margins top=0.7" bottom=0.7" left=0.7" right=0.7" */
  margin: 0 auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  border: 1px solid #cbd5e1;
  position: relative;
  box-sizing: border-box;
  font-family: 'Koh Santepheap', 'Kantumruy Pro', sans-serif;
  color: #000000;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

.a4-sheet-content {
  flex: 1;
}

/* Administrative Form Elements */
.doc-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  position: relative;
}

.doc-left {
  text-align: left;
  font-family: var(--font-moul);
  font-weight: normal !important;
  font-size: 10pt !important;
  line-height: 1.6;
  margin-left: -3mm;
  margin-top: 2rem;
}

.doc-left strong,
.doc-left b,
.doc-left span {
  font-weight: normal !important;
}

.photo-box {
  width: 3.0cm;
  height: 4.0cm;
  border: 1px solid #000;
  box-sizing: border-box;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 0.95rem;
  font-weight: bold;
  color: #334155;
  background-color: #f8fafc;
  margin-bottom: 0.4rem;
  margin-left: auto;
  text-align: center;
  line-height: 1.4;
}

.doc-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  text-align: center;
  font-size: 1.06rem;
  line-height: 1.5;
  width: 100%;
  max-width: 250px;
  pointer-events: none;
}

.doc-center .motto {
  font-weight: normal;
  font-family: var(--font-moul);
}

.doc-center .separator {
  margin: 0.25rem auto 0 auto;
  width: 6.5rem;
  height: 1.5px;
  background-color: #000;
}

.doc-right {
  text-align: right;
  font-size: 0.93rem;
  line-height: 1.5;
  margin-top: 4.3rem;
  margin-right: -3mm;
}

.doc-title {
  text-align: center;
  margin: 1.5rem 0;
}

.doc-title h2 {
  font-family: var(--font-moul);
  font-size: 1.11rem;
  font-weight: normal;
  margin-bottom: 0.25rem;
}

.doc-body {
  font-size: 1.12rem;
  line-height: 1.5;
  text-align: justify;
  text-justify: inter-word;
}

.doc-body p {
  text-indent: 1.5cm;
  margin-bottom: 0.4rem;
}

/* Force override inline spacing for preview forms to ensure consistency and prevent spilling onto second page */
.a4-sheet .doc-body p,
.a4-sheet .doc-body div[style*="line-height"] {
  line-height: 1.5 !important;
}

.a4-sheet .doc-body p[style*="margin-bottom"] {
  margin-bottom: 0.4rem !important;
}

.a4-sheet .doc-body div[style*="margin-bottom: 1rem"],
.a4-sheet .doc-body div[style*="margin-bottom:1rem"] {
  margin-bottom: 0.4rem !important;
}

.a4-sheet .doc-body p[style*="font-weight: bold"],
.a4-sheet .doc-body p[style*="font-weight:bold"] {
  text-indent: 0 !important;
}

.doc-footer {
  margin-top: 2rem;
  display: flex;
  justify-content: space-between;
  font-size: 1.01rem;
}

.doc-footer-left {
  text-align: center;
  width: 45%;
}

.doc-footer-right {
  text-align: center;
  width: 45%;
}

.doc-footer-date {
  margin-bottom: 0.5rem;
  font-style: italic;
}

.doc-footer-title {
  font-family: var(--font-moul);
  font-weight: normal;
}

.doc-footer-space {
  height: 5rem;
}

/* Print Styles for Forms Dashboard */
@media print {
  body.printing-form {
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    height: 100% !important;
    background-color: #ffffff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body.printing-form>*:not(#print_area_temp) {
    display: none !important;
  }

  body.printing-form #print_area_temp {
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    background-color: transparent !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body.printing-form #print_area_temp.a4-sheet {
    height: auto !important;
    max-height: none !important;
    padding: 0.7in !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    background-color: #ffffff !important;
    overflow: visible !important;
    page-break-inside: avoid !important;
    page-break-after: avoid !important;
  }

  body.printing-form #print_area_temp .a4-sheet {
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    padding: 0.7in !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    background-color: #ffffff !important;
    overflow: visible !important;
    page-break-inside: avoid !important;
    page-break-after: always !important;
  }

  body.printing-form #print_area_temp .a4-sheet.civil-status-form {
    box-shadow: none !important;
    border: none !important;
    width: 210mm !important;
    height: 297mm !important;
    max-height: 297mm !important;
    padding: 0.5in 0.7in 0.5in 0.7in !important;
    margin: 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    background-color: #ffffff !important;
    overflow: hidden !important;
    page-break-inside: avoid !important;
    page-break-after: always !important;
  }

  body.printing-form #print_area_temp .a4-sheet.civil-status-form:last-child {
    page-break-after: avoid !important;
  }

}

/* Preview Modal Styles */
.preview-modal {
  display: none;
  position: fixed;
  z-index: 1050;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.preview-modal-content {
  background-color: #f1f5f9;
  margin: 3vh auto;
  padding: 1.5rem;
  border-radius: var(--radius-md);
  width: 90%;
  max-width: 220mm;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(226, 232, 240, 0.8);
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.preview-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
}

.preview-modal-header h4 {
  font-family: 'Koh Santepheap', var(--font-khmer);
  color: var(--primary);
  font-weight: 700;
  margin: 0;
  font-size: 1.1rem;
}

.preview-modal-close {
  color: #64748b;
  font-size: 1.75rem;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.preview-modal-close:hover {
  color: #ef4444;
}

.preview-modal-body {
  display: flex;
  justify-content: center;
  overflow-x: auto;
  padding: 0.5rem;
}

.preview-modal-body .a4-sheet {
  box-shadow: var(--shadow-md) !important;
  margin: 0 auto !important;
}

/* ==========================================================================
   Global Font-Size Override for Administrative Forms (Size 12pt)
   ========================================================================== */
.a4-sheet:not(.civil-status-form),
.a4-sheet:not(.civil-status-form) table,
.a4-sheet:not(.civil-status-form) td,
.a4-sheet:not(.civil-status-form) p,
.a4-sheet:not(.civil-status-form) li,
.a4-sheet:not(.civil-status-form) span:not(.motto):not(.separator),
.a4-sheet:not(.civil-status-form) div:not(.doc-center):not(.doc-title):not(.photo-box):not(.a4-sheet) {
  font-size: 12pt !important;
}

/* Keep Moul titles and form names at appropriate scale */
.a4-sheet:not(.civil-status-form) h2,
.a4-sheet:not(.civil-status-form) h3,
.a4-sheet:not(.civil-status-form) .doc-center .motto,
.a4-sheet:not(.civil-status-form) .doc-title h2 {
  font-size: 13pt !important;
}

.photo-box.no-photo {
  border-color: transparent !important;
  background-color: transparent !important;
  color: transparent !important;
}

.doc-photo-box.no-photo {
  border-color: transparent !important;
  background-color: transparent !important;
  color: transparent !important;
}