/* ==========================================================================
   RESMİ VELİ İZİN KAĞIDI OTOMASYONU - STYLE DOSYASI
   Mobil & Web Uyumlu, Header/Footer Yok, A4 Baskı & Toplu Liste Destekli
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-mono: 'Roboto Mono', monospace;

  /* Renk Paleti */
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-secondary: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --color-primary: #1e3a8a;       /* Resmi Koyu MEB Laciverti */
  --color-primary-hover: #1e40af;
  --color-accent: #dc2626;        /* T.C. Bayrak Kırmızısı */
  --color-success: #16a34a;
  --color-whatsapp: #16a34a;      /* WhatsApp Yeşili */
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-paper: 0 12px 32px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* Sıfırlama */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
  background-color: var(--bg-body);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   MOBİL SEKME SEÇİCİ (HEADER YERİNE SADECE MOBİL KULLANIM İÇİN SEKMELER)
   ========================================================================== */
.mobile-tabs {
  display: none;
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 12px;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.mobile-export-bar {
  display: none;
}

.mobile-export-button {
  display: grid;
  min-width: 0;
  min-height: 52px;
  place-items: center;
  gap: 1px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #ffffff;
  padding: 5px 4px;
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1.15;
}

.mobile-export-button > span {
  font-size: 12px;
  font-weight: 800;
}

.mobile-export-primary {
  border-color: #b91c1c;
  background: #dc2626;
  color: #ffffff;
}

.mobile-export-word,
.btn-word {
  border-color: #174ea6;
  background: #185abd;
  color: #ffffff;
}

/* ==========================================================================
   ANA ÇALIŞMA ALANI (WORKSPACE - IFRAME VE GITHUB PAGES TAM UYUMLU)
   ========================================================================== */
.app-workspace {
  display: flex;
  width: 100%;
  min-height: 100vh;
  background: var(--bg-body);
}

/* SOL PANEL: Form Alanı */
.panel-form {
  width: 430px;
  min-width: 360px;
  max-width: 480px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.03);
  z-index: 10;
}

.panel-scroll-content {
  flex: 1;
  padding: 12px 14px;
}

/* Hızlı Kontrol Üst Alanı */
.action-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
  flex-wrap: wrap;
}

.badge-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-accent);
  background: #fef2f2;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 3px;
}

.main-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.3px;
}

.topbar-buttons {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-outline {
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--bg-surface-secondary);
  border-color: #cbd5e1;
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: #64748b;
}

.btn-ghost:hover {
  background: #fef2f2;
  color: #ef4444;
}

/* Form Kartları */
.card-section {
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  margin-bottom: 10px;
  transition: border-color 0.2s;
}

.card-section:hover {
  border-color: #cbd5e1;
}

.section-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--color-primary);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 50%;
  flex-shrink: 0;
}

.section-title h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.section-title p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Form Elemanları */
.form-group {
  margin-bottom: 12px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-label-bold {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.15s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-select {
  cursor: pointer;
  font-weight: 500;
}

.form-textarea {
  resize: vertical;
  min-height: 55px;
}

.template-badge-info {
  margin-top: 10px;
  padding: 10px 12px;
  background: #eff6ff;
  border-left: 3px solid #3b82f6;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #1e40af;
  line-height: 1.4;
}

/* Logo Yükleme Alanı */
.logo-upload-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-color);
}

.logo-upload-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.file-input-hidden {
  display: none;
}

.logo-upload-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.btn-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  background: #ffffff;
  color: var(--color-primary);
  border: 1px dashed var(--color-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-upload-label:hover {
  background: #eff6ff;
}

.logo-preview-thumb img {
  height: 34px;
  max-width: 100px;
  object-fit: contain;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px;
  background: #ffffff;
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: #166534;
  line-height: 1.35;
}

.privacy-note svg {
  flex-shrink: 0;
  margin-top: 2px;
}

/* İmza Alanı */
.signature-options-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

.radio-toggle-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.radio-item input[type="radio"] {
  cursor: pointer;
  accent-color: var(--color-primary);
}

.signature-pad-wrapper {
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 10px;
  margin-top: 8px;
}

.canvas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
}

.canvas-container {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fafafa;
  touch-action: none;
}

#signatureCanvas {
  width: 100%;
  height: 110px;
  display: block;
  cursor: crosshair;
}

.options-checkboxes {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--color-primary);
}

