/* ==========================================================================
   HAZIRBELGE — BELGE STÜDYOSU VE DÜZENLEYİCİ STİLLERİ (editor.css)
   Tekil Birleşik Üst Çubuk (Unified Studio Header), Ergonomik Butonlar ve Canlı A4 Sahnesi
   ========================================================================== */

.hb-studio-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--hb-surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hb-border);
  box-shadow: var(--hb-shadow-xs);
}

.hb-studio-topbar-inner {
  max-width: 1680px;
  margin: 0 auto;
  padding: 8px 18px;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.hb-studio-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hb-back-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--hb-border);
  background: var(--hb-surface);
  color: var(--hb-text-muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}

.hb-back-pill:hover {
  background: var(--hb-surface-alt);
  color: var(--hb-text);
  border-color: var(--hb-border-strong);
}

.hb-studio-divider {
  width: 1px;
  height: 22px;
  background: var(--hb-border);
}

.hb-type-switcher {
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--hb-border);
  background: var(--hb-surface-alt);
  color: var(--hb-text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.hb-doc-title-input {
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--hb-text);
  font-family: var(--hb-font-display);
  font-size: 14.5px;
  font-weight: 700;
  min-width: 210px;
  transition: all 0.15s ease;
}

.hb-doc-title-input:hover {
  background: var(--hb-surface-alt);
  border-color: var(--hb-border);
}

.hb-doc-title-input:focus {
  background: var(--hb-surface);
  border-color: var(--hb-primary);
}

.hb-save-status,
.hb-save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--hb-success-bg);
  color: var(--hb-success);
  white-space: nowrap;
}

.hb-save-status.is-saving,
.hb-save-indicator.is-saving {
  background: var(--hb-warning-bg);
  color: var(--hb-warning);
}

/* SAĞ ERGONOMİK AKSİYON GRUBU */
.hb-studio-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Birleşik Geri Al / Yinele Segmented Grup */
.hb-history-group {
  display: inline-flex;
  align-items: center;
  background: var(--hb-surface-alt);
  border: 1px solid var(--hb-border);
  border-radius: 9px;
  padding: 2px;
}

.hb-history-btn {
  height: 30px;
  padding: 0 9px;
  border: none;
  background: transparent;
  color: var(--hb-text);
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.14s ease;
}

.hb-history-btn:hover:not(:disabled) {
  background: var(--hb-surface);
  box-shadow: var(--hb-shadow-xs);
}

.hb-history-btn:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}

/* İŞLEMLER / YEDEK AÇILIR MENÜSÜ (Gereksiz Buton Kalabalığını Önler) */
.hb-actions-dropdown {
  position: relative;
}

.hb-actions-dropdown > summary {
  list-style: none;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--hb-border-strong);
  background: var(--hb-surface);
  color: var(--hb-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  transition: all 0.15s ease;
}

.hb-actions-dropdown > summary::-webkit-details-marker {
  display: none;
}

.hb-actions-dropdown > summary:hover {
  background: var(--hb-surface-alt);
}

.hb-actions-dropdown[open] > summary {
  border-color: var(--hb-primary);
  background: var(--hb-primary-soft);
  color: var(--hb-primary);
}

