/* ==========================================================================
   QLDP SUPPORT FLOATING WIDGET & EMBEDDABLE SDK STYLES
   Designed for compatibility with both modern Next.js and legacy WebForms
   ========================================================================== */

/* 1. Nút nổi bật mở tiện ích (Floating Launcher Button) */
.bcns-paste-hint { display: block; margin-top: 6px; color: #475569; font-size: 12px; line-height: 1.6; }
.bcns-paste-zone { margin-top: 8px; padding: 10px; border: 1px dashed #0284c7; border-radius: 6px; color: #075985; font-size: 12px; cursor: text; }
.bcns-paste-zone:focus { outline: 2px solid #0284c7; outline-offset: 2px; }
.bcns-attachment-list { display: grid; gap: 6px; margin-top: 8px; }
.bcns-attachment-item { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; background: #f8fafc; font-size: 12px; }
.bcns-attachment-item img { width: 56px; height: 42px; object-fit: contain; background: #fff; }
.bcns-attachment-item span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bcns-attachment-item button { padding: 4px 8px; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; color: #b91c1c; cursor: pointer; }

#bcns-support-launcher {
  position: fixed;
  bottom: 40px;
  right: 20px;
  z-index: 999999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #1d4ed8 0%, #0284c7 100%);
  color: #ffffff;
  border: none;
  border-radius: 9999px;
  box-shadow: 0 8px 20px -4px rgba(2, 132, 199, 0.4);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  cursor: grab;
  opacity: 1;
  transition: opacity 0.25s ease, transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
  touch-action: none;
}

#bcns-support-launcher.bcns-launcher-dimmed {
  opacity: 0.6;
}

#bcns-support-launcher:hover,
#bcns-support-launcher:focus,
#bcns-support-launcher.bcns-dragging {
  opacity: 1 !important;
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 28px -5px rgba(2, 132, 199, 0.5), 0 10px 10px -5px rgba(2, 132, 199, 0.4);
  background: linear-gradient(135deg, #1e40af 0%, #0369a1 100%);
}

#bcns-support-launcher.bcns-dragging {
  cursor: grabbing !important;
  transition: none !important;
}

#bcns-support-launcher:active {
  transform: translateY(0) scale(0.98);
}

#bcns-support-launcher svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bcns-badge-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background-color: #ef4444;
  border: 2px solid #ffffff;
  border-radius: 50%;
  animation: bcns-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes bcns-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .7; transform: scale(1.15); }
}

/* 2. Lớp phủ mờ (Modal Overlay) */
#bcns-support-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.25s ease-out;
  box-sizing: border-box;
}

#bcns-support-overlay.bcns-open {
  display: flex;
  opacity: 1;
}

/* 3. Khung hộp thoại (Modal Container) */
#bcns-support-modal {
  background-color: #ffffff;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #1e293b;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

#bcns-support-overlay.bcns-open #bcns-support-modal {
  transform: scale(1);
}

/* Header Modal */
.bcns-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.bcns-modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bcns-modal-close {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
}

.bcns-modal-close:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

/* Thanh Tabs */
.bcns-modal-tabs {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  background-color: #f1f5f9;
  padding: 4px 12px 0 12px;
  gap: 6px;
}

.bcns-tab-btn {
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
}

.bcns-tab-btn:hover {
  color: #0284c7;
  background: rgba(255, 255, 255, 0.6);
}

.bcns-tab-btn.bcns-active {
  color: #0284c7;
  background: #ffffff;
  border-bottom: 2px solid #0284c7;
}

/* Nội dung Body */
.bcns-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.bcns-tab-content {
  display: none;
}

.bcns-tab-content.bcns-active {
  display: block;
}

.bcns-submit-success {
  display: none;
  padding: 30px 18px;
  text-align: center;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
}

#bcns-support-modal.bcns-success-state .bcns-modal-tabs,
#bcns-support-modal.bcns-success-state .bcns-modal-footer,
#bcns-support-modal.bcns-success-state .bcns-tab-content {
  display: none;
}

#bcns-support-modal.bcns-success-state .bcns-submit-success {
  display: block;
}

.bcns-success-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: #16a34a;
  color: #ffffff;
  font-size: 36px;
  font-weight: 700;
  line-height: 58px;
}

.bcns-submit-success h3 {
  margin: 0 0 8px;
  color: #166534;
  font-size: 21px;
}

.bcns-submit-success p {
  margin: 0 0 20px;
  color: #334155;
  font-size: 14px;
  line-height: 1.5;
}

.bcns-success-code-label {
  margin-bottom: 6px;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
}

.bcns-success-code {
  display: inline-block;
  min-width: 160px;
  padding: 10px 20px;
  border: 1px solid #86efac;
  border-radius: 8px;
  background: #ffffff;
  color: #14532d;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .04em;
  user-select: all;
}

.bcns-success-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}

/* Khung hiển thị thông tin ngữ cảnh tự động (Vị trí nghiệp vụ & URL) */
.bcns-context-card {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 12px;
  line-height: 1.5;
}

.bcns-ctx-item {
  display: flex;
  margin-bottom: 4px;
}

.bcns-ctx-item:last-child {
  margin-bottom: 0;
}

.bcns-ctx-label {
  font-weight: 700;
  color: #0369a1;
  width: 140px;
  flex-shrink: 0;
}

.bcns-ctx-value {
  color: #0f172a;
  word-break: break-all;
  font-family: monospace;
}

/* Các trường nhập liệu Form */
.bcns-form-group {
  margin-bottom: 14px;
}

.bcns-form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.bcns-form-label span.bcns-required {
  color: #ef4444;
}

.bcns-form-input,
.bcns-form-select,
.bcns-form-textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  color: #0f172a;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.bcns-form-input:focus,
.bcns-form-select:focus,
.bcns-form-textarea:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

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

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

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

/* Khung File Upload */
.bcns-upload-box {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  background-color: #f8fafc;
  cursor: pointer;
  transition: border-color 0.2s;
}

.bcns-upload-box:hover {
  border-color: #0284c7;
  background-color: #f0f9ff;
}

/* Nút Submit & Actions */
.bcns-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.bcns-btn-submit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: #0284c7;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.bcns-btn-submit:hover {
  background-color: #0369a1;
}

.bcns-btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.bcns-btn-secondary {
  padding: 9px 14px;
  background: #ffffff;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

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

/* Badge & Status Items trong Tra Cứu */
.bcns-ticket-card {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin-bottom: 10px;
  background-color: #ffffff;
  transition: box-shadow 0.2s;
}

.bcns-ticket-card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.bcns-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
}

.bcns-badge-pending { background-color: #fef3c7; color: #b45309; }
.bcns-badge-processing { background-color: #e0f2fe; color: #0369a1; }
.bcns-badge-done { background-color: #dcfce7; color: #15803d; }
.bcns-badge-rejected { background-color: #fee2e2; color: #b91c1c; }

/* Thông báo nổi (Toast Notification) */
#bcns-toast {
  position: fixed;
  bottom: 80px;
  right: 24px;
  z-index: 1000001;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  font-weight: 500;
  display: none;
  opacity: 0;
  transition: opacity 0.3s;
}

#bcns-toast.bcns-show {
  display: block;
  opacity: 1;
}
