/* ==========================================================================
   Oranix — canlı sohbet (panel, lobi, kartlar, mobil tam ekran). Yalnızca tokens.css / app.css değişkenleri;
   mantıksal özellikler (RTL hazır), koyu / açık tema değişkenlerle.
   ========================================================================== */

/* ---------------------------------------------------------------- Panel */
.chat {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
}
.chat--aside .chat__scroll { height: clamp(260px, 46vh, 420px); flex: none; }
.chat--page { height: clamp(480px, calc(100dvh - 240px), 920px); }
.chat--admin { height: 640px; border: 0; border-radius: 0; background: transparent; }
.chat--page .chat__body, .chat--admin .chat__body { flex: 1; min-height: 0; }
.chat--page .chat__scroll, .chat--admin .chat__scroll { flex: 1; }

.chat__head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-block-end: 1px solid var(--border); }
.chat__toggle {
  display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); cursor: pointer;
}
.chat__toggle:hover { background: var(--surface2); color: var(--text); }
.chat__toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.chat__chev { transition: transform var(--motion-fast) var(--ease); }
.chat.is-collapsed .chat__chev { transform: rotate(-90deg); }
[dir="rtl"] .chat.is-collapsed .chat__chev { transform: rotate(90deg); }
.chat__heading { flex: 1; min-width: 0; }
.chat__title { display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--font-display); font-size: var(--fs-md); font-weight: 700; line-height: 1.25; }
.chat__dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--text-muted); }
.chat__dot.is-open { background: var(--live); animation: chat-pulse 1.6s infinite; }
@keyframes chat-pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 46, 77, 0.5); } 70% { box-shadow: 0 0 0 6px rgba(255, 46, 77, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 46, 77, 0); } }
@media (prefers-reduced-motion: reduce) { .chat__dot.is-open { animation: none; } }
.chat__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin: 2px 0 0; font-size: var(--fs-xs); color: var(--text-secondary); }
.chat__meta > span { display: inline-flex; align-items: center; gap: 4px; }
.chat__meta [hidden] { display: none; }
.chat__tools { display: flex; align-items: center; gap: 2px; flex: none; }
.chat__lang {
  height: 30px; max-width: 120px; padding: 0 26px 0 10px; border-radius: var(--radius-pill); border: 1px solid var(--border);
  background-color: var(--surface2); color: var(--text); font-size: var(--fs-xs);
}
.chat__sheet-close { display: none; }

.chat__body { position: relative; display: flex; flex-direction: column; min-height: 0; }
.chat__pinned {
  display: flex; align-items: center; gap: 8px; padding: 6px var(--space-4); font-size: var(--fs-sm);
  background: var(--accent-soft); border-block-end: 1px solid var(--border);
}
.chat__pinned-label { flex: none; font-size: 10.5px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); }
.chat__pinned-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat__notice { padding: 6px var(--space-4); font-size: var(--fs-xs); color: var(--text-secondary); background: var(--surface2); border-block-end: 1px solid var(--border); }
.chat__notice[data-kind="offline"], .chat__notice[data-kind="warn"] { background: var(--warning-soft); color: var(--text); }
.chat__notice[data-kind="ban"] { background: var(--danger-soft); color: var(--text); font-weight: 600; }
/* Maç sonu: oda kapanış geri sayımı */
.chat__closing {
  display: flex; align-items: center; gap: 6px; padding: 6px var(--space-4); font-size: var(--fs-xs); font-weight: 600;
  color: var(--text); background: var(--warning-soft); border-block-end: 1px solid var(--border); font-variant-numeric: tabular-nums;
}
.chat__closing[hidden] { display: none; }
.chat__slowbadge.is-auto { color: var(--warning-text); }

.chat__scroll { position: relative; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-block: var(--space-2); }
.chat__scroll:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.chat__list { list-style: none; margin: 0; padding: 0; }
.chat__placeholder { margin: 0; padding: var(--space-8) var(--space-4); text-align: center; font-size: var(--fs-sm); color: var(--text-muted); }
.chat__older { display: flex; margin: 2px auto 6px; }
.chat__pill {
  position: relative; z-index: 2; align-self: center; display: inline-flex; align-items: center; gap: 6px;
  height: 30px; margin: -40px auto 10px; padding: 0 14px; border: 0; border-radius: var(--radius-pill);
  background: var(--btn-primary-bg); color: var(--btn-primary-fg); font-size: var(--fs-xs); font-weight: 700; box-shadow: var(--shadow); cursor: pointer;
}
.chat__pill[hidden] { display: none; }