/* ==========================================================================
   SAĞ PANEL: Canlı A4 Belge Önizleme ve Aksiyon Çubuğu
   ========================================================================== */
.panel-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #cbd5e1;
  position: relative;
  min-height: 100vh;
}

.preview-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  z-index: 5;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 8px;
}

.preview-status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.btn-toggle-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.btn-toggle-edit.active {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.font-size-controls {
  display: inline-flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.btn-font-step {
  background: transparent;
  border: none;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-font-step:hover {
  background: #e2e8f0;
  color: var(--text-primary);
}

.font-size-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 4px;
  min-width: 38px;
  text-align: center;
  user-select: none;
}

/* Kurumsal Antet Renk Paleti */
.theme-color-palette {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  align-items: center;
}

.theme-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.theme-btn:hover {
  transform: scale(1.15);
}

.theme-btn.active {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
  transform: scale(1.15);
}

/* Sayfa Taşma İkazı */
.overflow-warning-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  color: #b45309;
  font-size: 11.5px;
  font-weight: 500;
  z-index: 4;
}

.btn-autofit {
  background: #f59e0b;
  color: #ffffff;
  border: none;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-autofit:hover {
  background: #d97706;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-print {
  background: var(--color-primary);
  color: #ffffff;
}

.btn-print:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-pdf {
  background: #dc2626;
  color: #ffffff;
}

.btn-pdf:hover {
  background: #b91c1c;
  box-shadow: var(--shadow-md);
}

.btn-word:hover {
  background: #12478f;
  box-shadow: var(--shadow-md);
}

.btn-whatsapp {
  background: #16a34a;
  color: #ffffff;
}

.btn-whatsapp:hover {
  background: #15803d;
  box-shadow: var(--shadow-md);
}

.btn-copy {
  background: #f1f5f9;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-copy:hover {
  background: #e2e8f0;
  color: var(--text-primary);
}

/* A4 Sayfa Taşıyıcı */
.paper-viewport {
  flex: 1;
  padding: 12px 14px 40px;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
}

/* GERÇEK A4 KAĞIT FORMATI (210mm x 297mm) */
.a4-sheet {
  width: 210mm;
  min-height: 297mm;
  padding: 16mm 20mm 16mm 20mm;
  background: #ffffff;
  box-shadow: var(--shadow-paper);
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  color: #000000;
  font-family: 'Times New Roman', Times, serif, var(--font-serif);
  position: relative;
  box-sizing: border-box;
  font-size: var(--doc-font-scale, 1rem);
  transform-origin: top center;
}

/* Canlı Belge İçi Düzenleme Stilleri (WYSIWYG) */
.doc-section-block {
  position: relative;
  transition: background 0.15s ease;
}

.btn-del-section {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #f87171;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-del-section:hover {
  background: #dc2626;
  color: #ffffff;
  transform: scale(1.05);
}

.a4-sheet.inline-editing-active .doc-section-block:hover .btn-del-section {
  opacity: 1;
  pointer-events: auto;
}

.a4-sheet.inline-editing-active [contenteditable="true"] {
  outline: 1px dashed transparent;
  transition: all 0.15s ease;
  border-radius: 2px;
  cursor: text;
}

.a4-sheet.inline-editing-active [contenteditable="true"]:hover {
  outline: 1px dashed #60a5fa;
  background-color: rgba(239, 246, 255, 0.4);
}

.a4-sheet.inline-editing-active [contenteditable="true"]:focus {
  outline: 2px solid #2563eb;
  background-color: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* A4 İÇİ RESMİ DOKÜMAN STİLLERİ */
.single-doc-page {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.doc-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 12px;
  text-align: center;
  padding-bottom: 6px;
  gap: 14px;
}

.doc-logo-box {
  flex-shrink: 0;
}

.doc-school-logo {
  max-height: 52px;
  max-width: 90px;
  object-fit: contain;
}

.tc-header-text {
  flex: 1;
  padding: 0;
  text-align: center;
}

.tc-title {
  font-size: 14pt;
  font-weight: bold;
  letter-spacing: 1px;
}

.tc-ministry {
  font-size: 13pt;
  font-weight: bold;
  margin: 1px 0;
}

.tc-school {
  font-size: 11pt;
  font-weight: bold;
  text-transform: uppercase;
}

.doc-title-box {
  text-align: center;
  margin: 10px 0 10px 0;
  border-top: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  padding: 5px 0;
}

.doc-main-title {
  font-size: 13.5pt;
  font-weight: bold;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.doc-regulation-ref {
  font-size: 9.5pt;
  font-style: italic;
  font-weight: normal;
  margin-top: 2px;
}

.doc-date-align {
  text-align: right;
  font-size: 11pt;
  margin-bottom: 8px;
  font-weight: bold;
}

.doc-table-wrapper {
  margin-bottom: 12px;
}

.doc-info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5pt;
}

.doc-info-table th, .doc-info-table td {
  border: 1px solid #333333;
  padding: 5px 8px;
  text-align: left;
}

.doc-info-table th {
  background-color: #f3f4f6;
  font-weight: bold;
}

.doc-body-content {
  font-size: 11pt;
  line-height: 1.45;
  text-align: justify;
  margin-bottom: 12px;
  text-indent: 1.5cm;
}

.doc-body-content p {
  margin-bottom: 8px;
}

.doc-highlight {
  font-weight: bold;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.doc-terms-box {
  margin-bottom: 14px;
  font-size: 9.5pt;
  line-height: 1.35;
  background: #fdfdfd;
  border: 1px dashed #777777;
  padding: 7px 10px;
}

.doc-terms-box ul {
  padding-left: 20px;
  margin: 4px 0;
}

.doc-terms-box li {
  margin-bottom: 3px;
}

.doc-signatures-container {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 14px;
  gap: 18px;
}

.signature-block {
  flex: 1;
  border: 1px solid #666666;
  border-radius: 2px;
  padding: 8px 12px;
  font-size: 10pt;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 125px;
}

.sig-title {
  font-weight: bold;
  font-size: 10pt;
  text-align: center;
  border-bottom: 1px solid #cccccc;
  padding-bottom: 4px;
  margin-bottom: 6px;
}

.sig-details div {
  margin-bottom: 3px;
  font-size: 9.5pt;
}

.sig-box-area {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.sig-label {
  font-weight: bold;
  font-size: 9.5pt;
}

.sig-canvas-render {
  width: 130px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sig-canvas-render img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.wet-sign-placeholder {
  width: 110px;
  border-bottom: 1px dotted #333333;
  height: 32px;
}

.school-seal-placeholder {
  width: 95px;
  height: 48px;
  border: 1px dashed #999999;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8pt;
  color: #777777;
}

/* ==========================================================================
   A4 2'Lİ BASKI MODU (KAĞIT TASARRUFU STİLLERİ)
   ========================================================================== */
.a4-sheet.two-per-page-mode {
  padding: 10mm 15mm !important;
  gap: 8mm;
}

.a4-sheet.two-per-page-mode .single-doc-page {
  font-size: 8.5pt !important;
}

.a4-sheet.two-per-page-mode .tc-title {
  font-size: 11pt !important;
}

.a4-sheet.two-per-page-mode .tc-ministry {
  font-size: 10pt !important;
}

.a4-sheet.two-per-page-mode .tc-school {
  font-size: 8.5pt !important;
}

.a4-sheet.two-per-page-mode .doc-main-title {
  font-size: 10pt !important;
}

.a4-sheet.two-per-page-mode .doc-info-table {
  font-size: 8pt !important;
}

.a4-sheet.two-per-page-mode .doc-body-content {
  font-size: 8.5pt !important;
  line-height: 1.35 !important;
  margin-bottom: 6px !important;
}

.a4-sheet.two-per-page-mode .doc-terms-box {
  font-size: 7.5pt !important;
  padding: 4px 6px !important;
  margin-bottom: 6px !important;
}

.a4-sheet.two-per-page-mode .signature-block {
  min-height: 90px !important;
  font-size: 8pt !important;
  padding: 4px 8px !important;
}

.a4-sheet.two-per-page-mode .doc-school-logo {
  max-height: 36px !important;
}

.sheet-divider-cut {
  text-align: center;
  font-size: 8pt;
  color: #777777;
  border-top: 1px dashed #777777;
  padding-top: 4px;
  margin: 4px 0;
  font-family: var(--font-sans);
}

/* ==========================================================================
   TOPLU LİSTE MODAL DIALOGU
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.show {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface-secondary);
}

.modal-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-primary);
  font-weight: 700;
}

.modal-title-box h3 {
  font-size: 15px;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #0f172a;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: 70vh;
}

.modal-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.45;
}

.modal-desc code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--color-primary);
}

.batch-textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  resize: vertical;
}

.batch-quick-helpers {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.batch-stats-info {
  margin-top: 12px;
  padding: 8px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #166534;
  font-weight: 600;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface-secondary);
}

/* Toast Bildirim */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 2000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   RESPONSIVE / MOBİL TASARIM KURALLARI (768px Altı Mobil Sekmeli Mod)
   ========================================================================== */
@media screen and (max-width: 768px) {
  body {
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
  }

  .app-workspace {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .mobile-tabs {
    display: flex;
  }

  .mobile-export-bar {
    position: fixed;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 8px;
    z-index: 1200;
    display: grid;
    grid-template-columns: 0.75fr 1fr 1.15fr;
    gap: 7px;
    border: 1px solid rgba(203, 213, 225, 0.95);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.97);
    padding: 7px;
    box-shadow: 0 12px 35px rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(12px);
  }

  .panel-form {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    height: auto;
    border-right: none;
  }

  .panel-preview {
    width: 100%;
    height: auto;
    min-height: calc(100vh - 60px);
  }

  /* Sekme Kontrolleri */
  .panel-form.mobile-hidden {
    display: none;
  }

  .panel-preview.mobile-hidden {
    display: none;
  }

  .paper-viewport {
    padding: 14px 8px;
    overflow-x: auto;
  }

  /* Mobilde A4 ölçekleme */
  .a4-sheet {
    transform-origin: top center;
    max-width: 100%;
    width: 100%;
    min-height: auto;
    padding: 12mm 10mm;
    overflow-wrap: anywhere;
  }

  .doc-info-table {
    table-layout: fixed;
  }

  .doc-info-table th,
  .doc-info-table td {
    min-width: 0;
    padding: 4px 5px;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  
  .preview-action-bar {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  .preview-actions {
    justify-content: stretch;
  }

  .preview-actions button {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }
}

@media screen and (max-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .doc-signatures-container {
    flex-direction: column;
    gap: 12px;
  }

  .topbar-buttons {
    width: 100%;
  }

  .topbar-buttons button {
    flex: 1;
  }
}

/* ==========================================================================
   YAZDIRMA VE PDF BASKI OPTİMİZASYONU (@media print)
   Header, Footer, Butonlar ve Gereksiz her şey gizlenir, sadece saf A4 çıkar
   ========================================================================== */
@media screen {
  .panel-preview { min-width: 0; }
  .paper-viewport { overflow-x: auto; }
  .paper-viewport > .a4-sheet { flex-shrink: 0; }
}

@media screen and (max-width: 900px) {
  .panel-preview, .panel-scroll-content, .grid-2 > * { min-width: 0; }
  .panel-form input:not([type=checkbox]):not([type=radio]):not([type=hidden]), .panel-form select, .panel-form textarea { font-size: 16px; min-height: 44px; min-width: 0; max-width: 100%; }
  .panel-form button, .mobile-tabs button, .preview-action-bar button, .btn-autofit { min-height: 44px; }
  .btn-font-step { min-width: 44px; }
  .preview-actions, .preview-status-indicator { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
  .preview-action-bar > div { max-width: 100%; }
  .theme-btn { width: 36px; height: 44px; border-radius: 10px; }
  .overflow-warning-banner { flex-wrap: wrap; }
  .paper-viewport { overflow-x: auto; overscroll-behavior-x: contain; }
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html, body {
    height: auto !important;
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  /* Web arayüz elemanlarını tamamen gizle */
  .panel-form,
  .preview-action-bar,
  .edit-mode-banner,
  .btn-del-section,
  .mobile-tabs,
  .mobile-export-bar,
  .toast,
  .modal-overlay,
  .topbar-buttons {
    display: none !important;
  }

  .app-workspace {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .panel-preview {
    display: block !important;
    background: transparent !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .paper-viewport {
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    overflow: visible !important;
  }

  .a4-sheet {
    width: 210mm !important;
    min-height: 297mm !important;
    padding: 16mm 20mm 16mm 20mm !important;
    margin: 0 auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    box-sizing: border-box !important;
  }

  table {
    width: 100% !important;
    page-break-inside: avoid !important;
  }

  tr {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  [contenteditable="true"] {
    outline: none !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  /* Tarayıcı varsayılan başlık ve URL yazdırmalarını engelle */
  body {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
