/* ============================================================
   admin-pdf.css — PDF Editor v3 (Geniş Alan + Eşit Hizalama)
   ============================================================ */

#pdfEditorModal, .pdf-editor-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  z-index: 9999999 !important;
  background: #4a4d52 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

body.pdf-editor-open {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
}

/* HEADER */
.pdf-editor-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  z-index: 20;
}

.pdf-editor-title {
  font-size: .9rem;
  font-weight: 800;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.pdf-editor-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.pdf-header-btn {
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all .18s;
  font-family: inherit;
  white-space: nowrap;
}

.pdf-header-btn:hover { background: #f9fafb; border-color: #9ca3af; }
.pdf-header-btn.save { background: #10b981; color: #fff; border-color: #10b981; }
.pdf-header-btn.load { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.pdf-header-btn.print { background: #0ea5e9; color: #fff; border-color: #0ea5e9; }
.pdf-header-btn.back { background: #8b5cf6; color: #fff; border-color: #8b5cf6; }
.pdf-header-btn.close { background: #ef4444; color: #fff; border-color: #ef4444; padding: 7px 10px; }

/* TOOLBAR */
.pdf-editor-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: thin;
  z-index: 19;
  -webkit-overflow-scrolling: touch;
}

.pdf-editor-toolbar::-webkit-scrollbar { height: 5px; }
.pdf-editor-toolbar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.pdf-tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #4b5563;
  font-size: .82rem;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
  flex-shrink: 0;
}

.pdf-tb-btn:hover { background: #e2e8f0; color: #111827; }
.pdf-tb-btn.active { background: #9333ea; color: #fff; border-color: #9333ea; }

.pdf-tb-sep {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: #cbd5e1;
  margin: 0 5px;
  flex-shrink: 0;
}

.pdf-tb-select {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  font-family: inherit;
  margin: 0 2px;
  height: 32px;
  flex-shrink: 0;
  max-width: 180px;
}

.pdf-tb-select:hover { border-color: #9ca3af; }

.pdf-tb-input {
  width: 60px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: .72rem;
  font-weight: 600;
  outline: none;
  font-family: inherit;
  height: 32px;
  flex-shrink: 0;
  text-align: center;
}

/* WORKSPACE (Arka plan) */
.pdf-editor-workspace {
  flex: 1;
  overflow: auto;
  background: #4a4d52;
  padding: 60px 30px 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 80px;
  -webkit-overflow-scrolling: touch;
  position: relative;
  touch-action: pinch-zoom !important; /* YENİ EKLENDİ: Zoom izni */
}

/* SAYFA DIŞ ÇERÇEVESİ (Kırmızı Alan) */
.pdf-page-wrap {
  position: relative;
  width: 794px;
  min-height: 1123px;
  flex-shrink: 0;
  background: #fff;
  box-shadow: 0 6px 30px rgba(0,0,0,.5);
  transition: padding .15s;
}

/* CETVELLER */
.pdf-ruler {
  position: absolute;
  background: linear-gradient(180deg,#f1f5f9,#e2e8f0);
  border: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #64748b;
  font-size: 8px;
  font-weight: 700;
  user-select: none;
  -webkit-user-select: none;
  z-index: 5;
  transition: background .15s;
}

.pdf-ruler:hover { background: #dbeafe; }
.pdf-ruler:active { background: #bfdbfe; }

.pdf-ruler-top { top:-18px; left:0; right:0; height:18px; cursor:ns-resize; padding:0 6px; border-radius:4px 4px 0 0; }
.pdf-ruler-bottom { bottom:-18px; left:0; right:0; height:18px; cursor:ns-resize; padding:0 6px; border-radius:0 0 4px 4px; }
.pdf-ruler-left { top:0; bottom:0; left:-18px; width:18px; cursor:ew-resize; flex-direction:column; padding:6px 0; border-radius:4px 0 0 4px; }
.pdf-ruler-right { top:0; bottom:0; right:-18px; width:18px; cursor:ew-resize; flex-direction:column; padding:6px 0; border-radius:0 4px 4px 0; }

.pdf-ruler-dot { width:3px; height:3px; border-radius:50%; background:#94a3b8; flex-shrink:0; }

.pdf-page-num {
  position: absolute;
  bottom: -34px;
  right: 0;
  font-size: 10px;
  color: #cbd5e1;
  font-weight: 700;
  letter-spacing: .5px;
  user-select: none;
}

.pdf-page-delete-btn {
  position: absolute;
  top: -40px;
  right: 0;
  padding: 5px 10px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: .65rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 6;
}

.pdf-page-delete-btn:hover { background: #dc2626; }

/* ============================================================
   YAZI YAZILAN ALAN (Sarı Alan) - BOŞLUKLAR DÜZELTİLDİ
   ============================================================ */
.pdf-page {
  width: 100%;
  min-height: 1123px;
  /* Boşluklar daraltıldı: Üst-Alt 20px, Sağ-Sol 20px (Daha geniş alan) */
  padding: 20px 20px; 
  background: #fff;
  outline: none;
  font-size: 14px;
  line-height: 1.6; 
  font-family: Arial, sans-serif;
  box-sizing: border-box;
  word-wrap: break-word;
  color: #000;
  /* Yazıları eşitler (Bir ileri bir geri gitmeyi önler) */
  text-align: justify; 
}

.pdf-page:focus { outline: none; }

.pdf-page img {
  max-width: 100%;
  height: auto;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .2s;
}

.pdf-page img:hover { border-color: #9333ea; }

.pdf-page table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.pdf-page table td, .pdf-page table th { border: 1px solid #999; padding: 6px; }

/* Sadece başlıklar sola yaslı olsun, paragraflar justify kalsın */
.pdf-page h1 { font-size: 24px; margin: 12px 0; text-align: left; }
.pdf-page h2 { font-size: 20px; margin: 10px 0; text-align: left; }
.pdf-page h3 { font-size: 16px; margin: 15px 0 5px 0; text-align: left; font-weight: 800; color: #333; }
.pdf-page p { margin: 8px 0; text-align: justify; }
.pdf-page ul, .pdf-page ol { margin: 8px 0 8px 24px; }

/* YENİ SAYFA EKLEME BUTONU */
.pdf-add-page-wrap {
  display: flex;
  justify-content: center;
  padding: 20px 0 40px;
}

.pdf-add-page {
  padding: 12px 28px;
  background: rgba(147,51,234,.2);
  color: #fff;
  border: 2px dashed rgba(147,51,234,.6);
  border-radius: 12px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 700;
  font-family: inherit;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pdf-add-page:hover {
  background: rgba(147,51,234,.4);
  border-color: #9333ea;
  transform: translateY(-1px);
}

/* FOOTER */
.pdf-editor-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -1px 3px rgba(0,0,0,.05);
  z-index: 20;
  flex-wrap: wrap;
}

.pdf-footer-left { display: flex; align-items: center; flex: 1; min-width: 0; gap: 12px; flex-wrap: wrap; }
.pdf-footer-right { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

.pdf-action-btn {
  padding: 9px 14px;
  border-radius: 9px;
  border: none;
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all .2s;
  font-family: inherit;
  white-space: nowrap;
}

.pdf-action-btn:hover { transform: translateY(-1px); opacity: .92; }
.pdf-action-btn.secondary { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.pdf-action-btn.download { background: #3b82f6; color: #fff; }
.pdf-action-btn.print { background: #0ea5e9; color: #fff; }
.pdf-action-btn.primary { background: #9333ea; color: #fff; }

/* YAZDIRMA MODU */
@media print {
  body * { visibility: hidden !important; }
  #pdfEditorModal, #pdfEditorModal * { visibility: visible !important; }
  .pdf-editor-header, .pdf-editor-toolbar, .pdf-editor-footer, .pdf-ruler, .pdf-page-num, .pdf-page-delete-btn, .pdf-add-page-wrap { display: none !important; }
  .pdf-editor-workspace { position: static !important; padding: 0 !important; background: #fff !important; overflow: visible !important; gap: 0 !important; display: block !important; }
  .pdf-page-wrap { width: 100% !important; min-height: auto !important; margin: 0 !important; box-shadow: none !important; page-break-after: always; }
  .pdf-page-wrap:last-child { page-break-after: auto; }
  .pdf-page { min-height: auto !important; box-shadow: none !important; padding: 20px !important; }
}

/* KIRPMA MODALI */
#pdfCropModal {
  position: fixed !important;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,.92) !important;
  z-index: 99999999 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
}

#pdfCropModal.active { display: flex !important; }

.pdf-crop-inner { width: 100%; max-width: 800px; background: #fff; border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; max-height: 90vh; }
.pdf-crop-header { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e5e7eb; font-weight: 800; font-size: .9rem; color: #1f2937; }
.pdf-crop-body { flex: 1; overflow: hidden; background: #1e293b; display: flex; align-items: center; justify-content: center; min-height: 400px; max-height: 60vh; }
.pdf-crop-body img { max-width: 100%; max-height: 60vh; display: block; }
.pdf-crop-footer { padding: 12px 16px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid #e5e7eb; }
.pdf-crop-footer button { padding: 10px 20px; border-radius: 10px; border: none; font-size: .82rem; font-weight: 700; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 6px; }
.pdf-crop-footer button.cancel { background: #f3f4f6; color: #374151; }
.pdf-crop-footer button.apply { background: #9333ea; color: #fff; }

/* RESPONSIVE */
@media (max-width: 900px) {
  /* Çalışma alanının üst boşluğunu sıfırla ki sayfa hemen başlasın */
  .pdf-editor-workspace { 
    padding: 10px 10px 80px 10px !important; 
    overflow-x: hidden; 
  }

  /* Sayfayı ortalayarak küçült */
  .pdf-page-wrap { 
    width: 794px !important; 
    min-height: 1123px; 
    transform: scale(0.45); 
    transform-origin: top center;
    margin: 0 auto !important; /* Sağdan soldan ortalıyoruz */
    margin-bottom: -620px !important; /* Sadece alttaki boşluğu çekiyoruz */
  }

  /* Cetvelleri gizle */
  .pdf-ruler { display: none !important; }
  
  .pdf-page { padding: 20px; font-size: 14px; }
  
  /* Butonlar */
  .pdf-editor-header { padding: 8px 10px; gap: 6px; }
  .pdf-editor-title { font-size: .78rem; }
  .pdf-header-btn { padding: 6px 9px; font-size: .65rem; }
  .pdf-header-btn span { display: none; }
  .pdf-action-btn { flex: 1; justify-content: center; padding: 8px 6px; font-size: .68rem; }
  .pdf-action-btn span { display: none; }
}