/* UpdateForm Specific Styles */

/* Disabled form type (select) and form title (input) – same appearance */
.create-form-container .form-input:disabled,
.create-form-container select.form-input:disabled {
  background: #f3f4f6 !important;
  color: #6b7280 !important;
  border-color: #e5e7eb !important;
  cursor: not-allowed;
  -webkit-text-fill-color: #6b7280;
  opacity: 1;
}

body.night-mode .create-form-container .form-input:disabled,
body.night-mode .create-form-container select.form-input:disabled {
  background: rgba(255, 255, 255, 0.08) !important;
  color: rgba(255, 255, 255, 0.9) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.9);
}

/* Single searchable combobox for form selection */
.form-combobox-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.form-combobox-input {
  margin-bottom: 0;
  padding: 0.625rem 1rem 0.625rem 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.75rem center;
  background-size: 1rem;
}

.form-combobox-input::placeholder {
  color: #9ca3af;
}

/* When dropdown is open, raise wrapper so list isn't clipped by container overflow */
.form-combobox-wrapper--open {
  z-index: 1000;
  position: relative;
}

/* Portal wrapper: no extra layout, list sits inside it */
.form-combobox-list-portal {
  min-width: 0;
}

.form-combobox-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 0;
  margin-top: 0.375rem;
  padding: 0;
  list-style: none;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow:
    0 10px 25px -5px rgba(0, 0, 0, 0.15),
    0 4px 6px -4px rgba(0, 0, 0, 0.1);
  max-height: 16rem;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  border-top: 2px solid #f3f4f6;
}

/* When list is inside portal, position relative to portal div not input */
.form-combobox-list-portal .form-combobox-list {
  position: static;
  margin-top: 0;
  top: auto;
  left: auto;
  right: auto;
  width: 100%;
}

/* Scrollbar styling so it's visible and not overly thin */
.form-combobox-list::-webkit-scrollbar {
  width: 8px;
}

.form-combobox-list::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 4px;
}

.form-combobox-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.form-combobox-list::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

@supports (scrollbar-width: thin) {
  .form-combobox-list {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f3f4f6;
  }
}

.form-combobox-item {
  padding: 0.625rem 1rem 0.625rem 2.5rem;
  font-size: 0.9375rem;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s ease;
  border: none;
  text-align: left;
  width: 100%;
}

.form-combobox-item:hover {
  background-color: #f3f4f6;
}

.form-combobox-item--selected {
  background-color: #fffbeb;
  font-weight: 600;
}

.form-combobox-item--selected:hover {
  background-color: #fef3c7;
}

.form-combobox-item--empty {
  color: #9ca3af;
  cursor: default;
  font-style: italic;
}

.form-combobox-item--empty:hover {
  background: transparent;
}

/* Update form list – dark mode */
body.night-mode .form-combobox-list {
  background: #3a3838;
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  border-top-color: rgba(255, 255, 255, 0.1);
}

body.night-mode .form-combobox-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
}

body.night-mode .form-combobox-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
}

body.night-mode .form-combobox-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

@supports (scrollbar-width: thin) {
  body.night-mode .form-combobox-list {
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.06);
  }
}

body.night-mode .form-combobox-item {
  color: rgba(255, 255, 255, 0.92);
}

body.night-mode .form-combobox-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

body.night-mode .form-combobox-item--selected {
  background-color: rgba(242, 27, 35, 0.2);
  font-weight: 600;
}

body.night-mode .form-combobox-item--selected:hover {
  background-color: rgba(242, 27, 35, 0.28);
}

body.night-mode .form-combobox-item--empty {
  color: rgba(255, 255, 255, 0.55);
}

body.night-mode .form-combobox-item--empty:hover {
  background: transparent;
}

/* Update Form page – dark mode (question section, panels, cards, buttons) */
body.night-mode .question-management-section {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}

body.night-mode .section-title {
  color: rgba(255, 255, 255, 0.98);
}

body.night-mode .panel-title {
  color: rgba(255, 255, 255, 0.9);
  border-bottom-color: rgba(255, 255, 255, 0.15);
}

body.night-mode .questions-list {
  background: rgba(255, 255, 255, 0.04);
}

body.night-mode .questions-list.selected {
  background: linear-gradient(180deg, rgba(242, 27, 35, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
}

body.night-mode .questions-list.available {
  background: rgba(255, 255, 255, 0.04);
}

body.night-mode .question-card:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

body.night-mode .question-card.selected {
  background-color: rgba(242, 27, 35, 0.12);
}

body.night-mode .question-card.available:hover {
  background-color: rgba(16, 185, 129, 0.15);
}

body.night-mode .question-card.selected.required.disabled {
  background-color: rgba(255, 255, 255, 0.06);
}

body.night-mode .question-card.selected.required.disabled:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

body.night-mode .question-card.selected.required.disabled .question-order {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.25) 100%);
}

