@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css'); /* Cho fa-spinner */

#prompt-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.modal-actions {
    text-align: right;
    margin-top: 10px;
}

.modal-actions button {
    margin-left: 10px;
}

#resultBox {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.result-content, .error-content { background: white; padding: 20px; border-radius: 8px; max-width: 600px; }
.loading { text-align: center; padding: 40px; }
.close-result { background: #ff6b6b; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; }

/* Thêm vào public/css/run_prompt.css để làm modal đẹp hơn */

/* Modal overlay: Làm mờ background và centered */
#prompt-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6); /* Mờ hơn một chút */
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px); /* Blur nhẹ cho modern look */
  animation: fadeIn 0.3s ease-out; /* Animation fade in */
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Modal content: Rounded, shadow, gradient border */
.modal-content {
  background: linear-gradient(145deg, #ffffff, #f8f9ff); /* Gradient nhẹ */
  border-radius: 20px; /* Rounded hơn */
  padding: 30px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.15), /* Shadow lớn hơn */
    0 0 0 1px rgba(255, 255, 255, 0.5), /* Inner glow */
    inset 0 1px 0 rgba(255, 255, 255, 0.8); /* Inner highlight */
  border: 1px solid rgba(59, 130, 246, 0.2); /* Blue subtle border */
  position: relative;
  animation: slideUp 0.3s ease-out; /* Slide up animation */
}

@keyframes slideUp {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Header: Title với icon */
.modal-content h3 {
  margin: 0 0 20px;
  font-size: 24px;
  font-weight: 600;
  color: #1f2937; /* Dark gray */
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-content h3::before {
  content: '⚡'; /* Icon lightning cho prompt */
  font-size: 28px;
}

/* Prompt display section */
#prompt-display {
  margin-bottom: 25px;
}

#prompt-display label {
  display: block;
  font-weight: 500;
  color: #374151;
  margin-bottom: 8px;
  font-size: 14px;
}

#promptInput {
  width: 100%;
  min-height: 150px; /* Cao hơn cho dễ đọc */
  padding: 15px;
  border: 2px solid #e5e7eb; /* Border xám nhạt */
  border-radius: 12px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Font sạch */
  font-size: 14px;
  line-height: 1.5;
  resize: vertical; /* Chỉ resize vertical */
  transition: border-color 0.2s, box-shadow 0.2s; /* Smooth transition */
  background: #fafbff; /* Background nhẹ */
}

#promptInput:focus {
  outline: none;
  border-color: #3b82f6; /* Blue focus */
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); /* Glow focus */
}

#promptInput::placeholder {
  color: #9ca3af;
  font-style: italic;
}

/* Small note */
#prompt-display small {
  display: block;
  margin-top: 8px;
  color: #6b7280;
  font-size: 12px;
  font-style: italic;
}

/* Actions: Buttons đẹp hơn, flex layout */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.modal-actions button {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 100px; /* Width cố định */
}

.cancel {
  background: #f3f4f6;
  color: #6b7280;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.cancel:hover {
  background: #e5e7eb;
  transform: translateY(-1px); /* Hover lift */
}

.confirm {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8); /* Gradient blue */
  color: white;
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(59, 130, 246, 0.4);
}

.confirm:active {
  transform: translateY(0);
}

/* Responsive cho mobile */
@media (max-width: 768px) {
  .modal-content {
    padding: 20px;
    margin: 20px;
    width: calc(100% - 40px);
  }
  
  .modal-actions {
    flex-direction: column;
  }
  
  #promptInput {
    min-height: 120px;
  }
}

#resultBox {
  display: none;                     /* JS sẽ bật flex khi cần */
  position: fixed;
  inset: 0;                          /* top:0 right:0 bottom:0 left:0 */
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1001;
  align-items: center;               /* căn dọc giữa */
  justify-content: center;           /* căn ngang giữa */
  padding: 20px;                     /* quan trọng: tạo khoảng trống cho mobile */
  box-sizing: border-box;
  overflow-y: auto;                  /* nếu nội dung quá cao thì scroll */
}

/* Container chính của kết quả */
.result-content,
.error-content {
  position: relative;
  background: linear-gradient(145deg, #ffffff, #f8f9ff);
  border-radius: 24px;
  padding: 32px;
  width: 100%;
  max-width: 760px;                  /* rộng rãi thoải mái */
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 
    0 30px 60px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(59, 130, 246, 0.15);
  animation: popIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Animation đẹp */
@keyframes popIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Tiêu đề */
.result-content h4,
.error-content h4 {
  margin: 0 0 20px 0;
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #059669;
  padding-bottom: 12px;
  border-bottom: 2px solid rgba(34, 197, 94, 0.3);
}

.error-content h4 {
  color: #dc2626;
  border-bottom-color: rgba(239, 68, 68, 0.3);
}

.result-content h4::before { content: "Checkmark"; font-size: 28px; }
.error-content   h4::before { content: "Cross"; font-size: 28px; }

/* Nội dung <pre> – quan trọng nhất */
.result-content pre,
.error-content pre {
  margin: 0;
  padding: 24px;
  background: #f8fafc;
  border-radius: 16px;
  border-left: 6px solid #10b981;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  font-size: 15.5px;
  line-height: 1.7;
  color: #1e293b;
  white-space: pre-wrap;           /* giữ xuống dòng */
  word-wrap: break-word;
  overflow-wrap: anywhere;         /* bắt buộc – fix chuỗi dài */
  word-break: break-word;          /* dự phòng */
  overflow-x: auto;                /* nếu vẫn quá dài thì có scroll ngang */
  max-height: 60vh;
  overflow-y: auto;
}

/* Nút đóng – đẹp và luôn ở góc trên phải */
.close-result {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  transition: all 0.2s ease;
  z-index: 10;
}

.close-result:hover {
  transform: scale(1.1) rotate(90deg);
  background: #dc2626;
}

/* Mobile responsive */
@media (max-width: 768px) {
  #resultBox {
    padding: 10px;
  }
  .result-content,
  .error-content {
    padding: 24px 20px;
    border-radius: 20px;
    max-width: calc(100vw - 20px);
  }
  .result-content pre,
  .error-content pre {
    font-size: 15px;
    padding: 18px;
  }
  .close-result {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
}