/**
 * ╔════╗─────────────╔╗───────────────╔╗──────╔════╗╔═══╗╔═══╗╔═╗─╔╗╔═══╗──╔═══╗╔═══╗╔═══╗
 * ║╔╗╔╗║─────────────║║───────────────║║──────║╔╗╔╗║║╔═╗║║╔═╗║║║╚╗║║║╔═╗║──║╔═╗║║╔═╗║║╔═╗║
 * ╚╝║║╚╝╔╗─╔╗╔══╗╔══╗║║───╔══╗╔══╗╔══╗║╚═╦╗─╔╗╚╝║║╚╝║╚═╝║║║─║║║╔╗╚╝║║║─╚╝──║╚═╝║║╚═╝║║║─║║
 * ──║║──║║─║║║╔╗║║║═╣║║─╔╗║║═╣║══╣║══╣║╔╗║║─║║──║║──║╔╗╔╝║║─║║║║╚╗║║║║╔═╗──║╔══╝║╔╗╔╝║║─║║
 * ──║║──║╚═╝║║╚╝║║║═╣║╚═╝║║║═╣╠══║╠══║║╚╝║╚═╝║──║║──║║║╚╗║╚═╝║║║─║║║║╚╩═║╔╗║║───║║║╚╗║╚═╝║
 * ──╚╝──╚═╗╔╝║╔═╝╚══╝╚═══╝╚══╝╚══╝╚══╝╚══╩═╗╔╝──╚╝──╚╝╚═╝╚═══╝╚╝─╚═╝╚═══╝╚╝╚╝───╚╝╚═╝╚═══╝
 * ──────╔═╝║─║║──────────────────────────╔═╝║
 * ──────╚══╝─╚╝──────────────────────────╚══╝
 * 
 * TypeLess - Auto Form Filler
 * v1.0.5 by TRONG.PRO
 */

/* ═══════════════════════════════════════════
   TOOLBAR — compact redesign
   ═══════════════════════════════════════════ */

#tl-toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.3);
  z-index: 2147483640;
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  animation: slideUp 0.3s ease-out;
  cursor: default !important;
}

html body #tl-toolbar,
html body #tl-toolbar *,
html body .tl-modal,
html body .tl-modal *,
html body #tl-floating-btn,
html body #tl-floating-btn * {
  cursor: default !important;
}

html body #tl-toolbar .tl-btn,
html body #tl-toolbar .tl-chip,
html body #tl-toolbar button,
html body .tl-modal button,
html body .tl-modal .tl-field-item,
html body .tl-modal .tl-modal-close,
html body #tl-floating-btn {
  cursor: pointer !important;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ── Header row ── */
.tl-toolbar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  background: rgba(0, 0, 0, 0.18);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  height: 30px;
  box-sizing: border-box;
}

.tl-toolbar-title {
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0.9;
}

.tl-toolbar-title img { width: 12px; height: 12px; }

.tl-toolbar-controls {
  display: flex;
  gap: 3px;
}

.tl-btn {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: white;
  padding: 0 7px;
  border-radius: 4px;
  cursor: pointer !important;
  font-size: 11px;
  font-weight: 500;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 20px;
}

.tl-btn img { width: 11px; height: 11px; filter: brightness(0) invert(1); }

.tl-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.tl-btn-icon {
  width: 20px;
  padding: 0;
  justify-content: center;
}

/* ── Profile chips row ── */
.tl-toolbar-content {
  padding: 4px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  height: 34px;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.3) transparent;
}

.tl-toolbar-content::-webkit-scrollbar { height: 3px; }
.tl-toolbar-content::-webkit-scrollbar-track { background: transparent; }
.tl-toolbar-content::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
}

.tl-toolbar-profiles {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 26px;
}

/* Single-line profile chip: [N] Name × */
.tl-chip {
  display: inline-flex;
  align-items: stretch;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 5px;
  height: 26px;
  cursor: pointer !important;
  font-size: 12px;
  color: #4a3580;
  transition: background 0.15s, box-shadow 0.15s;
  user-select: none;
  max-width: 220px;
  flex-shrink: 0;
}

