/* Enterprise Survey System Design - Left Sidebar Theme */
:root {
  --primary-color: #1e3a8a;
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --accent-color: #059669;
  --accent-hover: #047857;
  --warning-color: #d97706;
  --danger-color: #dc2626;
  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #cbd5e1;
  --border-focus: #3b82f6;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  padding-bottom: 90px; /* space for fixed bottom action bar */
}

/* Header Bar */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--primary-color);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.header-badge {
  background-color: var(--warning-color);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.header-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* Main Layout Wrapper: Left Sidebar + Right Content */
.app-wrapper {
  max-width: 1400px;
  margin: 20px auto;
  padding: 0 20px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

/* Left Sidebar Navigation */
.sidebar-nav {
  width: 260px;
  flex-shrink: 0;
  position: sticky;
  top: 75px;
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  max-height: calc(100vh - 95px);
  overflow-y: auto;
}

.sidebar-header {
  background-color: var(--primary-color);
  color: #ffffff;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border-left: 4px solid transparent;
}

.sidebar-item:last-child {
  border-bottom: none;
}

.sidebar-item:hover {
  background-color: #f1f5f9;
  color: var(--primary-color);
}

.sidebar-item.active {
  background-color: var(--primary-light);
  color: var(--primary-color);
  font-weight: 700;
  border-left-color: var(--primary-color);
}

.item-code {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background-color: #e2e8f0;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.sidebar-item.active .item-code {
  background-color: var(--primary-color);
  color: #ffffff;
}

.sidebar-item.item-phuluc {
  background-color: #fffbeb;
  color: #b45309;
  font-weight: 600;
}

.sidebar-item.item-phuluc .item-code {
  background-color: var(--warning-color);
  color: #ffffff;
}

.sidebar-item.item-phuluc:hover,
.sidebar-item.item-phuluc.active {
  background-color: #fef3c7;
  border-left-color: var(--warning-color);
}

.sidebar-item.item-xacnhan {
  background-color: #ecfdf5;
  color: #047857;
  font-weight: 600;
}

.sidebar-item.item-xacnhan .item-code {
  background-color: var(--accent-color);
  color: #ffffff;
}

.sidebar-item.item-xacnhan:hover,
.sidebar-item.item-xacnhan.active {
  background-color: #d1fae5;
  border-left-color: var(--accent-color);
}

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

/* Right Content Survey Container */
.survey-container {
  flex: 1;
  min-width: 0; /* Prevents grid/table blowout */
}

.doc-header-card {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  color: #ffffff;
  padding: 30px 25px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
  margin-bottom: 25px;
  position: relative;
  overflow: hidden;
}

.doc-header-card::before {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
}

.emblem {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #fbbf24;
  text-transform: uppercase;
  margin-bottom: 8px;
  border-bottom: 2px solid #fbbf24;
  padding-bottom: 3px;
}

.doc-main-title {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.doc-sub-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #93c5fd;
  margin-bottom: 12px;
}

.doc-description {
  font-size: 0.925rem;
  color: #e0f2fe;
  max-width: 800px;
  margin: 0 auto;
  font-style: italic;
}

/* Form Sections */
.form-section {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 25px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  scroll-margin-top: 80px; /* Offset for smooth scrolling with sticky header */
}

.section-header {
  background-color: #f1f5f9;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-tag {
  background-color: var(--primary-color);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-color);
}

.section-body {
  padding: 24px;
}

.sub-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 20px 0 12px 0;
  padding-left: 10px;
  border-left: 4px solid var(--accent-color);
}