body.night-mode .question-card.selected.required.disabled .question-text {
  color: rgba(255, 255, 255, 0.6);
}

body.night-mode .question-text {
  color: rgba(255, 255, 255, 0.92);
}

body.night-mode .btn-remove {
  background: rgba(242, 27, 35, 0.25);
  color: #fca5a5;
}

body.night-mode .btn-remove:hover {
  background: rgba(242, 27, 35, 0.4);
}

body.night-mode .btn-add-small {
  background: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
}

body.night-mode .btn-add-small:hover {
  background: rgba(16, 185, 129, 0.4);
}

body.night-mode .empty-state {
  color: rgba(255, 255, 255, 0.6);
}

body.night-mode .empty-form-state {
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.15);
}

body.night-mode .empty-form-state p {
  color: rgba(255, 255, 255, 0.8);
}

/* Update Form modal (Add New Question) – dark mode */
body.night-mode .create-form-container .modal-content,
body.night-mode .modal-content {
  background: #3a3838;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

body.night-mode .create-form-container .modal-header,
body.night-mode .modal-header {
  background: transparent;
  border-bottom-color: rgba(255, 255, 255, 0.15);
}

body.night-mode .create-form-container .modal-header h2,
body.night-mode .modal-header h2 {
  color: rgba(255, 255, 255, 0.98);
}

body.night-mode .create-form-container .btn-close,
body.night-mode .modal-header .btn-close {
  color: rgba(255, 255, 255, 0.8);
}

body.night-mode .create-form-container .btn-close:hover,
body.night-mode .modal-header .btn-close:hover {
  color: #f87171;
}

body.night-mode .create-form-container .modal-footer,
body.night-mode .modal-footer {
  background: transparent;
  border-top: none;
}

/* Success Message */
.success-message {
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  color: #065f46;
  border-radius: 0.75rem;
  border: 1px solid #a7f3d0;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.success-message::before {
  content: '✓';
  font-size: 1.125rem;
  font-weight: bold;
}

body.night-mode .success-message {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.35);
}

/* Question Management Section */
.question-management-section {
  margin-top: 2.5rem;
  padding: 1.5rem;
  background: linear-gradient(145deg, #fafafa 0%, #e5e5e5 100%);
  border-radius: 1rem;
  border: 1px solid #e5e7eb;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

.btn-add {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-add:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

/* Questions Panels */
.questions-panel {
  margin-bottom: 1.5rem;
}

.panel-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed #d1d5db;
}

.questions-list {
  border-radius: 0.625rem;
  background: white;
  border: none;
}

.questions-list.selected {
  background: linear-gradient(180deg, #fffbeb 0%, #fff 100%);
}

.questions-list.available {
  background: white;
}

/* Question Card */
.question-card {
  display: flex;
  align-items: center;
  padding: 0.875rem 1rem;
  border-bottom: none;
  transition: all 0.2s ease;
  gap: 0.75rem;
}

.question-card:hover {
  background-color: #fef3c7;
}

.question-card.selected {
  background-color: #fffbeb;
}

.question-card.available:hover {
  background-color: #ecfdf5;
}

/* Required questions – disabled, cannot be removed */
.question-card.selected.required.disabled {
  background-color: #f3f4f6;
  opacity: 0.95;
  cursor: default;
}

.question-card.selected.required.disabled:hover {
  background-color: #f3f4f6;
}

.question-card.selected.required.disabled .question-order {
  background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
}

.question-card.selected.required.disabled .question-text {
  color: #6b7280;
}

.question-required-badge {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #6b7280;
  background: #e5e7eb;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.question-order {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  background: linear-gradient(135deg, #f21b23 0%, #d91820 100%);
  color: white;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.question-text {
  flex: 1;
  font-size: 0.9375rem;
  color: #374151;
  line-height: 1.4;
}

/* Icon Buttons */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-remove {
  background: #fee2e2;
  color: #dc2626;
}

.btn-remove:hover {
  background: #fecaca;
  transform: scale(1.1);
}

.btn-add-small {
  background: #d1fae5;
  color: #059669;
}

.btn-add-small:hover {
  background: #a7f3d0;
  transform: scale(1.1);
}

/* Empty State */
.empty-state {
  padding: 1.5rem;
  text-align: center;
  color: #9ca3af;
  font-size: 0.875rem;
  font-style: italic;
}

.empty-form-state {
  text-align: center;
  padding: 3rem;
  color: #6b7280;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 0.75rem;
  border: 2px dashed #e5e7eb;
}

.empty-form-state p {
  font-size: 1.125rem;
  font-weight: 500;
  margin: 0;
}

/* Modal Styles - overlay must not be inside an overflow/transform container for fixed to work on mobile */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 1rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: modalSlideUp 0.3s ease;
}

.modal-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  background: transparent;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #1f2937;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #6b7280;
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.2s;
}

.btn-close:hover {
  color: #1f2937;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-top: none;
  background: transparent;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(0);
  }
}

