/* MEDLY-RTC — siyah/beyaz, minimal arayüz (açık + karanlık tema) */

:root {
    --ink: #0a0a0a;          /* metin / vurgu */
    --paper: #ffffff;        /* arka plan */
    --line: rgba(10, 10, 10, .16);
    --soft: rgba(10, 10, 10, .55);
    --softbg: #f4f4f4;       /* bilgi şeridi zemini */
    --focus: rgba(10, 10, 10, .14);
    --scroll: rgba(10, 10, 10, .25);
    --me-link: rgba(255, 255, 255, .65);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color-scheme: light;
}

/* karanlık tema: değişkenler ters çevrilir, tüm arayüz siyah-beyaz kalır */
:root[data-theme="dark"] {
    --ink: #f2f2f2;
    --paper: #000000;
    --line: rgba(255, 255, 255, .18);
    --soft: rgba(255, 255, 255, .55);
    --softbg: #141414;
    --focus: rgba(255, 255, 255, .22);
    --scroll: rgba(255, 255, 255, .28);
    --me-link: rgba(0, 0, 0, .6);
    color-scheme: dark;
}

* { box-sizing: border-box; }

/* hidden özniteliği her zaman kazansın (display:flex/grid kuralı ezmesin) */
[hidden] { display: none !important; }

html, body { height: 100%; }

body.page {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

/* ---------- giriş ---------- */
body.page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.card {
    width: 100%;
    max-width: 380px;
    border: 1px solid var(--ink);
    border-radius: 16px;
    padding: 28px 26px 26px;
}

.brand {
    margin: 0 0 4px;
    font-size: 26px;
    letter-spacing: .14em;
    font-weight: 700;
}

.sub {
    margin: 0 0 22px;
    color: var(--soft);
    font-size: 13px;
}

.alert {
    margin: 0 0 16px;
    padding: 10px 12px;
    border: 1px solid var(--ink);
    border-left-width: 4px;
    border-radius: 8px;
    font-size: 13px;
}

/* kapatılamayan bilgi şeridi (ör. depolama uyarısı) */
.notice {
    margin: 0;
    padding: 7px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--softbg);
    color: var(--ink);
    font-size: 11.5px;
    line-height: 1.35;
}

.field { display: block; margin-bottom: 14px; }

.field > span {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 6px;
    color: var(--soft);
}

input[type="text"], input[type="password"], textarea {
    width: 100%;
    font: inherit;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--ink);
    border-radius: 10px;
    padding: 11px 13px;
    outline: none;
}

input:focus, textarea:focus {
    box-shadow: 0 0 0 3px var(--focus);
}

input::placeholder, textarea::placeholder {
    color: var(--soft);
    opacity: 1;
}

.btn {
    display: inline-block;
    border: 1px solid var(--ink);
    background: var(--ink);
    color: var(--paper);
    font: inherit;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 999px;
    cursor: pointer;
    transition: opacity .15s ease;
}

.btn:hover { opacity: .82; }
.btn:active { transform: translateY(1px); }

.login-form .btn { width: 100%; margin-top: 6px; }

/* ---------- yerleşim: sol pano | sohbet | sağ pano ---------- */
.shell {
    position: fixed;
    inset: 0;
    margin: 0 auto;
    max-width: 1220px;
    display: grid;
    grid-template-columns: 15.5rem minmax(0, 1fr) 15.5rem;
    /* minmax(0, 1fr): satır, içerikle birlikte UZAMAZ (kaydırma çubuğu bunun için şart) */
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "mine chat peer";
    overflow: hidden;
    background: var(--paper);
}

.chat {
    grid-area: chat;
    min-width: 0;
    min-height: 0;          /* olmazsa .log taşmaz, kaydırma çubuğu çıkmaz */
    height: 100%;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    background: var(--paper);
}

.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ink);
}

.who { display: flex; align-items: center; gap: 9px; font-size: 15px; }