/* Form Layout Grid */
.grid-form {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.full-width {
  width: 100%;
}

.half-width {
  width: calc(50% - 10px);
}

.form-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-label.required::after {
  content: " *";
  color: var(--danger-color);
}

.sub-label-hint {
  display: block;
  font-weight: 400;
  font-size: 0.825rem;
  color: #047857;
  margin-top: 2px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.inline-input {
  display: inline-block;
  width: auto;
  min-width: 200px;
  padding: 4px 10px;
  margin-left: 6px;
}

.inline-date {
  width: auto;
  display: inline-block;
}

.inline-group {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
  margin-top: 5px;
}

.custom-checkbox,
.custom-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.custom-checkbox input,
.custom-radio input {
  accent-color: var(--primary-color);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.custom-cb-lg {
  width: 20px;
  height: 20px;
  accent-color: var(--primary-color);
  cursor: pointer;
}

/* Product Group Cards */
.highlight-box {
  background-color: #f0fdf4;
  border: 2px solid #a7f3d0;
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 10px;
}

.product-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.product-card {
  cursor: pointer;
  user-select: none;
}

.product-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.product-card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 10px;
  background-color: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-md);
  text-align: center;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.product-icon {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.product-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.product-card input:checked + .product-card-body {
  border-color: var(--accent-color);
  background-color: #ecfdf5;
  box-shadow: 0 0 0 2px var(--accent-color);
}

.product-card input:checked + .product-card-body .product-name {
  color: var(--accent-hover);
}

/* Survey Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin-top: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.survey-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background-color: #ffffff;
}

.survey-table th,
.survey-table td {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  vertical-align: middle;
}

.survey-table th {
  background-color: #f1f5f9;
  color: var(--primary-color);
  font-weight: 700;
  text-align: center;
  font-size: 0.85rem;
  line-height: 1.3;
}

.survey-table tbody tr:nth-child(even) {
  background-color: #f8fafc;
}

.survey-table tbody tr:hover {
  background-color: #f1f5f9;
}

.unit-cell {
  color: var(--text-muted);
  font-size: 0.825rem;
}

.table-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  transition: border-color 0.2s;
}

.table-input:focus {
  outline: none;
  border-color: var(--border-focus);
  background-color: #eff6ff;
}

.table-textarea {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  resize: vertical;
}

.table-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  background-color: #eff6ff;
}

.short-input {
  width: 80px;
  text-align: center;
  display: inline-block;
}

.inline-flex-gap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Rating Scale Options (1 to 5) */
.rating-options {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rating-options-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.rating-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.rating-label input {
  display: none;
}

.rating-label span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  background-color: #ffffff;
  transition: all 0.2s ease;
}

.rating-label input:checked + span {
  background-color: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-color);
}

.rating-label-sm {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.8rem;
  cursor: pointer;
}

.rating-side-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.rating-hint {
  display: block;
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.numbered-inputs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.numbered-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.numbered-row span {
  font-weight: 700;
}

.footnote-box {
  background-color: #fffbeb;
  border-left: 4px solid var(--warning-color);
  padding: 12px 16px;
  margin-top: 15px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.825rem;
  color: #92400e;
  line-height: 1.4;
}

.footnote-box p {
  margin-bottom: 4px;
}

.footnote-box p:last-child {
  margin-bottom: 0;
}

/* Dynamic Phụ Lục Section */
.phuluc-section {
  border: 2px solid var(--warning-color);
}

.phuluc-header {
  background-color: #fffbeb;
}

.phuluc-tag {
  background-color: var(--warning-color);
}

.phuluc-block {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 2px stroke #e2e8f0;
}

.phuluc-block.hidden {
  display: none !important;
}

.phuluc-block-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--primary-color);
}

.phuluc-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background-color: var(--primary-color);
  color: #ffffff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.9rem;
}

.empty-notice-card {
  text-align: center;
  padding: 40px 20px;
  background-color: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

.notice-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

/* Remuneration & Signature Section */
.confirmation-section {
  border: 2px solid var(--accent-color);
}

.remuneration-banner {
  background-color: #ecfdf5;
  border: 1px solid #6ee7b7;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  color: #065f46;
}

.banner-highlight {
  font-size: 1.05rem;
}

.banner-sub {
  font-size: 0.85rem;
  font-style: italic;
  margin-top: 4px;
}

.signature-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 10px;
}

#signatureCanvas {
  border: 2px dashed #94a3b8;
  border-radius: var(--radius-md);
  background-color: #ffffff;
  cursor: crosshair;
  touch-action: none;
  width: 100%;
  max-width: 600px;
  height: 200px;
}

.canvas-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 600px;
  margin-top: 8px;
}

.canvas-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Bottom Action Bar */
.bottom-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #ffffff;
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
  padding: 12px 20px;
  z-index: 99;
}

.action-bar-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.left-actions,
.right-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.btn-lg {
  padding: 12px 28px;
  font-size: 1.05rem;
}

.btn-primary {
  background-color: var(--primary-color);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: #64748b;
  color: #ffffff;
}

.btn-secondary:hover {
  background-color: #475569;
}

.btn-warning {
  background-color: var(--warning-color);
  color: #ffffff;
}

.btn-warning:hover {
  background-color: #b45309;
}

.btn-outline-danger {
  background-color: transparent;
  border: 1px solid var(--danger-color);
  color: var(--danger-color);
}

.btn-outline-danger:hover {
  background-color: #fef2f2;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

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

.modal-card {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
}

.justify-center {
  justify-content: center;
}

.success-icon {
  font-size: 3.5rem;
  margin-bottom: 10px;
}

.success-msg {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.text-lg { font-size: 1.05rem; }
.mt-1 { margin-top: 4px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

/* Responsive Media Queries */
@media (max-width: 992px) {
  .app-wrapper {
    flex-direction: column;
  }

  .sidebar-nav {
    width: 100%;
    position: sticky;
    top: 55px;
    z-index: 90;
    max-height: none;
  }

  .sidebar-menu {
    flex-direction: row;
    overflow-x: auto;
    padding: 6px 10px;
    gap: 6px;
  }

  .sidebar-header {
    display: none;
  }

  .sidebar-item {
    border-bottom: none;
    border-radius: 6px;
    padding: 6px 10px;
    white-space: nowrap;
    border-left: none;
  }

  .sidebar-item.active {
    border-left: none;
  }

  .half-width {
    width: 100%;
  }

  .doc-main-title {
    font-size: 1.4rem;
  }
}

@media (max-width: 576px) {
  .product-group-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .action-bar-container {
    flex-direction: column;
    gap: 10px;
  }

  .left-actions, .right-actions {
    width: 100%;
    justify-content: space-between;
  }

  .left-actions .btn, .right-actions .btn {
    flex: 1;
  }
}