.hb-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 230px;
  background: var(--hb-surface);
  border: 1px solid var(--hb-border-strong);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--hb-shadow-lg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hb-dropdown-item {
  width: 100%;
  padding: 8px 11px;
  border: none;
  background: transparent;
  color: var(--hb-text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  transition: background-color 0.14s ease;
}

.hb-dropdown-item:hover {
  background: var(--hb-surface-alt);
}

.hb-dropdown-item.is-danger {
  color: var(--hb-danger);
}

.hb-dropdown-item.is-danger:hover {
  background: var(--hb-danger-bg);
}

.hb-dropdown-sep {
  height: 1px;
  background: var(--hb-border);
  margin: 4px 2px;
}

/* MOBİL GÖRÜNÜM GEÇİŞ SEKMELERİ (Form <-> A4 Önizleme) */
.hb-mobile-tabs,
.hb-mobile-editor-tabs {
  display: none;
  background: var(--hb-surface);
  border-bottom: 1px solid var(--hb-border);
  padding: 8px 14px;
  gap: 8px;
}

.hb-mobile-tab,
.hb-mobile-tab-btn {
  flex: 1;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--hb-border);
  background: var(--hb-surface-alt);
  color: var(--hb-text-muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.hb-mobile-tab.is-active,
.hb-mobile-tab-btn.is-active {
  background: var(--hb-primary);
  color: #ffffff;
  border-color: var(--hb-primary);
  box-shadow: var(--hb-shadow-xs);
}

/* ==========================================================================
   ANA ÇALIŞMA ALANI (SOL FORM PANELİ + SAĞ CANLI A4 SAHNESİ)
   ========================================================================== */
.hb-workspace,
.hb-editor-workspace {
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 500px 1fr;
  flex: 1;
  align-items: start;
}

/* SOL PANEL: FORM, BÖLÜM SIRALAMA VE GÖRÜNÜM AYARLARI */
.hb-sidebar,
.hb-editor-sidebar {
  background: var(--hb-surface);
  border-right: 1px solid var(--hb-border);
  height: calc(100vh - 63px);
  position: sticky;
  top: 63px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hb-sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--hb-surface-alt);
  margin: 12px 14px 4px;
  padding: 4px;
  border-radius: 11px;
  border: 1px solid var(--hb-border);
  gap: 4px;
}

.hb-side-tab,
.hb-sidebar-tab {
  padding: 8px 8px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--hb-text-muted);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.hb-side-tab:hover,
.hb-sidebar-tab:hover {
  color: var(--hb-text);
}

.hb-side-tab.is-active,
.hb-sidebar-tab.is-active {
  background: var(--hb-surface);
  color: var(--hb-primary);
  box-shadow: var(--hb-shadow-xs);
}

.hb-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

/* Form Grupları */
.hb-form-section {
  border: 1px solid var(--hb-border);
  border-radius: 12px;
  background: var(--hb-bg);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--hb-shadow-xs);
}

.hb-form-sec-head {
  padding: 11px 14px;
  background: var(--hb-surface);
  border-bottom: 1px solid var(--hb-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--hb-text);
}

.hb-form-sec-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hb-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 520px) {
  .hb-field-row {
    grid-template-columns: 1fr;
  }
}

.hb-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hb-field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--hb-text);
}

.hb-field small {
  font-size: 11.5px;
  color: var(--hb-text-soft);
}

.hb-input,
.hb-select,
.hb-textarea {
  width: 100%;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--hb-border-strong);
  background: var(--hb-surface);
  color: var(--hb-text);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hb-input:focus,
.hb-select:focus,
.hb-textarea:focus {
  border-color: var(--hb-primary);
  box-shadow: 0 0 0 3px var(--hb-primary-ring);
}

.hb-textarea {
  min-height: 76px;
  resize: vertical;
  line-height: 1.48;
}

/* Dinamik Kayıt Kartı (Eğitim, Deneyim, Proje, Katılımcı vb.) */
.hb-repeat-card {
  border: 1px solid var(--hb-border-strong);
  border-radius: 10px;
  background: var(--hb-surface);
  padding: 12px;
  margin-bottom: 10px;
}

.hb-repeat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--hb-border);
}

.hb-repeat-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--hb-primary);
}

.hb-repeat-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hb-mini-btn {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--hb-border);
  background: var(--hb-bg);
  color: var(--hb-text-muted);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
}

.hb-mini-btn:hover {
  background: var(--hb-surface-alt);
  color: var(--hb-text);
}

.hb-mini-btn.danger {
  color: var(--hb-danger);
  border-color: rgba(220, 38, 38, 0.25);
}

.hb-mini-btn.danger:hover {
  background: var(--hb-danger-bg);
}

