/* UDF Editörü — ContractCode masaüstü editörünün düzeni (araç çubuğu, A4 kâğıt, sayfa çubuğu),
   uygulamanın sade yeşil / gri / beyaz diliyle. Telefonda tam ekran, araç çubuğu yana kayar. */
body.ue-acik { overflow: hidden; }
.ue { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg); }
.ue[hidden] { display: none; }

.ue-ust { display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
    background: var(--surface); border-bottom: 1px solid var(--line); }
.ue-ad { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ue-ad b { font-size: 1.02rem; letter-spacing: -.01em; }
.ue-ad span { color: var(--text-3); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Araç çubuğu: gruplar ince ayraçla ayrılır */
.ue-arac { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 6px; padding: 8px 12px; background: var(--surface-2);
    border-bottom: 1px solid var(--line); }
.ue-grup { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding-right: 8px; border-right: 1px solid var(--line); }
.ue-grup.son { border-right: 0; padding-right: 0; }
.ue-btn, .ue-arac select { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 10px;
    border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: 500 .8rem var(--font);
    cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s; }
.ue-btn:hover, .ue-arac select:hover { border-color: var(--line-strong); background: var(--surface); }
.ue-btn:focus-visible, .ue-arac select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ue-btn.ue-k { min-width: 34px; padding: 6px 8px; font-size: .84rem; }
.ue-btn svg { width: 16px; height: 16px; fill: none; stroke: var(--text-2); stroke-width: 2; stroke-linecap: round; }
.ue-btn.aktif { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-strong); }
.ue-btn.yz { border-color: var(--ink); background: var(--ink); color: #fff; }
.ue-btn.yz:hover { background: #000; border-color: #000; }
.ue-arac select { padding-right: 6px; color: var(--text-2); }

.ue-serit { display: flex; align-items: center; gap: 10px; padding: 7px 16px; font-size: .76rem; color: var(--text-3);
    background: var(--surface); border-bottom: 1px solid var(--line); }
#ueBilgi { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ue-imza { flex: none; padding: 3px 9px; border-radius: 20px; border: 1px solid var(--line-strong); font-weight: 600; color: var(--text-3); }
.ue-imza.imzali { color: var(--accent-strong); border-color: var(--accent-line); background: var(--accent-soft); }

/* Kâğıt alanı */
.ue-alan { flex: 1; min-height: 0; overflow: auto; padding: 18px 12px 28px; background: #e4e9e6; -webkit-overflow-scrolling: touch; }
.ue-kagit { margin: 0 auto; background: #fff; border-radius: 3px; box-shadow: 0 1px 2px rgba(15, 19, 17, .06), 0 10px 30px rgba(15, 19, 17, .12); }
.ue-kagit[hidden] { display: none; }
.ue-kagit textarea { display: block; width: 100%; min-height: 60vh; margin: 0; padding: 0; border: 0; outline: 0; resize: none; overflow: hidden;
    background: transparent; color: #111; caret-color: var(--accent); }
.ue-kagit textarea::placeholder { color: #9aa19d; }
.ue-onizle { display: flex; justify-content: center; }
.ue-onizle[hidden] { display: none; }
.ue-olcek { position: relative; overflow: hidden; }
.ue-olcek iframe { position: absolute; top: 0; left: 0; border: 0; background: transparent; transform-origin: 0 0; }
.ue-kaynak { margin: 0; min-height: 100%; padding: 16px; border-radius: 10px; background: #1e1f1e; color: #d4d6d4; font: 500 .74rem/1.55 var(--mono);
    white-space: pre-wrap; word-break: break-all; }
.ue-kaynak[hidden] { display: none; }

/* Sayfa çubuğu */
.ue-alt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 14px; padding-bottom: max(8px, env(safe-area-inset-bottom));
    background: var(--surface-2); border-top: 1px solid var(--line); font-size: .78rem; }
.ue-etiket { color: var(--text-3); }
.ue-kenar { display: inline-flex; align-items: center; gap: 5px; color: var(--text-3); }
.ue-kenar input { width: 54px; padding: 6px 7px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); font: 500 .8rem var(--font); color: var(--text); }
.ue-kenar input:focus { outline: none; border-color: var(--accent); }
.ue-alt .seg-btn { padding: 5px 11px; }

/* Durum satırı */
.ue-durum { position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); width: min(620px, calc(100% - 24px)); display: flex; align-items: center; gap: 10px;
    padding: 10px 12px 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 8px 28px rgba(15, 19, 17, .14);
    font-size: .82rem; line-height: 1.45; }
.ue-durum[hidden] { display: none; }
.ue-durum > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ue-durum.tamam { border-color: var(--accent-line); background: var(--accent-soft); }
.ue-durum.hata { border-color: #efc4c4; background: #fdf3f3; color: var(--danger); }
.ue-durum.calisiyor > span:first-child::before { content: ''; display: inline-block; width: 11px; height: 11px; margin-right: 8px; vertical-align: -1px;
    border: 2px solid var(--accent-line); border-top-color: var(--accent); border-radius: 50%; animation: ue-don .8s linear infinite; }
@keyframes ue-don { to { transform: rotate(360deg); } }
.ue-deylem { display: flex; gap: 6px; flex: none; }
.ue-dkapat { flex: none; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); cursor: pointer; }
.ue-dkapat:hover { background: var(--bg-2); color: var(--text); }

/* Editör içi pencere */
.ue-perde { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: rgba(15, 19, 17, .32); }
.ue-perde[hidden] { display: none; }
.ue-pencere { width: min(420px, 100%); max-height: min(640px, 100%); display: flex; flex-direction: column; overflow: hidden;
    border-radius: 16px; background: var(--surface); box-shadow: 0 20px 60px rgba(15, 19, 17, .25); }
.ue-pencere.genis { width: min(620px, 100%); }
.ue-pencere > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--line); }
.ue-pencere > header .sh-ikon { width: 34px; height: 34px; }
.ue-pgovde { flex: 1; overflow: auto; padding: 14px 18px; font-size: .88rem; line-height: 1.5; }
.ue-pgovde p { margin: 0 0 10px; }
.ue-pgovde h4 { margin: 12px 0 6px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.ue-pgovde h4:first-child { margin-top: 0; }
.ue-pencere > footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
.ue-pencere > footer:empty { display: none; }
.ue-palan { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.ue-palan span { font-size: .8rem; font-weight: 600; color: var(--text-2); }
.ue-palan input, .ue-palan textarea, .ue-palan select, .ue-yz { width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line-strong);
    background: var(--surface); font: .9rem var(--font); color: var(--text); }
.ue-palan input:focus, .ue-palan textarea:focus, .ue-palan select:focus, .ue-yz:focus { outline: none; border-color: var(--accent); }
.ue-yz { min-height: 240px; resize: vertical; font-family: var(--mono); font-size: .8rem; line-height: 1.5; }
.ue-liste { display: flex; flex-direction: column; gap: 6px; }
.ue-satir-kap { display: flex; gap: 6px; }
.ue-satir { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 9px 12px; text-align: left; cursor: pointer;
    border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font: 600 .85rem var(--font); color: var(--text); }
.ue-satir:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.ue-satir small { font-weight: 400; font-size: .74rem; color: var(--text-3); }
.ue-sil { flex: none; width: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.ue-sil:hover { border-color: var(--danger); }
.ue-cihaz { margin-top: 12px; }
.soluk { color: var(--text-3); }

/* Belge Oluşturucu ve Belgelerim'deki giriş düğmeleri */
.editor-bar .ue-ac { flex: none; }
.udf-list-head #btnYeniUdf { margin-left: auto; }

@media (max-width: 720px) {
    .ue-ust { padding: 8px 10px; gap: 8px; }
    .ue-ust .sh-ikon { width: 36px; height: 36px; flex: none; }
    .ue-gorunum .seg-btn { padding: 6px 9px; }
    /* Araç çubuğu tek satır, yana kaydırılır */
    .ue-arac { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 7px 10px; }
    .ue-arac::-webkit-scrollbar { display: none; }
    .ue-grup { flex-wrap: nowrap; flex: none; }
    .ue-serit { padding: 6px 12px; }
    .ue-alan { padding: 10px 6px 24px; }
    .ue-alt { gap: 6px 8px; padding: 7px 10px; padding-bottom: max(7px, env(safe-area-inset-bottom)); }
    .ue-kenar input { width: 46px; }
    #ueYaziBilgi { display: none; }
    .ue-durum { bottom: 96px; }
    .ue-pencere, .ue-pencere.genis { max-height: 100%; }
}
@media (max-width: 420px) {
    .ue-ad span { display: none; }
}


/* Dosya & İndir Dropdown Menüsü */
.ue-dropdown-wrap {
    position: relative;
    display: inline-flex;
}
.ue-dropdown-trigger {
    font-weight: 600;
    background: var(--surface);
    border-color: var(--line-strong);
}
.ue-dropdown-trigger.acik {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-strong);
}
.ue-dropdown-menu {
    position: fixed;
    top: 96px;
    left: 16px;
    z-index: 80;
    min-width: 270px;
    padding: 8px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    box-shadow: 0 14px 38px rgba(15, 19, 17, 0.18), 0 2px 8px rgba(15, 19, 17, 0.08);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ue-dropdown-menu[hidden] {
    display: none !important;
}
.ue-dd-section-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-3);
    padding: 6px 10px 3px;
}
.ue-dd-divider {
    height: 1px;
    background: var(--line);
    margin: 5px 4px;
}
.ue-dd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    text-align: left;
    font-family: var(--font);
    cursor: pointer;
    transition: background .14s ease, color .14s ease;
}
.ue-dd-item:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
}
.ue-dd-item[hidden] {
    display: none !important;
}
.ue-dd-ico {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--bg-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    flex-shrink: 0;
}
.ue-dd-item:hover .ue-dd-ico {
    background: #fff;
}
.ue-dd-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.ue-dd-text strong {
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.25;
}
.ue-dd-text small {
    font-size: .7rem;
    color: var(--text-3);
    line-height: 1.25;
}


