/*
 * Smart Fields Component Styles
 *
 * Styles for the smart field editor, chips, and popover.
 */

/* ============================================
   EDITOR CONTAINER
   ============================================ */

.smart-field-editor {
  position: relative;
}

.smart-field-editor-wrapper {
  position: relative;
  border: 1px solid #eceff0;
  border-radius: 8px;
  background: #fff;
}

.smart-field-editor-content {
  padding: 12px;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #000b14;
  outline: none;
}

.smart-field-editor-content:focus {
  outline: none;
}

.smart-field-editor-content:empty::before {
  content: attr(data-placeholder);
  color: #858a8e;
  pointer-events: none;
}

/* Toolbar */
.smart-field-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid #eceff0;
  background: #fafafa;
  border-radius: 0 0 8px 8px;
}

.smart-field-insert-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #52595f;
  background: #fff;
  border: 1px solid #eceff0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.smart-field-insert-btn:hover {
  color: #000b14;
  border-color: #c4c8cc;
  background: #f5f5f5;
}

.smart-field-insert-btn .icon {
  width: 14px;
  height: 14px;
}

/* ============================================
   SMART FIELD CHIP
   ============================================ */

.smart-field-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  margin: 0 2px;
  background: #e0f2fe;
  border-radius: 4px;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #0369a1;
  user-select: none;
  vertical-align: middle;
  white-space: nowrap;
}

.smart-field-chip .icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.smart-field-chip .label {
  line-height: 1;
}

.smart-field-chip .remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 2px;
  padding: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  color: #0369a1;
  background: transparent;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.smart-field-chip .remove:hover {
  opacity: 1;
  background: rgba(3, 105, 161, 0.1);
}

/* ============================================
   FIELD PICKER POPOVER (Portal - rendered at body level)
   ============================================ */

.smart-field-portal-popover {
  position: fixed;
  z-index: 9999;
  min-width: 280px;
  max-width: 320px;
  background: #fff;
  border: 1px solid #eceff0;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.smart-field-portal-popover.hidden {
  display: none;
}

.popover-header {
  padding: 12px 16px;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #52595f;
  border-bottom: 1px solid #eceff0;
}

.popover-body {
  padding: 8px;
}

.field-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.field-option:hover {
  background: #f5f7f8;
}

.field-option.field-option--disabled {
  opacity: 0.5;
  cursor: not-allowed;
  position: relative;
}

.field-option.field-option--disabled:hover {
  background: transparent;
}

.field-option.field-option--disabled:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #050505;
  color: #fff;
  font-size: 12px;
  line-height: 1.2;
  padding: 6px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10001;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.field-option .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #52595f;
  margin-top: 2px;
}

.field-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.field-label {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #000b14;
}

.field-description {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 12px;
  color: #858a8e;
}

/* ============================================
   INLINE INSERT BUTTON
   ============================================ */

.smart-field-inline-btn {
  position: absolute;
  right: 4px;
  top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #f5f7f8;
  border: 1px solid #eceff0;
  border-radius: 4px;
  color: #52595f;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

/* In browser content, position button outside on the right */
.browser-content .smart-field-inline-btn {
  right: -32px;
  top: 50%;
  transform: translateY(-50%);
}

/* In Gmail content, position button outside on the right */
.gmail-content .smart-field-inline-btn {
  right: -32px;
  top: 50%;
  transform: translateY(-50%);
}

.smart-field-editor:hover .smart-field-inline-btn,
.smart-field-editor:focus-within .smart-field-inline-btn {
  opacity: 1;
}

.smart-field-inline-btn:hover {
  background: #e5e7eb;
  color: #000b14;
}

/* ============================================
   AUTO-SAVE INDICATOR
   ============================================ */

.save-indicator {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  padding: 8px 16px;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.save-indicator.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

.save-indicator--saving {
  background: #f5f5f5;
  color: #52595f;
  border: 1px solid #e5e7eb;
}

.save-indicator--success {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.save-indicator--error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}