/* Bölüm Sıralama Satırı */
.hb-order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  background: var(--hb-surface);
  border: 1px solid var(--hb-border);
  border-radius: 8px;
  margin-bottom: 6px;
}

.hb-order-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

/* ==========================================================================
   ORTA / SAĞ PANEL: CANLI A4 BELGE ÖNİZLEMESİ
   ========================================================================== */
.hb-preview-pane,
.hb-preview-stage {
  padding: 26px 24px 60px;
  background-color: var(--hb-bg);
  min-height: calc(100vh - 63px);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: auto;
}

.hb-preview-meta-bar {
  width: 100%;
  max-width: 210mm;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--hb-text-muted);
}

.hb-a4-sheet {
  width: 210mm;
  min-height: 297mm;
  background-color: #ffffff;
  color: #111827;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.14), 0 0 0 1px rgba(15, 23, 42, 0.08);
  border-radius: 4px;
  padding: 16mm;
  position: relative;
  transition: padding 0.2s ease;
}

.hb-a4-sheet[data-margin="narrow"] {
  padding: 12mm;
}

.hb-a4-sheet[data-margin="normal"] {
  padding: 16mm;
}

.hb-a4-sheet[data-margin="wide"] {
  padding: 22mm;
}

/* ==========================================================================
   FOTOĞRAF KIRPMA MODAL STİLLERİ VE TOAST
   ========================================================================== */
.hb-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.hb-modal-backdrop.is-open {
  display: flex;
}

.hb-modal {
  background: var(--hb-surface);
  color: var(--hb-text);
  border: 1px solid var(--hb-border);
  border-radius: var(--hb-radius-lg);
  width: min(94vw, 460px);
  padding: 22px;
  box-shadow: var(--hb-shadow-lg);
}

.hb-crop-stage,
.hb-crop-canvas-wrap {
  width: 260px;
  height: 260px;
  margin: 14px auto;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--hb-primary);
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hb-toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 9999;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 11px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
  font-size: 13.5px;
  font-weight: 600;
  display: none;
  align-items: center;
  gap: 10px;
  max-width: 380px;
}

.hb-toast.is-shown {
  display: flex;
}

.hb-toast.is-error {
  background: #dc2626;
}

/* ==========================================================================
   MOBİL VE TABLET RESPONSIVE DÜZEN
   ========================================================================== */
@media (max-width: 1080px) {
  .hb-mobile-tabs,
  .hb-mobile-editor-tabs {
    display: flex;
  }
  .hb-workspace,
  .hb-editor-workspace {
    grid-template-columns: 1fr;
  }
  .hb-sidebar,
  .hb-editor-sidebar {
    position: static;
    height: auto;
    border-right: none;
  }
  .hb-workspace[data-mobile-view="preview"] .hb-sidebar,
  .hb-editor-workspace[data-mobile-view="preview"] .hb-editor-sidebar {
    display: none;
  }
  .hb-workspace[data-mobile-view="form"] .hb-preview-pane,
  .hb-editor-workspace[data-mobile-view="form"] .hb-preview-stage {
    display: none;
  }
  .hb-preview-pane,
  .hb-preview-stage {
    padding: 16px 10px 40px;
  }
  .hb-a4-sheet {
    width: 100%;
    max-width: 210mm;
    min-height: auto;
    padding: 18px !important;
  }
}

@media (max-width: 720px) {
  .hb-studio-topbar-inner {
    padding: 8px 12px;
    gap: 8px;
  }
  .hb-studio-divider,
  .hb-doc-title-input,
  .hb-save-status,
  #hbPrintBtn {
    display: none;
  }
  .hb-studio-left {
    width: 100%;
    justify-content: space-between;
  }
  .hb-type-switcher {
    flex: 1;
  }
  .hb-studio-right {
    width: 100%;
    justify-content: space-between;
  }
  #hbDownloadPdfBtn {
    flex: 1;
  }
}