.dot {
    width: 9px;
    height: 9px;
    border: 1.5px solid var(--ink);
    border-radius: 50%;
    background: transparent;
    flex: 0 0 auto;
}

.dot--on { background: var(--ink); }

.tools { display: flex; align-items: center; gap: 10px; }

.net { font-size: 11px; color: var(--soft); text-transform: lowercase; }
.net--off { color: var(--ink); font-weight: 700; }

.icon {
    border: 1px solid var(--ink);
    background: var(--paper);
    color: var(--ink);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    padding: 0;
}

.icon[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.log {
    flex: 1 1 auto;
    min-height: 0;          /* flex içinde taşma için şart */
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 16px 16px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty { margin: auto; color: var(--soft); font-size: 13px; }

.row { display: flex; }
/* Dikkat: aşağıda .row--me için flex-direction: row-reverse tanımlıdır ve
   ana ekseni ters çevirdiği için hizalamayı da orada (flex-start) veriyoruz. */
.row--me { justify-content: flex-end; }

.bubble {
    max-width: 78%;
    padding: 9px 13px 7px;
    border-radius: 16px;
    font-size: 15px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.row--me .bubble {
    background: var(--ink);
    color: var(--paper);
    border-bottom-right-radius: 5px;
}

.row--you .bubble {
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--ink);
    border-bottom-left-radius: 5px;
}

.bubble .text { white-space: pre-wrap; display: block; overflow-wrap: anywhere; }

.bubble .text a.link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}

.row--me .bubble .text a.link { text-decoration-color: var(--me-link); }

/* çok uzun metinler: balonun içinde kaydırılır, sohbeti kaplamaz */
.bubble--long .text {
    max-height: 46vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
}

.bubble--long::after {
    content: 'uzun mesaj';
    display: block;
    font-size: 9px;
    letter-spacing: .1em;
    text-transform: uppercase;
    opacity: .45;
    margin-top: 2px;
}

.bubble .time {
    display: block;
    margin-top: 3px;
    font-size: 10px;
    letter-spacing: .04em;
    opacity: .6;
    text-align: right;
}

.row--failed .bubble {
    background: var(--paper);
    color: var(--ink);
    border: 1px dashed var(--ink);
}

.row--failed .time { opacity: 1; font-weight: 700; }

.typing {
    height: 20px;
    padding: 0 18px;
    font-size: 12px;
    color: var(--soft);
    font-style: italic;
}

.composer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--ink);
}

.composer__row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    width: 100%;
}

.composer textarea {
    flex: 1 1 auto;
    resize: none;
    max-height: 132px;
    border-radius: 14px;
    padding: 11px 13px;
    line-height: 1.4;
}

.btn--send { padding: 11px 18px; }

/* ince kaydırma çubuğu */
.log::-webkit-scrollbar { width: 8px; }
.log::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 8px; }
.log::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 640px) {
    .chat { border-left: 0; border-right: 0; }
    .bubble { max-width: 86%; }
    body.page { padding: 12px; }
}

/* ================= pano (sol: ben, sağ: karşı taraf) ================= */

.board {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    background: var(--paper);
}

.board--mine { grid-area: mine; }
.board--peer { grid-area: peer; }

.board__top {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 12px 10px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}

.board__top strong { flex: 1 1 auto; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.count {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border: 1px solid var(--ink);
    border-radius: 999px;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    opacity: .8;
}

.board__add {
    display: flex;
    gap: 6px;
    padding: 10px;
    border-bottom: 1px solid var(--line);
}

.board__add input {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    padding: 8px 10px;
    border-radius: 8px;
}

.btn--mini {
    font-size: 12px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
}

.board__list {
    list-style: none;
    margin: 0;
    padding: 8px 10px 4px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.board__list::-webkit-scrollbar { width: 6px; }
.board__list::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 6px; }

.item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 7px 8px;
    border: 1px solid var(--line);
    border-radius: 9px;
    font-size: 12.5px;
    line-height: 1.35;
}