/* Manuel Font Büyüklüğü (Punto) Giriş Kutusu */
.ue-fontsize-wrap {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1px;
}
.ue-fontsize-wrap .ue-fs-step {
    border: none;
    min-height: 30px;
    min-width: 28px;
    padding: 4px 6px;
    border-radius: 6px;
    font-weight: 700;
}
.ue-fontsize-wrap .ue-fs-step:hover {
    background: var(--bg-2);
}
.ue-fontsize-box {
    display: inline-flex;
    align-items: center;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    padding: 0 6px;
    height: 30px;
    background: var(--surface);
}
#uePuntoInput {
    width: 38px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font: 700 .82rem var(--font);
    text-align: center;
    padding: 2px 0;
    -moz-appearance: textfield;
}
#uePuntoInput::-webkit-outer-spin-button,
#uePuntoInput::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.ue-pt-label {
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-3);
    margin-left: 2px;
    user-select: none;
}

/* Gerçek WYSIWYG A4 Yazım Alanı */
.ue-wysiwyg {
    display: block;
    width: 100%;
    min-height: 65vh;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #111;
    caret-color: var(--accent);
    overflow-wrap: anywhere;
    word-break: normal;
}
.ue-wysiwyg:empty::before {
    content: attr(data-placeholder);
    color: #9aa19d;
    pointer-events: none;
}
.ue-wysiwyg p {
    margin: 0 0 0.25em;
    text-align: justify;
    white-space: pre-wrap;
    min-height: 1.2em;
}
.ue-wysiwyg p[data-align="left"] { text-align: left; }
.ue-wysiwyg p[data-align="center"] { text-align: center; }
.ue-wysiwyg p[data-align="right"] { text-align: right; }
.ue-wysiwyg p[data-align="justify"] { text-align: justify; }