/* ---------------------------------------------------------------- Mesajlar */
.chat-msg { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 5px var(--space-4); }
.chat-msg:hover, .chat-msg:focus-within { background: var(--surface2); }
.chat-msg[hidden] { display: none; }
.chat-msg__avatar {
  display: inline-grid; place-items: center; width: 28px; height: 28px; overflow: hidden; border-radius: 50%;
  background: var(--violet-500); color: #fff; font-family: var(--font-display); font-size: 11px; font-weight: 700; margin-block-start: 2px;
}
.chat-msg__avatar img { width: 100%; height: 100%; object-fit: cover; background: var(--surface3); }
.chat-msg__avatar[data-c="1"] { background: var(--sky-600); }
.chat-msg__avatar[data-c="2"] { background: var(--win-600); }
.chat-msg__avatar[data-c="3"] { background: var(--draw-600); }
.chat-msg__avatar[data-c="4"] { background: var(--loss-600); }
.chat-msg__avatar[data-c="5"] { background: var(--volt-700); }
.chat-msg__avatar[data-c="6"] { background: var(--violet-700); }
.chat-msg__avatar[data-c="7"] { background: var(--ink-500); }
.chat-msg__avatar[data-c="mod"] { background: var(--gradient-ai); }
.chat-msg__body { min-width: 0; }
.chat-msg__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; font-size: var(--fs-xs); line-height: 1.3; }
.chat-msg__name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.chat-msg.is-own .chat-msg__name { color: var(--primary-text); }
.chat-msg__time { font-size: 11px; color: var(--text-muted); }
.chat-msg__text {
  margin: 1px 0 0; font-size: var(--fs-sm); line-height: 1.45; color: var(--text);
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; overflow: hidden;
}
.chat-msg__quote {
  margin: 3px 0 1px; padding: 1px 8px; border-inline-start: 3px solid var(--border-strong); color: var(--text-secondary);
  font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-msg__qname { font-weight: 600; }
.chat-msg__edited { font-size: 11px; font-style: italic; color: var(--text-muted); }
.chat-msg__more {
  width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary);
  font-size: 18px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity var(--motion-fast);
}
.chat-msg:hover .chat-msg__more, .chat-msg__more:focus-visible, .chat-msg__more[aria-expanded="true"] { opacity: 1; }
.chat-msg__more:hover { background: var(--surface3); color: var(--text); }
.chat-msg__more:focus-visible { outline: 2px solid var(--primary); outline-offset: 0; }
@media (hover: none) { .chat-msg__more { opacity: 0.7; } }
.chat-msg--moderator { background: var(--accent-soft); }
.chat-msg--moderator:hover { background: var(--accent-soft); }
.chat-msg--system { grid-template-columns: minmax(0, 1fr) auto; align-items: center; margin: 4px var(--space-3); padding: 6px 10px; border-radius: var(--radius-sm); background: var(--surface2); }
.chat-msg__sys { margin: 0; font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary); overflow-wrap: anywhere; }
.chat-msg--system[data-ev="goal"] { background: var(--primary-soft); }
.chat-msg--system[data-ev="goal"] .chat-msg__sys { font-size: var(--fs-sm); color: var(--text); }
.chat-msg--system[data-ev="red"] { background: var(--danger-soft); }
.chat-msg--system[data-ev="ft"], .chat-msg--system[data-ev="ht"] { background: var(--surface3); }
.chat-msg--system[data-ev="closing"] { background: var(--warning-soft); }
.chat-msg--system[data-ev="closed"] { background: var(--surface3); }
.chat-badge { display: inline-flex; align-items: center; height: 16px; padding: 0 5px; border-radius: 4px; font-size: 9.5px; font-weight: 800; letter-spacing: 0.05em; }
.chat-badge--mod { background: var(--accent); color: #fff; }
.chat-badge--staff { background: var(--btn-primary-bg); color: var(--btn-primary-fg); }
.chat-badge--you { background: var(--surface3); color: var(--text-secondary); }

/* ---------------------------------------------------------------- Yazma alanı, kapı, moderatör çubuğu */
.chat__gate { padding: var(--space-3) var(--space-4); border-block-start: 1px solid var(--border); background: var(--surface2); font-size: var(--fs-sm); }
.chat__gate[data-reason="muted"], .chat__gate[data-reason="banned"] { background: var(--danger-soft); }
.chat__gate-text { margin: 0; color: var(--text-secondary); }
.chat__gate[data-reason="muted"] .chat__gate-text, .chat__gate[data-reason="banned"] .chat__gate-text { color: var(--text); font-weight: 600; }
.chat__countdown { margin: 4px 0 0; font-family: var(--font-display); font-size: var(--fs-md); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--danger-text); }
.chat__gate-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-block-start: 8px; }
.chat__composer { display: flex; flex-direction: column; gap: 6px; padding: var(--space-2) var(--space-3) var(--space-3); border-block-start: 1px solid var(--border); }
.chat__composer[hidden] { display: none; }
.chat.is-announce .chat__composer { background: var(--accent-soft); }
.chat__reply { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 2px 4px 2px 10px; border-radius: var(--radius-sm); background: var(--surface2); font-size: var(--fs-xs); color: var(--text-secondary); }
.chat__reply[hidden] { display: none; }
.chat__reply-text { flex: 1; min-width: 0; }
.chat__input {
  display: block; width: 100%; min-height: 40px; max-height: 132px; resize: none; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-elevated); color: var(--text);
  font: inherit; font-size: var(--fs-sm); line-height: 1.4;
}
.chat__input::placeholder { color: var(--muted); }
.chat__input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.chat__bar { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.chat__counter { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chat__counter.is-over { color: var(--danger-text); font-weight: 700; }
.chat__wait { flex: 1; min-width: 0; font-size: 11px; color: var(--warning-text); }
.chat__bar .btn { margin-inline-start: auto; }
.chat__error { margin: 0; font-size: var(--fs-xs); font-weight: 600; color: var(--danger-text); }
.chat__error[hidden] { display: none; }
.chat__modbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px var(--space-3); border-block-start: 1px dashed var(--border); background: var(--surface2); }
.chat__modbar[hidden] { display: none; }
.chat__modbar .select { width: auto; }
.chat__modbar [aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* Mesaj menüsü (tek açılır menü; tetikleyicinin altında) */
.chat__menu {
  position: absolute; z-index: 30; min-width: 190px; max-width: min(280px, calc(100% - 16px)); padding: 4px;
  background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-md); box-shadow: var(--shadow);
}
.chat__menu[hidden] { display: none; }
.chat__menu-item { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: var(--fs-sm); text-align: start; cursor: pointer; }
.chat__menu-item:hover, .chat__menu-item:focus-visible { outline: none; background: var(--surface2); }
.chat__menu-item.is-danger { color: var(--danger-text); }
.chat__menu-sep { height: 1px; margin: 4px; background: var(--border); }
.chat__menu-title { margin: 6px 10px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary); }
.chat__noscript { margin: 0; padding: var(--space-4); font-size: var(--fs-sm); color: var(--text-secondary); }