.tl-chip:hover {
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.tl-chip.tl-drag-over {
  box-shadow: -3px 0 0 rgba(255,255,255,0.9);
  border-color: white;
}

.tl-chip.tl-dragging {
  opacity: 0.4;
  transform: scale(0.96);
}

/* [N] field count badge */
.tl-chip-count {
  background: rgba(102,126,234,0.15);
  color: #7c3aed;
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  border-right: 1px solid rgba(0,0,0,0.07);
  display: flex;
  align-items: center;
  border-radius: 4px 0 0 4px;
  min-width: 22px;
  justify-content: center;
}

/* Profile name */
.tl-chip-name {
  flex: 1;
  padding: 0 7px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
  display: flex;
  align-items: center;
}

/* × delete button */
.tl-chip-delete {
  background: none;
  border: none;
  border-left: 1px solid rgba(0,0,0,0.08);
  color: #9b8ec4;
  font-size: 14px;
  line-height: 1;
  padding: 0 6px;
  cursor: pointer !important;
  display: flex;
  align-items: center;
  border-radius: 0 4px 4px 0;
  transition: background 0.15s, color 0.15s;
}

.tl-chip-delete:hover {
  background: rgba(220,50,50,0.12);
  color: #e53e3e;
}

/* Loading / empty inline text */
.tl-toolbar-loading,
.tl-toolbar-empty {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  height: 26px;
  padding: 0 4px;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .tl-btn-text { display: none; }
  .tl-btn { padding: 0 4px; }
  .tl-title-text { display: none; }
}

/* ── inline rename for popup profile list ── */
.tl-profile-name-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  margin-right: 6px;
  overflow: hidden;
}

