/* ---------------------------------------------------------------------------
 * Central Document Service - guvenli belge goruntuleyici
 *
 * Tema anasirket.com/ingiltere ile ayni paleti kullanir (Apple tarzi):
 *   primary #0071e3 - zemin #f5f5f7 - metin #1d1d1f - soluk #6e6e73
 *
 * CSP unsafe-inline icermez: burada tanimli olmayan hicbir stil calismaz,
 * bu yuzden satir ici style kullanilmaz. Dis font da yuklenmez (font-src self),
 * sistem fontlari kullanilir.
 * ------------------------------------------------------------------------- */

:root {
    --v-primary:       #0071e3;
    --v-primary-light: #5ac8fa;
    --v-primary-dark:  #0051d5;

    --v-bg:        #f5f5f7;
    --v-panel:     #ffffff;
    --v-text:      #1d1d1f;
    --v-muted:     #6e6e73;
    --v-line:      rgba(0, 0, 0, .09);
    --v-line-soft: rgba(0, 0, 0, .05);

    --v-ok:     #1d9e5e;
    --v-warn:   #b25000;
    --v-danger: #c8102e;

    --v-pill:   980px;
    --v-radius: 18px;

    --v-shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
    --v-shadow-md: 0 1px 2px rgba(0, 0, 0, .04), 0 10px 30px rgba(0, 0, 0, .08);
    --v-shadow-lg: 0 2px 6px rgba(0, 0, 0, .05), 0 24px 60px rgba(0, 0, 0, .12);

    --v-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
              Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    /* iPhone centigi ve alt cubugu icin guvenli kenar bosluklari. */
    --v-safe-top:    0px;
    --v-safe-bottom: 0px;
}

@supports (padding: max(0px)) {
    :root {
        --v-safe-top:    env(safe-area-inset-top, 0px);
        --v-safe-bottom: env(safe-area-inset-bottom, 0px);
    }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--v-bg);
    color: var(--v-text);
    font-family: var(--v-font);
    font-size: 15px;
    line-height: 1.5;
    overflow-x: hidden;
    overscroll-behavior-y: none;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Cerceve ------------------------------------------------------------- */

.viewer {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* --- Ust bar ------------------------------------------------------------- */

.viewer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 14px 24px;
    padding-top: calc(14px + var(--v-safe-top));
    background: rgba(255, 255, 255, .82);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--v-line);
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}

.viewer-head .doc-meta { min-width: 0; flex: 1 1 240px; }

.viewer-head .company {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--v-primary);
    overflow-wrap: anywhere;
}

.viewer-head .doc-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -.015em;
    margin: 3px 0 0;
    color: var(--v-text);
    overflow-wrap: anywhere;
}

.viewer-head .doc-date {
    font-size: 13px;
    color: var(--v-muted);
    margin-top: 3px;
}

.viewer-head .doc-date .sep { opacity: .45; margin: 0 6px; }

/* --- Butonlar ------------------------------------------------------------ */

.viewer-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
}

.vbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    padding: 9px 18px;
    border-radius: var(--v-pill);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    background: rgba(0, 0, 0, .05);
    border: 1px solid transparent;
    color: var(--v-text);
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .18s ease, color .18s ease,
                border-color .18s ease, transform .12s ease, box-shadow .18s ease;
}

/* Gorsel zaten ekrana sigiyorsa yakinlastirma butonu gizlenir. */
.vbtn[hidden] { display: none; }

.vbtn:hover  { background: rgba(0, 0, 0, .09); }
.vbtn:active { transform: scale(.97); }

.vbtn:focus-visible {
    outline: 2px solid var(--v-primary);
    outline-offset: 2px;
}

.vbtn.primary {
    background: var(--v-primary);
    color: #fff;
    box-shadow: var(--v-shadow-sm);
}
.vbtn.primary:hover { background: var(--v-primary-dark); }

.vbtn.ghost {
    background: transparent;
    border-color: var(--v-line);
    color: var(--v-muted);
}
.vbtn.ghost:hover {
    background: rgba(0, 0, 0, .04);
    color: var(--v-text);
    border-color: rgba(0, 0, 0, .16);
}

.vbtn .ico { width: 15px; height: 15px; flex: none; }

/* Yakinlastirma acikken buyutec artisi kaybolur, eksi kalir. */
.vbtn.is-zoomed .zoom-plus { display: none; }

/* --- Belge alani --------------------------------------------------------- */

.viewer-body {
    flex: 1;
    min-height: 0;
    display: flex;
    padding: 18px;
    background:
        radial-gradient(1200px 420px at 50% -10%, rgba(0, 113, 227, .07), transparent 70%),
        var(--v-bg);
}