/* ---------------------------------------------------------------- Mobil: kayan düğme + tam ekran */
.chat-fab { display: none; }
@media (max-width: 1023px) {
  .chat-fab {
    position: fixed; z-index: 40; inset-inline-end: 16px; inset-block-end: calc(88px + env(safe-area-inset-bottom));
    display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 16px; border: 0; border-radius: var(--radius-pill);
    background: var(--btn-primary-bg); color: var(--btn-primary-fg); font-size: var(--fs-sm); font-weight: 700; box-shadow: var(--shadow); cursor: pointer;
  }
  .chat-fab .icon { width: 18px; height: 18px; }
  .chat-fab__count:empty { display: none; }
  .chat-fab__count { min-width: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: rgba(0, 0, 0, 0.18); font-size: 11px; text-align: center; }
  .chat--sheet {
    position: fixed; inset: 0; z-index: 60; height: 100dvh; max-height: none; border: 0; border-radius: 0;
    padding-block-end: env(safe-area-inset-bottom);
  }
  .chat--sheet .chat__body { flex: 1; min-height: 0; }
  .chat--sheet .chat__body[hidden] { display: flex; }
  .chat--sheet .chat__scroll { flex: 1; height: auto; }
  .chat--sheet .chat__sheet-close { display: inline-flex; }
  .chat--sheet .chat__toggle { display: none; }
  html.chat-sheet-open, html.chat-sheet-open body { overflow: hidden; }
  html.chat-sheet-open .chat-fab { display: none; }
}
@media (max-width: 479px) {
  .chat-msg { padding-inline: var(--space-3); }
  .chat__head { padding-inline: var(--space-3); }
}