.ue-wysiwyg p.ue-h1 {
    font-weight: 700;
    font-size: 1.33em;
    margin: 0.35em 0 0.25em;
}
.ue-wysiwyg p.ue-h2 {
    font-weight: 700;
    font-size: 1.17em;
    margin: 0.3em 0 0.2em;
}
.ue-wysiwyg p.ue-h3 {
    font-weight: 700;
    font-size: 1.05em;
    margin: 0.25em 0 0.15em;
}
.ue-wysiwyg p.ue-bullet {
    text-align: left;
    padding-left: 1.4em;
    position: relative;
}
.ue-wysiwyg p.ue-bullet::before {
    content: "•";
    position: absolute;
    left: 0.35em;
    font-weight: 700;
}
.ue-wysiwyg table.ue-tbl {
    width: 100%;
    border-collapse: collapse;
    margin: 6px 0 10px;
}
.ue-wysiwyg table.ue-tbl th,
.ue-wysiwyg table.ue-tbl td {
    border: 1px solid #444;
    padding: 4px 8px;
    text-align: left;
    vertical-align: top;
    min-width: 40px;
}
.ue-wysiwyg table.ue-tbl th {
    font-weight: 700;
    background: #f8fafc;
}
.ue-wysiwyg img {
    max-width: 100%;
    height: auto;
    display: inline-block;
}

/* UDF Editörü Mobil İmza & E-İmza Butonları ve Modalı */
.ue-btn.ue-sign-btn.mobil {
    background: #ecfdf5 !important;
    border-color: #86efac !important;
    color: #047857 !important;
    font-weight: 600;
}
.ue-btn.ue-sign-btn.mobil:hover {
    background: #d1fae5 !important;
    border-color: #10b981 !important;
}
.ue-btn.ue-sign-btn.eimza {
    background: #eff6ff !important;
    border-color: #93c5fd !important;
    color: #1d4ed8 !important;
    font-weight: 600;
}
.ue-btn.ue-sign-btn.eimza:hover {
    background: #dbeafe !important;
    border-color: #3b82f6 !important;
}
.ue-imza.imzali.eimza {
    color: #1d4ed8;
    border-color: #bfdbfe;
    background: #eff6ff;
}
.ue-eimza-modal-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    margin-bottom: 12px;
    border-radius: 9px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    color: var(--accent-strong);
    font-size: 0.78rem;
    line-height: 1.4;
}
.ue-eimza-modal-info .ue-emi-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.18);
    flex-shrink: 0;
}
