/**
 * Excel Custom Field modal - opened from project iframe via postMessage in index.
 * Layout and CSS aligned with www folder (project.html / inhouse project.html).
 */
.excel-custom-field-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.excel-custom-field-modal.show {
  display: flex !important;
}
/* Match www: .excel-custom-field-modal .modal-content - width 50%, max-width 80% */
.excel-custom-field-modal .modal-content {
  position: relative;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 24px;
  width: 50%;
  max-width: 80%;
  background: white;
  border-radius: var(--border-radius, 12px);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}

/* In-modal spinner overlay (shown while saving) */
.excel-custom-field-modal .excel-custom-field-spinner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  z-index: 20;
  border-radius: inherit;
}
.excel-custom-field-modal .excel-custom-field-spinner-overlay[hidden] {
  display: none !important;
}
.excel-custom-field-modal .excel-custom-field-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(15, 23, 42, 0.1);
  border-top-color: var(--create-task-primary, #dc2626);
  border-radius: 50%;
  animation: excel-custom-field-spin 0.8s linear infinite;
}
.excel-custom-field-modal .excel-custom-field-spinner-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600, #4b5563);
}
@keyframes excel-custom-field-spin {
  to { transform: rotate(360deg); }
}
.excel-custom-field-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
}
.excel-custom-field-modal .modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800, #1f2937);
}
.excel-custom-field-modal .close-btn {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: #64748b;
  font-size: 18px;
  line-height: 1;
}
.excel-custom-field-modal .close-btn:hover {
  color: #0f172a;
}
.excel-custom-field-modal .modal-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
  margin-top: 8px;
}
.excel-custom-field-modal .modal-footer {
  flex-shrink: 0;
  padding-top: 12px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  justify-content: flex-end;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #ffffff 80%);
}
.excel-custom-field-modal .modal-footer .form-actions {
  margin: 0;
  padding: 0;
  display: flex;
  gap: 10px;
}
.excel-custom-field-modal .form-group {
  margin-bottom: 16px;
}
.excel-custom-field-modal .form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700, #334155);
  margin-bottom: 6px;
}
.excel-custom-field-modal .form-input,
.excel-custom-field-modal .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-200, #e2e8f0);
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
}
.excel-custom-field-modal .form-textarea {
  min-height: 450px;
  resize: vertical;
}
.excel-custom-field-modal .btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
}
.excel-custom-field-modal .btn-secondary {
  background: #f1f5f9;
  color: #475569;
}
.excel-custom-field-modal .btn-primary {
  background: var(--create-task-primary, #dc2626);
  color: #fff;
}
/* Multiselect - match www */
.excel-custom-field-modal .custom-field-multiselect {
  min-height: 120px;
}

/* URL list - match www: row with input + Remove button */
.excel-custom-field-modal .custom-field-url-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.excel-custom-field-modal .custom-field-url-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.excel-custom-field-modal .custom-field-url-input-row input[type="url"] {
  flex: 1;
  width: auto;
  margin-bottom: 0;
}
.excel-custom-field-modal .custom-field-link-btn {
  background: none;
  border: none;
  color: var(--create-task-primary, #dc2626);
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
  text-align: left;
  width: fit-content;
}
.excel-custom-field-modal .custom-field-link-btn.danger {
  color: #ef4444;
}
.excel-custom-field-modal .custom-field-link-btn.undo {
  color: var(--create-task-primary, #dc2626);
  font-weight: 600;
}
.excel-custom-field-modal .custom-field-link-btn:hover {
  text-decoration: underline;
}
.excel-custom-field-modal .custom-field-url-list input[type="url"] {
  padding: 8px 12px;
  border: 1px solid var(--gray-200, #e2e8f0);
  border-radius: 6px;
}
.excel-custom-field-modal .custom-field-secondary-btn {
  padding: 6px 14px;
  font-size: 13px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 8px;
}

/* File field - match www dropzone and file list */
.excel-custom-field-modal .custom-field-dropzone {
  border: 1px dashed var(--gray-300, #d1d5db);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #f8fafc;
}
.excel-custom-field-modal .custom-field-dropzone.dragover {
  border-color: var(--create-task-primary, #dc2626);
  background: rgba(220, 38, 38, 0.05);
}
.excel-custom-field-modal .custom-field-dropzone button {
  padding: 6px 14px;
}
.excel-custom-field-modal .custom-field-dropzone-hint {
  font-size: 12px;
  color: var(--gray-500, #64748b);
  text-align: center;
}
.excel-custom-field-modal .custom-field-file-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.excel-custom-field-modal .custom-field-file-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: 8px;
  background: #fff;
}
.excel-custom-field-modal .custom-field-file-item.pending-upload {
  border-style: dashed;
  border-color: var(--create-task-primary, #dc2626);
  background: rgba(220, 38, 38, 0.05);
}
.excel-custom-field-modal .custom-field-file-item.pending-removal {
  opacity: 0.6;
  border-color: rgba(220, 38, 38, 0.4);
  background: rgba(220, 38, 38, 0.08);
}
.excel-custom-field-modal .custom-field-file-preview-wrapper {
  flex: 0 0 auto;
  max-width: 260px;
  width: 100%;
}
.excel-custom-field-modal .custom-field-file-preview {
  width: 100%;
  max-height: 200px;
  border-radius: 6px;
  background: #000;
  display: block;
  object-fit: contain;
}
.excel-custom-field-modal .custom-field-file-preview.audio {
  max-height: none;
  background: transparent;
}
.excel-custom-field-modal .custom-field-file-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.excel-custom-field-modal .custom-field-file-name {
  font-weight: 600;
  color: var(--gray-800, #1f2937);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.excel-custom-field-modal .custom-field-file-info {
  font-size: 12px;
  color: var(--gray-500, #6b7280);
}
.excel-custom-field-modal .custom-field-file-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.excel-custom-field-modal .custom-field-file-empty {
  font-size: 13px;
  color: var(--gray-500, #6b7280);
  border: 1px dashed var(--gray-200, #e5e7eb);
  border-radius: 6px;
  padding: 10px 12px;
}
/* Rich text editor - match www .custom-field-rich-text-wrapper */
.excel-custom-field-modal .custom-field-rich-text-wrapper {
  border: 1px solid var(--gray-300, #d1d5db);
  border-radius: 6px;
  background: #fff;
  min-height: 200px;
}
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-container {
  border: none;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  min-height: 200px;
}
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-editor {
  min-height: 200px;
  padding: 12px 15px;
  color: var(--gray-800, #1f2937);
}
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-editor.ql-blank::before {
  color: var(--gray-400, #9ca3af);
  font-style: normal;
}
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar {
  border-bottom: 1px solid var(--gray-200, #e5e7eb);
  background: var(--gray-50, #f9fafb);
  padding: 8px;
}
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar .ql-stroke {
  stroke: var(--gray-600, #4b5563);
}
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar .ql-fill {
  fill: var(--gray-600, #4b5563);
}
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar button:hover,
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar button.ql-active {
  color: var(--primary-color, #dc2626);
}
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar button:hover .ql-stroke,
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar button.ql-active .ql-stroke {
  stroke: var(--primary-color, #dc2626);
}
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar button:hover .ql-fill,
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar button.ql-active .ql-fill {
  fill: var(--primary-color, #dc2626);
}
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-editor a {
  color: var(--primary-color, #dc2626);
  text-decoration: underline;
}
.excel-custom-field-modal .custom-field-rich-text-wrapper .ql-editor a:hover {
  text-decoration: none;
}

@media (max-width: 768px) {
  .excel-custom-field-modal {
    padding: 16px;
    align-items: center;
    justify-content: center;
    padding-bottom: env(safe-area-inset-bottom, 16px);
  }
  .excel-custom-field-modal .modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    max-height: calc(100vh - 32px);
    padding: 20px;
    margin: 0;
    border-radius: 12px;
    box-sizing: border-box;
  }
  .excel-custom-field-modal .modal-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    flex-shrink: 0;
  }
  .excel-custom-field-modal .modal-title {
    font-size: 17px;
    line-height: 1.3;
    padding-right: 12px;
    min-width: 0;
    word-break: break-word;
  }
  .excel-custom-field-modal .close-btn {
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }
  .excel-custom-field-modal .modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
    margin-top: 0;
  }
  .excel-custom-field-modal .modal-footer {
    flex-shrink: 0;
    padding-top: 20px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    border-top: 1px solid rgba(15, 23, 42, 0.08);
  }
  .excel-custom-field-modal .modal-footer .form-actions {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    gap: 16px;
    width: 100%;
  }
  .excel-custom-field-modal .modal-footer .btn {
    min-height: 44px;
    padding: 12px 24px;
    font-size: 15px;
    min-width: 0;
    flex: none;
  }
  .excel-custom-field-modal .modal-footer .btn-secondary {
    padding: 12px 20px;
  }
  .excel-custom-field-modal .modal-footer .btn-primary {
    padding: 12px 24px;
  }
  .excel-custom-field-modal .form-group {
    margin-bottom: 14px;
  }
  .excel-custom-field-modal .form-label {
    font-size: 13px;
    margin-bottom: 6px;
  }
  .excel-custom-field-modal .form-input,
  .excel-custom-field-modal .form-textarea {
    padding: 12px;
    font-size: 16px;
    min-height: 44px;
  }
  .excel-custom-field-modal .form-textarea {
    min-height: 160px;
  }
  .excel-custom-field-modal .custom-field-multiselect {
    min-height: 100px;
  }
  .excel-custom-field-modal .custom-field-url-input-row {
    flex-wrap: wrap;
  }
  .excel-custom-field-modal .custom-field-url-input-row input[type="url"] {
    min-width: 0;
    font-size: 16px;
  }
  .excel-custom-field-modal .custom-field-link-btn,
  .excel-custom-field-modal .custom-field-secondary-btn {
    min-height: 44px;
    padding: 10px 14px;
  }
  .excel-custom-field-modal .custom-field-dropzone {
    padding: 16px 12px;
  }
  .excel-custom-field-modal .custom-field-dropzone-hint {
    font-size: 11px;
  }
  .excel-custom-field-modal .custom-field-file-item {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .excel-custom-field-modal .custom-field-file-preview-wrapper {
    max-width: 100%;
  }
  .excel-custom-field-modal .custom-field-file-preview {
    max-height: 160px;
  }
  .excel-custom-field-modal .custom-field-file-actions {
    flex-wrap: wrap;
  }
  /* Rich text editor - mobile: compact toolbar, more space for editor */
  .excel-custom-field-modal .custom-field-rich-text-wrapper {
    min-height: 180px;
    width: 100%;
    border-radius: 8px;
  }
  .excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar {
    padding: 4px 6px;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    background: var(--gray-50, #f9fafb);
    font-size: 12px;
  }
  .excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar .ql-formats {
    margin-right: 4px;
  }
  .excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar button {
    min-width: 28px;
    min-height: 28px;
    padding: 4px;
  }
  .excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar button .ql-stroke {
    stroke-width: 1.5;
  }
  .excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar .ql-picker {
    min-height: 28px;
    padding: 2px 4px;
  }
  .excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar .ql-picker-label {
    padding: 2px 6px;
    font-size: 12px;
  }
  .excel-custom-field-modal .custom-field-rich-text-wrapper .ql-toolbar .ql-picker-options {
    padding: 4px;
  }
  .excel-custom-field-modal .custom-field-rich-text-wrapper .ql-container {
    border: none;
    min-height: 180px;
  }
  .excel-custom-field-modal .custom-field-rich-text-wrapper .ql-editor {
    min-height: 180px;
    padding: 12px 14px;
    font-size: 16px;
    line-height: 1.5;
  }
  .excel-custom-field-modal .custom-field-rich-text-wrapper .ql-editor.ql-blank::before {
    font-size: 16px;
  }
}