.item .num {
    flex: 0 0 auto;
    min-width: 15px;
    font-variant-numeric: tabular-nums;
    opacity: .6;
    font-size: 11px;
    padding-top: 1px;
}

.item .txt {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.item .acts {
    flex: 0 0 auto;
    display: flex;
    gap: 2px;
    opacity: .45;
    transition: opacity .12s ease;
}

.item:hover .acts, .item:focus-within .acts { opacity: 1; }

.mini {
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

.mini:hover { border-color: var(--ink); }

.board__hint {
    margin: 0;
    padding: 6px 12px 12px;
    font-size: 10px;
    color: var(--soft);
    border-top: 1px solid var(--line);
}

.board__close { display: none; }

/* ================= emoji seçici ================= */

.emojis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    gap: 2px;
    max-height: 172px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--softbg);
}

.emojis button {
    border: 0;
    background: transparent;
    font-size: 19px;
    line-height: 1;
    padding: 6px 0;
    border-radius: 8px;
    cursor: pointer;
}

.emojis button:hover { background: var(--paper); }

.icon--flat { border: 0; font-size: 19px; width: 34px; height: 34px; }

/* ================= yanıtlama ================= */

.replybar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-left: 3px solid var(--ink);
    background: var(--softbg);
    border-radius: 0 8px 8px 0;
    font-size: 12px;
}

.replybar__txt {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: .85;
}

.replybar__txt strong { margin-right: 4px; }

.row { align-items: flex-start; gap: 6px; }

/* row-reverse ana ekseni ters çevirir: flex-start artık SAĞ taraf olur.
   Bu yüzden kendi mesajlarım sağda kalır, ↩ düğmesi de balonun soluna (iç tarafa) gelir. */
.row--me { flex-direction: row-reverse; justify-content: flex-start; }

.reply-btn {
    flex: 0 0 auto;
    align-self: center;
    border: 0;
    background: transparent;
    color: var(--soft);
    font-size: 14px;
    padding: 2px 4px;
    cursor: pointer;
    opacity: .35;
    transition: opacity .12s ease;
}

.row:hover .reply-btn, .reply-btn:focus { opacity: 1; }

.quote {
    display: block;
    margin-bottom: 5px;
    padding: 4px 8px;
    border-left: 2px solid currentColor;
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    opacity: .72;
    cursor: pointer;
    overflow: hidden;
}

.quote strong { display: block; font-size: 10.5px; letter-spacing: .02em; }

.quote span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.row--flash .bubble { outline: 2px solid var(--ink); outline-offset: 2px; }

/* veri gelmediğinde mesaj listesinde görünen uyarı */
.dataloss {
    margin: auto;
    max-width: 420px;
    padding: 14px 16px;
    border: 1px solid var(--ink);
    border-radius: 12px;
    background: var(--softbg);
    font-size: 12.5px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

/* teşhis uyarı şeridi: arayüz kodu çalışmadıysa ekranın altında görünür */
.bootwarn {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99;
    padding: 9px 14px;
    background: var(--ink);
    color: var(--paper);
    font-size: 12px;
    line-height: 1.35;
    text-align: center;
}

/* ================= dar ekran: panolar kayan panel ================= */

@media (max-width: 980px) {
    .shell {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "chat";
    }

    .board {
        position: fixed;
        top: 0;
        bottom: 0;
        width: min(86vw, 21rem);
        z-index: 40;
        border: 0;
        transition: transform .18s ease;
    }

    .board--mine { left: 0; transform: translateX(-102%); border-right: 1px solid var(--ink); }
    .board--peer { right: 0; transform: translateX(102%); border-left: 1px solid var(--ink); }

    .shell.board-mine-open .board--mine { transform: none; }
    .shell.board-peer-open .board--peer { transform: none; }

    .board__close { display: inline-flex; align-items: center; justify-content: center; }

    .icon.pn { display: inline-flex; }
    .log { padding-left: 12px; padding-right: 12px; }
}

@media (min-width: 981px) {
    .icon.pn { display: none; }
}