.tl-profile-name-edit {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #2d3748);
  border: 1px solid var(--primary-color, #3291B6);
  border-radius: 5px;
  padding: 2px 6px;
  outline: none;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(50, 145, 182, 0.18);
}

.tl-icon-btn.tl-rename-btn {
  font-size: 13px;
  line-height: 1;
  border: 1px solid transparent;
  background: transparent;
}
.tl-icon-btn.tl-rename-btn:hover {
  background: #edf2ff;
  border-color: #7bc0d9;
}
.tl-icon-btn.tl-rename-confirm {
  background: #e6fff4 !important;
  border-color: #48bb78 !important;
  color: #276749;
}
.tl-icon-btn.tl-rename-confirm:hover {
  background: #48bb78 !important;
  color: #fff;
}

.tl-profile-count {
  font-size: 12px;
  color: #764ba2;
  opacity: 0.8;
}

/* Notification */
.tl-notification {
  animation: fadeInRight 0.3s ease-out;
}

@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(50px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Drag handle for popup/options profile lists */
.tl-drag-handle {
  cursor: grab !important;
  padding: 0 6px;
  color: #ccc;
  font-size: 14px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  user-select: none;
}
.tl-drag-handle:active { cursor: grabbing !important; }

.tl-profile-item.tl-drag-over-top    { border-top: 2px solid #3291B6; }
.tl-profile-item.tl-drag-over-bottom { border-bottom: 2px solid #3291B6; }
.tl-profile-item.tl-is-dragging      { opacity: 0.4; }

.tl-profile-card.tl-drag-over-top    { border-top: 2px solid #3291B6; }
.tl-profile-card.tl-drag-over-bottom { border-bottom: 2px solid #3291B6; }
.tl-profile-card.tl-is-dragging      { opacity: 0.4; }

/* Modal Styles for Field Selection */
.tl-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Max 32-bit integer to stay on top of everything */
  z-index: 2147483647;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.tl-modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease-out;
  cursor: default !important;
  /* Force cursor visibility */
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.tl-modal-header {
  padding: 20px 24px;
  border-bottom: 2px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tl-modal-header h2 {
  margin: 0;
  font-size: 24px;
  color: #667eea;
}

.tl-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer !important;
  /* Force pointer cursor */
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.tl-modal-close:hover {
  background: #f0f0f0;
  color: #333;
}

.tl-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.tl-modal-section {
  margin-bottom: 20px;
}

.tl-modal-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.tl-modal-label {
  display: block;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  font-size: 14px;
}

.tl-modal-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.tl-modal-input:focus {
  outline: none;
  border-color: #667eea;
}

.tl-modal-actions {
  display: flex;
  gap: 8px;
}

.tl-modal-btn-small {
  padding: 6px 12px;
  background: #f0f0f0;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer !important;
  /* Force pointer cursor */
  transition: background 0.2s;
  font-weight: 500;
}

.tl-modal-btn-small:hover {
  background: #e0e0e0;
}

.tl-field-list {
  max-height: 300px;
  overflow-y: auto;
  border: 2px solid #f0f0f0;
  border-radius: 8px;
  padding: 8px;
}

.tl-field-item {
  display: flex;
  align-items: flex-start;
  padding: 12px;
  border-radius: 6px;
  cursor: pointer !important;
  /* Force pointer cursor */
  transition: background 0.2s;
  margin-bottom: 4px;
}

.tl-field-item:hover {
  background: #f9f9f9;
}

.tl-field-checkbox {
  margin-right: 12px;
  margin-top: 2px;
  width: 18px;
  height: 18px;
  cursor: pointer !important;
  /* Force pointer cursor */
  flex-shrink: 0;
}

.tl-field-info {
  flex: 1;
  min-width: 0;
}

/* New semantic classes used by the updated modal template */
.tl-field-label-text {
  font-weight: 500;
  color: #333;
  margin-bottom: 3px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-field-value-text {
  font-size: 11px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.tl-field-value-code {
  display: inline-block;
  background: #f0f4ff;
  border: 1px solid #c5d0f0;
  border-radius: 3px;
  color: #667eea;
  font-size: 10px;
  font-family: 'Courier New', monospace;
  padding: 0 4px;
  margin-left: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

.tl-field-type-icon {
  margin-right: 10px;
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
  line-height: 1;
}

/* Dim fields with no current value — still selectable but visually de-emphasized */
.tl-field-item--empty {
  opacity: 0.6;
}
.tl-field-item--empty .tl-field-value-text {
  font-style: italic;
}



.tl-modal-footer {
  padding: 16px 24px;
  border-top: 2px solid #f0f0f0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.tl-modal-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer !important;
  /* Force pointer cursor */
  transition: all 0.2s;
}

.tl-modal-btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.tl-modal-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.tl-modal-btn-secondary {
  background: #f0f0f0;
  color: #333;
}

.tl-modal-btn-secondary:hover {
  background: #e0e0e0;
}

/* Scrollbar for field list */
.tl-field-list::-webkit-scrollbar {
  width: 8px;
}

.tl-field-list::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 4px;
}

.tl-field-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.tl-field-list::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Floating Restore Button */
#tl-floating-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: 3px solid rgba(255, 255, 255, 0.3);
  font-size: 28px;
  cursor: pointer !important;
  /* Force pointer cursor */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 2147483640;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#tl-floating-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

#tl-floating-btn:active {
  transform: scale(0.95);
}

/**
 * End of styles.css
* ╔══╗─────────╔╗────╔═╗╔═╗╔╗───╔══╗╔═╗╔═╗╔═╦╗╔══╗──╔═╗╔═╗╔═╗
* ╚╗╔╝╔╦╗╔═╗╔═╗║║─╔═╗║═╣║═╣║╚╦╦╗╚╗╔╝║╬║║║║║║║║║╔═╣──║╬║║╬║║║║
* ─║║─║║║║╬║║╩╣║╚╗║╩╣╠═║╠═║║╬║║║─║║─║╗╣║║║║║║║║╚╗║╔╗║╔╝║╗╣║║║
* ─╚╝─╠╗║║╔╝╚═╝╚═╝╚═╝╚═╝╚═╝╚═╬╗║─╚╝─╚╩╝╚═╝╚╩═╝╚══╝╚╝╚╝─╚╩╝╚═╝
* ────╚═╝╚╝──────────────────╚═╝
 */

/* ─── Shadow DOM scoping ─────────────────────────────────────────────────────
 * The toolbar, modal, and notifications are rendered inside Shadow DOM roots.
 * The class-based rules above (.toolbar-*, .modal-*, etc.) work unchanged
 * inside shadow roots because shadow DOM inherits nothing from the page but
 * DOES apply stylesheets that are explicitly linked/injected inside the shadow.
 *
 * The :host { } rule for positioning is injected as a <style> element directly
 * inside each shadow root (in content.js) so it cannot be overridden by the
 * page's CSS selectors.
 * ──────────────────────────────────────────────────────────────────────────── */

/* Floating restore button — lives in light DOM, uses high-specificity rule */
html body #tl-floating-btn {
  all: initial;
  display: flex !important;
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  width: 60px !important;
  height: 60px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: white !important;
  border: 3px solid rgba(255,255,255,0.3) !important;
  font-size: 28px !important;
  cursor: pointer !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3) !important;
  z-index: 2147483640 !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.3s !important;
  font-family: 'Be Vietnam Pro', -apple-system, sans-serif !important;
  box-sizing: border-box !important;
}
html body #tl-floating-btn:hover {
  transform: scale(1.1) !important;
  box-shadow: 0 6px 30px rgba(0,0,0,0.4) !important;
}
