/* ---------------------------------------------------------------
   YKS Dijital Soru Arşivi + gizli chat arayüzü
   --------------------------------------------------------------- */

:root {
    color-scheme: light;   /* arşiv sayfası sabit light */
    --bg: #f4f6fa;
    --surface: #ffffff;
    --border: #e2e6ee;
    --text: #1b2333;
    --muted: #6b7488;
    --brand: #1e4fd8;
    --brand-soft: #eaf0ff;
    --danger: #c2334a;
    --danger-soft: #fdecef;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(18, 27, 51, .05), 0 8px 24px rgba(18, 27, 51, .06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.wrap {
    width: min(960px, 100% - 40px);
    margin-inline: auto;
}

/* ---------------- Arşiv sayfası ---------------- */

.hero { padding: 64px 0 28px; }

.eyebrow {
    margin: 0 0 10px;
    color: var(--brand);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.hero h1 {
    margin: 0 0 14px;
    font-size: clamp(28px, 4.5vw, 40px);
    line-height: 1.2;
    letter-spacing: -.02em;
}

.lead {
    margin: 0;
    max-width: 62ch;
    color: var(--muted);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}

.panel-title {
    margin: 0 0 6px;
    font-size: 19px;
}

.panel-desc {
    margin: 0 0 22px;
    color: var(--muted);
    font-size: 14px;
    max-width: 60ch;
}

.query-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 16px;
    align-items: start;
}

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

.field label {
    font-size: 13px;
    font-weight: 600;
}

.field input {
    font: inherit;
    color: var(--text);
    background: var(--bg);
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.field input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.field small {
    color: var(--muted);
    font-size: 12px;
}

.btn {
    align-self: start;
    margin-top: 25px;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--brand);
    border: 0;
    border-radius: 10px;
    padding: 12px 22px;
    cursor: pointer;
    transition: filter .15s;
    white-space: nowrap;
}

.btn:hover { filter: brightness(1.08); }

.alert {
    margin: 20px 0 0;
    padding: 12px 14px;
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(194, 51, 74, .2);
    border-radius: 10px;
    font-size: 14px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin: 28px 0;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat strong {
    display: block;
    font-size: 24px;
    letter-spacing: -.02em;
}

.stat span {
    color: var(--muted);
    font-size: 13px;
}

.faq { margin: 40px 0 60px; }

.faq h2 {
    font-size: 20px;
    margin: 0 0 16px;
}

.faq details {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 10px;
}

.faq summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
}

.faq p {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 24px 0;
    font-size: 13px;
    color: var(--muted);
}

.site-footer p { margin: 0 0 4px; }
.muted { opacity: .7; }

@media (max-width: 720px) {
    .query-form { grid-template-columns: 1fr; }
    .btn { margin-top: 4px; width: 100%; }
    .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------- Chat ---------------- */

.chat-body {
    background: var(--bg);
    overflow: hidden;
}

.chat-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: min(760px, 100%);
    margin-inline: auto;
    background: var(--surface);
    border-inline: 1px solid var(--border);
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.avatar {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-weight: 600;
}

.chat-peer {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

.chat-peer strong { font-size: 15px; }

.peer-status {
    font-size: 12px;
    color: var(--muted);
}

.icon-btn {
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
}

.icon-btn:hover {
    color: var(--danger);
    border-color: rgba(194, 51, 74, .35);
}

.offline-bar {
    display: none;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13px;
    text-align: center;
    padding: 6px;
    border-bottom: 1px solid rgba(194, 51, 74, .2);
}

.offline-bar.is-visible { display: block; }

.chat-scroll {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 16px;
    background:
        radial-gradient(circle at 20% 10%, rgba(30, 79, 216, .05), transparent 45%),
        var(--bg);
}

.chat-empty {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin-top: 40px;
}

.chat-empty.is-hidden { display: none; }

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.day-sep {
    align-self: center;
    margin: 12px 0 6px;
    padding: 4px 12px;
    font-size: 12px;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.msg {
    max-width: min(76%, 520px);
    padding: 9px 13px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

/* Yalnızca yeni gelen mesaj yumuşakça belirir; mevcut baloncuklar hiç yeniden çizilmez. */
.msg.is-new { animation: fade-in .22s ease-out both; }

.msg.mine {
    align-self: flex-end;
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    border-radius: 16px;
    border-bottom-right-radius: 5px;
}

.msg + .msg.mine,
.msg.mine + .msg:not(.mine) { margin-top: 8px; }

.msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    margin-top: 3px;
    font-size: 11px;
    color: var(--muted);
    user-select: none;
}

.msg.mine .msg-meta { color: rgba(255, 255, 255, .75); }

.ticks {
    letter-spacing: -2px;
    font-size: 12px;
    transition: color .25s ease;
}

.ticks.seen { color: #9ed8ff; letter-spacing: -3px; }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .msg.is-new { animation: none; }
}

.composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.composer textarea {
    flex: 1;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 10px 15px;
    resize: none;
    max-height: 140px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.composer textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.send-btn {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    transition: filter .15s, opacity .15s;
}

.send-btn:hover { filter: brightness(1.08); }
.send-btn:disabled { opacity: .5; cursor: default; }

/* ---------------- Koyu tema (yalnızca chat) ----------------
   Arşiv sayfası sistem temasından bağımsız olarak her zaman light kalır. */

@media (prefers-color-scheme: dark) {
    .chat-body {
        color-scheme: dark;
        --bg: #0f1117;
        --surface: #171a22;
        --border: #262a35;
        --text: #e8eaf0;
        --muted: #8d94a6;
        --brand: #3d6dff;
        --brand-soft: rgba(61, 109, 255, .16);
        --danger: #ff8095;
        --danger-soft: rgba(255, 128, 149, .12);
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    }

    .msg.mine { color: #fff; }
    .ticks.seen { color: #b7dcff; }
}