.doc-stage {
    flex: 1;
    min-width: 0;
    display: flex;
    position: relative;
    border-radius: var(--v-radius);
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--v-line-soft);
    box-shadow: var(--v-shadow-md);
}

.doc-stage iframe,
.doc-stage embed,
.doc-stage object {
    flex: 1;
    min-width: 0;
    border: 0;
    display: block;
}

/* Gorseller varsayilan olarak alana sigar. Yakinlastirilinca gercek boyuta
 * gecer ve kutu iki eksende kaydirilir; o durumda ortalama birakilir, yoksa
 * buyuk gorselin sol ust kosesi kirpilir ve erisilemez olur. */
.image-wrap {
    flex: 1;
    min-width: 0;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #fbfbfd;
}
.image-wrap img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: var(--v-shadow-lg);
    background: #fff;
    cursor: zoom-in;
}

.image-wrap.is-zoom {
    place-items: start;
    padding: 12px;
}
.image-wrap.is-zoom img {
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    cursor: zoom-out;
}

/* --- Alt bar ------------------------------------------------------------- */

.viewer-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 10px 24px;
    padding-bottom: calc(10px + var(--v-safe-bottom));
    background: rgba(255, 255, 255, .82);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--v-line);
    font-size: 12.5px;
    color: var(--v-muted);
}

.foot-secure {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--v-ok);
    font-weight: 500;
}
.foot-secure .ico { width: 13px; height: 13px; flex: none; }
.foot-secure .note { color: var(--v-muted); font-weight: 400; }

.foot-brand {
    flex: 1 1 auto;
    text-align: center;
    color: var(--v-muted);
    letter-spacing: .01em;
}
.foot-brand strong { color: var(--v-text); font-weight: 600; }

.countdown {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 13px;
    border-radius: var(--v-pill);
    background: rgba(0, 0, 0, .05);
    color: var(--v-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    transition: background-color .3s ease, color .3s ease;
}
.countdown .ico { width: 13px; height: 13px; flex: none; }
.countdown.is-warn   { background: rgba(178, 80, 0, .12);  color: var(--v-warn); }
.countdown.is-urgent { background: rgba(200, 16, 46, .12); color: var(--v-danger); }

/* --- Bilgi ekranlari (gecersiz baglanti / kapatildi / sure doldu) --------- */

.notice-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(900px 400px at 50% 0%, rgba(0, 113, 227, .08), transparent 70%),
        var(--v-bg);
}

/* Oturum sona erdiginde JS bu bloku belge alanina yerlestirir. */
.viewer-body .notice-wrap {
    flex: 1;
    min-height: 0;
    border-radius: var(--v-radius);
    border: 1px solid var(--v-line-soft);
    box-shadow: var(--v-shadow-md);
    background: #fff;
    overflow: auto;
}

.notice {
    max-width: 540px;
    width: 100%;
    background: var(--v-panel);
    border: 1px solid var(--v-line-soft);
    border-radius: 22px;
    padding: 40px 36px;
    text-align: center;
    box-shadow: var(--v-shadow-lg);
}
.viewer-body .notice { box-shadow: none; border: 0; background: transparent; }

.notice .icon {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    margin: 0 auto 22px;
    display: grid;
    place-items: center;
    font-size: 27px;
    font-weight: 600;
    line-height: 1;
    background: rgba(178, 80, 0, .1);
    color: var(--v-warn);
}
.notice .icon.ok { background: rgba(29, 158, 94, .1); color: var(--v-ok); }

.notice h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -.02em;
    margin: 0 0 12px;
}

.notice p {
    color: var(--v-muted);
    margin: 0 0 10px;
    line-height: 1.65;
}

.notice .steps-back {
    margin-top: 24px;
    padding: 16px 18px;
    border-radius: 14px;
    background: rgba(0, 113, 227, .06);
    border: 1px solid rgba(0, 113, 227, .16);
    font-size: 14px;
    color: #0b4f9e;
    text-align: left;
    line-height: 1.6;
}
.notice .steps-back strong { color: var(--v-primary-dark); }

/* Oturum dolunca gosterilen "Belgelerime don" baglantisi. */
.notice-actions {
    margin-top: 26px;
    display: flex;
    justify-content: center;
}
.notice-actions .vbtn { text-decoration: none; }

.notice-brand {
    margin-top: 26px;
    font-size: 12.5px;
    color: var(--v-muted);
}
.notice-brand strong { color: var(--v-text); font-weight: 600; }

