/* ============================================================
   PDF FILLER - Stílusok
   ============================================================ */

/* Fő konténer */
.pdf-filler-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 500px;
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Fejléc */
.pdf-filler-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.pdf-filler-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
}

.pdf-filler-actions {
  display: flex;
  gap: 8px;
}

/* Fő tartalom - 3 oszlopos elrendezés */
.pdf-filler-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Bal oldal - CRM mezők */
.pdf-filler-sidebar {
  width: 280px;
  min-width: 280px;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  background: var(--gray-50);
}

.sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--white);
}

.sidebar-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 13px;
}

.sidebar-search:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(98, 148, 137, 0.1);
}

.crm-fields-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* CRM kategóriák */
.crm-category {
  margin-bottom: 8px;
}

.crm-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--white);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  color: var(--gray-700);
  transition: background 0.2s;
}

.crm-category-header:hover {
  background: var(--gray-100);
}

.crm-category-header .toggle-icon {
  margin-left: auto;
  transition: transform 0.2s;
}

.crm-category.collapsed .crm-category-header .toggle-icon {
  transform: rotate(-90deg);
}

.crm-category.collapsed .crm-fields {
  display: none;
}

.crm-fields {
  padding: 4px 0 4px 12px;
}

/* Draggable CRM mező */
.crm-field-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 2px 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: grab;
  font-size: 13px;
  color: var(--gray-700);
  transition: all 0.2s;
}

.crm-field-item:hover {
  border-color: var(--green);
  background: var(--beige);
}

.crm-field-item:active {
  cursor: grabbing;
}

.crm-field-item.dragging {
  opacity: 0.5;
  border-color: var(--green);
}

.crm-field-item .drag-handle {
  color: var(--gray-400);
  font-size: 14px;
}

/* Középső rész - PDF nézet */
.pdf-viewer-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--gray-100);
  min-width: 400px;
}

/* PDF feltöltő zóna */
.pdf-drop-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  border: 3px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  margin: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.pdf-drop-zone:hover,
.pdf-drop-zone.dragover {
  border-color: var(--green);
  background: rgba(98, 148, 137, 0.1);
  transform: scale(1.01);
}

.pdf-drop-zone.dragover {
  border-width: 4px;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

.pdf-drop-zone.dragover svg {
  color: var(--green);
  transform: translateY(-5px);
  transition: transform 0.3s ease;
}

.pdf-drop-zone.dragover h3 {
  color: var(--green);
}

.pdf-drop-zone svg {
  width: 64px;
  height: 64px;
  color: var(--gray-400);
  margin-bottom: 16px;
}

.pdf-drop-zone h3 {
  font-size: 18px;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.pdf-drop-zone p {
  font-size: 14px;
  color: var(--gray-500);
}

.pdf-drop-zone .file-input {
  display: none;
}

/* PDF megjelenítő */
.pdf-viewer-wrapper {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  background: var(--gray-200);
}

#pdfViewer {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  background: white;
}

#pdfViewer canvas {
  display: block;
}

/* PDF navigáció */
.pdf-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
}

.pdf-nav button {
  padding: 6px 12px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.pdf-nav button:hover:not(:disabled) {
  background: var(--gray-100);
  border-color: var(--green);
}

.pdf-nav button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#pdfPageInfo {
  font-size: 13px;
  color: var(--gray-600);
  min-width: 60px;
  text-align: center;
}

/* Jobb oldal - PDF mezők */
.pdf-fields-container {
  width: 320px;
  min-width: 320px;
  border-left: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  background: var(--white);
}

.pdf-fields-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.pdf-fields-header h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin: 0;
}

.pdf-fields-header .field-count {
  font-size: 12px;
  color: var(--gray-500);
  font-weight: normal;
}

#pdfFieldsList {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* PDF mező elem */
.pdf-field-item {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  transition: all 0.2s;
}

.pdf-field-item.mapped {
  border-color: var(--green);
  background: rgba(98, 148, 137, 0.05);
}

.pdf-field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
}

.pdf-field-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-800);
  word-break: break-all;
}

.pdf-field-type {
  font-size: 11px;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
}

.pdf-field-mapping {
  padding: 12px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.pdf-field-mapping.drag-over {
  background: rgba(98, 148, 137, 0.1);
  border: 2px dashed var(--green);
  border-radius: var(--radius);
  margin: 4px;
}

.pdf-field-mapping.ready-for-drop {
  background: rgba(98, 148, 137, 0.05);
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  margin: 4px;
}

.drop-hint {
  font-size: 12px;
  color: var(--gray-400);
  font-style: italic;
}

.mapped-field {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--green);
  color: white;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
}

.mapped-icon {
  font-size: 14px;
}

.remove-mapping-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  margin-left: 4px;
  transition: background 0.2s;
}

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

/* Üzenetek */
#pdfMessages {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pdf-message {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: slideIn 0.3s ease;
}

.pdf-message.success {
  border-left: 4px solid var(--green);
}

.pdf-message.error {
  border-left: 4px solid var(--red);
}

.pdf-message.info {
  border-left: 4px solid var(--gold);
}

.pdf-message button {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  line-height: 1;
}

.pdf-message button:hover {
  color: var(--gray-600);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Loader */
#pdfLoader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

#pdfLoader.hidden {
  display: none;
}

.loader-content {
  background: var(--white);
  padding: 24px 32px;
  border-radius: var(--radius-lg);
  text-align: center;
}

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-text {
  font-size: 14px;
  color: var(--gray-600);
}

/* No fields message */
.no-fields-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}

.no-fields-message .hint {
  font-size: 12px;
  margin-top: 8px;
  color: var(--gray-400);
}

/* Responsive */
@media (max-width: 1200px) {
  .pdf-filler-sidebar {
    width: 240px;
    min-width: 240px;
  }
  
  .pdf-fields-container {
    width: 280px;
    min-width: 280px;
  }
}

@media (max-width: 900px) {
  .pdf-filler-content {
    flex-direction: column;
  }
  
  .pdf-filler-sidebar,
  .pdf-fields-container {
    width: 100%;
    min-width: unset;
    max-height: 200px;
    border: none;
    border-bottom: 1px solid var(--gray-200);
  }
  
  .crm-fields-list,
  #pdfFieldsList {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .crm-field-item,
  .pdf-field-item {
    flex: 0 0 auto;
  }
}