/* ---------------------------------------------------------------- Lobi ve kartlar */
.chat-grid { align-items: stretch; }
.chat-room { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; padding: var(--space-4); color: var(--text); }
.chat-room__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.chat-room__teams { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--space-2); min-width: 0; }
.chat-room__teams--single { grid-template-columns: minmax(0, 1fr); }
.chat-room__team { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--fs-sm); font-weight: 600; }
.chat-room__team--away { justify-content: flex-end; text-align: end; }
.chat-room__score { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700; }
.chat-room__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-room__presence { display: inline-flex; align-items: center; gap: 4px; }
.chat-room__presence[hidden] { display: none; }
.chat-general { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5); color: var(--text); }
.chat-general__icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--primary-soft); color: var(--primary-text); }
.chat-general__main { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
@media (max-width: 479px) { .chat-general { flex-wrap: wrap; } .chat-general .btn { width: 100%; } }
.chat-card__head { display: flex; align-items: center; gap: 10px; }
.chat-card__icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--live-soft); color: var(--live-text); }
.chat-card__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.chat-card__presence { display: inline-flex; align-items: center; gap: 4px; }
.chat-rooms { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.chat-room-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-block-end: 1px solid var(--border); color: var(--text); }
.chat-rooms li:last-child .chat-room-row { border-block-end: 0; }
.chat-room-row:hover { color: var(--link); }
.chat-room-row__teams { display: grid; flex: 1; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-sm); }
.chat-room-row__teams > :last-child { text-align: end; }
.chat-room-row__meta { display: inline-flex; flex: none; align-items: center; gap: 6px; }
.chat-soon__title { display: flex; align-items: center; gap: 8px; }
/* Misafir: sohbet yalnızca üyelere açık — mesaj yok, giriş çağrısı */
.chat-guest { display: flex; flex-direction: column; gap: var(--space-3); }
.chat-guest__head { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.chat-guest__icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--live-soft); color: var(--live-text); }
.chat-guest__heading { flex: 1; min-width: 0; }
.chat-guest__text { margin: 0; font-size: var(--fs-sm); color: var(--text-secondary); }
.chat-guest__rules { margin: 0; }
.chat-guest .chat__gate-actions { margin-block-start: 0; }
.chat-guest--page { padding: var(--space-6); }

/* Tam sayfa oda */
.chat-page { display: grid; gap: var(--space-6); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1024px) { .chat-page { grid-template-columns: minmax(0, 1fr) 300px; } }
.chat-page__main { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.chat-page__fixture { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); color: var(--text); }
.chat-page__score { display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: var(--font-display); font-size: var(--fs-xl); }
@media (max-width: 1023px) { .chat-page__aside { order: 2; } }

/* ---------------------------------------------------------------- Yönetim: yasaklar ve arşiv */
.chat-adm-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: var(--fs-sm); }
.chat-adm-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.chat-adm-narrow { width: 8.5rem; }
.chat-ts { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.chat-ts__row { display: grid; grid-template-columns: 82px minmax(0, 150px) minmax(0, 1fr) auto; gap: 4px var(--space-3); align-items: start; padding: 6px var(--space-3); border-block-end: 1px solid var(--border); font-size: var(--fs-sm); }
.chat-ts__row:last-child { border-block-end: 0; }
.chat-ts__time { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chat-ts__who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.chat-ts__text { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-ts__note { display: block; margin-block-start: 2px; font-size: var(--fs-xs); color: var(--text-secondary); }
.chat-ts__row[data-status="hidden"], .chat-ts__row[data-status="removed"] { background: var(--danger-soft); }
.chat-ts__row[data-status="shadow"] { background: var(--warning-soft); }
.chat-ts__row[data-status="blocked"] { background: var(--surface2); border-inline-start: 3px solid var(--danger-text); }
.chat-ts__row[data-kind="system"] { color: var(--text-secondary); }
.chat-ts__row[data-kind="moderator"] { background: var(--accent-soft); }
@media (max-width: 767px) {
  .chat-ts__row { grid-template-columns: minmax(0, 1fr) auto; }
  .chat-ts__time { grid-column: 1; }
  .chat-ts__who { grid-column: 1 / -1; }
  .chat-ts__text { grid-column: 1 / -1; }
}