/* --- Tablet -------------------------------------------------------------- */

@media (max-width: 880px) {
    .viewer-head { gap: 14px; padding-left: 18px; padding-right: 18px; }
    .viewer-head .doc-title { font-size: 19px; }
    .viewer-body { padding: 14px; }
}

/* --- Telefon ------------------------------------------------------------- */

@media (max-width: 640px) {
    body { font-size: 14px; }

    .viewer-head {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 14px;
        padding-top: calc(12px + var(--v-safe-top));
    }
    .viewer-head .doc-meta { flex: none; }
    .viewer-head .doc-title { font-size: 17px; line-height: 1.3; }
    .viewer-head .doc-date  { font-size: 12px; }

    .viewer-actions {
        width: 100%;
        justify-content: stretch;
        gap: 6px;
    }
    /* Parmakla basilacak kadar buyuk, satira sigacak kadar dar. */
    .vbtn {
        flex: 1 1 0;
        min-width: 0;
        min-height: 42px;
        padding: 9px 10px;
        font-size: 13.5px;
    }
    /* Yakinlastirma butonu darda yalnizca ikon gosterir; erisilebilir adi
     * aria-label ile korunur. */
    .vbtn.compact { flex: 0 0 auto; padding: 9px 14px; }
    .vbtn.compact .label { display: none; }

    .viewer-body { padding: 8px; }
    .doc-stage { border-radius: 14px; }
    .image-wrap { padding: 10px; }
    .image-wrap.is-zoom { padding: 0; }

    .viewer-foot {
        justify-content: space-between;
        padding: 8px 14px;
        padding-bottom: calc(8px + var(--v-safe-bottom));
        font-size: 11.5px;
        gap: 8px;
    }
    .foot-secure .note { display: none; }
    .foot-brand { flex-basis: 100%; order: 3; font-size: 11px; }
    .countdown { padding: 4px 10px; }

    .notice { padding: 30px 20px; border-radius: 18px; }
    .notice h1 { font-size: 19px; }
    .notice .icon { width: 54px; height: 54px; font-size: 23px; margin-bottom: 18px; }
    .notice-wrap { padding: 16px; }
}

@media (max-width: 380px) {
    .viewer-head .doc-title { font-size: 16px; }
    .vbtn { font-size: 12.5px; padding: 9px 8px; gap: 5px; }
    .vbtn .ico { width: 14px; height: 14px; }
}

/* Alcak yatay ekranlarda basligi kucultup belgeye yer ac. */
@media (max-height: 460px) and (orientation: landscape) {
    .viewer-head { padding-top: calc(8px + var(--v-safe-top)); padding-bottom: 8px; }
    .viewer-head .doc-title { font-size: 16px; margin-top: 1px; }
    .viewer-head .doc-date  { display: none; }
    .viewer-body { padding: 8px; }
    .viewer-foot { padding-top: 6px; padding-bottom: calc(6px + var(--v-safe-bottom)); }
}

/* --- Yazdirma ------------------------------------------------------------
 * Kagida yalnizca belgenin kendisi dusmeli. @page kenar bosluklari sifirlanir:
 * bu hem tarayicinin ekledigi tarih/URL ust-alt bilgisini kaldirir hem de
 * gorsele tam sayfa birakir. Guvenli bosluk .viewer-body icinde mm verilir,
 * boylece kenara basamayan yazicilarda da icerik kirpilmaz.
 * ------------------------------------------------------------------------- */

@media print {
    @page { size: auto; margin: 0; }

    .viewer-head,
    .viewer-foot { display: none !important; }

    html, body {
        background: #fff;
        height: auto;
        overflow: visible;
    }

    .viewer { height: auto; display: block; }

    .viewer-body {
        display: block;
        padding: 8mm;
        min-height: 0;
        background: #fff;
    }

    .doc-stage {
        display: block;
        height: auto;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
    }

    /* Yakinlastirma acik birakilmis olsa bile kagida sigdirilmis hali basilir. */
    .image-wrap,
    .image-wrap.is-zoom {
        display: block;
        height: auto;
        padding: 0;
        overflow: visible;
        background: #fff;
        text-align: center;
    }
    .image-wrap img,
    .image-wrap.is-zoom img {
        display: block;
        margin: 0 auto;
        max-width: 100%;
        max-height: calc(100vh - 16mm);
        width: auto;
        height: auto;
        border-radius: 0;
        box-shadow: none;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .notice { box-shadow: none; border: 0; }
}

/* --- Hareket azaltma tercihine saygi ------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
