/* WebRTC Sohbet - Arayüz stilleri (BRD v1.0)
   Responsive / duyarlı tasarım (BR-008). */

:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #1e293b;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 12px;
}

* { box-sizing: border-box; }

/* `hidden` attribute'u her zaman gizlesin. Aksi halde .overlay { display:flex } gibi
   class kuralları, daha düşük öncelikli UA `[hidden]{display:none}` kuralını ezer ve
   eleman hidden olsa bile görünür kalır (overlay/retry butonu kalıcı görünme bug'ı). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* ---- Kartlar / formlar ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.brand { margin: 0 0 .25rem; font-size: 1.6rem; }
.brand-sm { font-weight: 700; letter-spacing: .3px; }
.subtitle { margin: 0 0 1.5rem; color: var(--muted); font-size: .95rem; }

.form { display: flex; flex-direction: column; gap: .4rem; }
.form label { font-size: .85rem; color: var(--muted); margin-top: .6rem; }
.form input {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: .7rem .8rem;
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
}
.form input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

.row { display: flex; gap: .5rem; }
.row input { flex: 1; }

.btn {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: .7rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  transition: background .15s;
}
.btn-primary { background: var(--primary); color: #fff; margin-top: 1rem; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg-soft); }

.error { color: #fca5a5; font-size: .85rem; margin: .5rem 0 0; }
.notice {
  margin-top: 1.25rem;
  font-size: .75rem;
  color: var(--muted);
  border-top: 1px dashed var(--line);
  padding-top: .75rem;
}

/* ============ ODA EKRANI ============ */
.room-page { display: flex; flex-direction: column; height: 100vh; }

.room-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; background: var(--bg-soft); border-bottom: 1px solid var(--line);
  gap: 1rem; flex-wrap: wrap;
}
.room-tag { color: var(--muted); margin-left: .75rem; font-size: .9rem; }

.status { font-size: .85rem; padding: .25rem .7rem; border-radius: 999px; white-space: nowrap; }
.status-wait { background: rgba(217,119,6,.2); color: #fbbf24; }
.status-ok { background: rgba(22,163,74,.2); color: #4ade80; }
.status-err { background: rgba(220,38,38,.2); color: #fca5a5; }

.room-main {
  flex: 1; display: grid; grid-template-columns: 1fr 320px;
  gap: 1rem; padding: 1rem; min-height: 0;
}

.video-area { position: relative; min-height: 0; }
.video-wrap {
  position: relative; width: 100%; height: 100%;
  background: #000; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line);
}
.video-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-wrap.local {
  position: absolute; right: 1rem; bottom: 1rem;
  width: 30%; max-width: 220px; height: auto; aspect-ratio: 4/3;
  z-index: 5; box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.video-name {
  position: absolute; left: .5rem; bottom: .5rem;
  background: rgba(0,0,0,.55); padding: .2rem .6rem; border-radius: 6px; font-size: .8rem;
}
.placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); text-align: center; padding: 1rem; background: #0b1220;
}

/* ---- Chat ---- */
.chat-area {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius);
}
.chat-header { padding: .75rem 1rem; border-bottom: 1px solid var(--line); font-weight: 600; }
.messages { flex: 1; overflow-y: auto; padding: .75rem; display: flex; flex-direction: column; gap: .5rem; }
.msg { max-width: 85%; padding: .45rem .7rem; border-radius: 10px; font-size: .9rem; line-height: 1.3; }
.msg-meta { display: block; font-size: .7rem; color: var(--muted); margin-bottom: .15rem; }
.msg-text { word-wrap: break-word; overflow-wrap: anywhere; }
.msg-self { align-self: flex-end; background: var(--primary); color: #fff; }
.msg-self .msg-meta { color: #dbeafe; }
.msg-peer { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); }
.msg-system { align-self: center; background: transparent; color: var(--muted); font-style: italic; font-size: .8rem; }
.chat-form { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: .6rem; border-radius: 8px; }

/* ---- Kontroller ---- */
.controls {
  display: flex; gap: .75rem; justify-content: center;
  padding: .75rem; background: var(--bg-soft); border-top: 1px solid var(--line);
}
.ctrl {
  cursor: pointer; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: .6rem 1rem;
  font-size: .95rem; display: inline-flex; align-items: center; gap: .4rem;
}
.ctrl:hover { background: var(--line); }
.ctrl.off { background: var(--warn); color: #fff; border-color: var(--warn); }
.ctrl-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.ctrl-danger:hover { background: #b91c1c; }

.room-notice { text-align: center; margin: 0; padding: .4rem; border: none; }

/* ---- Overlay ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem;
}
.overlay-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; max-width: 440px; text-align: center; }
.overlay-actions { display: flex; gap: .75rem; justify-content: center; margin-top: 1.25rem; }
.overlay-actions .btn { margin-top: 0; text-decoration: none; display: inline-flex; align-items: center; }

/* ============ ADMIN ============ */
.admin-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; background: var(--bg-soft); border-bottom: 1px solid var(--line); flex-wrap: wrap; gap: .75rem;
}
.admin-stats { display: flex; gap: 1.25rem; align-items: center; color: var(--muted); font-size: .9rem; }
.admin-stats strong { color: var(--text); }
.conn-dot { color: var(--ok); font-size: .8rem; }
.conn-dot.off { color: #fca5a5; }
.admin-main { padding: 1.5rem; max-width: 1000px; margin: 0 auto; }

.rooms-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.rooms-table th, .rooms-table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--line); }
.rooms-table th { background: var(--bg-soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.rooms-table code { background: var(--bg); padding: .15rem .4rem; border-radius: 5px; }
.rooms-table .empty { text-align: center; color: var(--muted); }

.badge { padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; text-decoration: none; }
.badge-ok { background: rgba(22,163,74,.2); color: #4ade80; }
.badge-wait { background: rgba(217,119,6,.2); color: #fbbf24; }

/* ---- Admin oda detayı ---- */
.room-row { cursor: pointer; transition: background .15s; }
.room-row:hover { background: var(--bg-soft); }
.room-detail { margin-top: 1.5rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.detail-head h2 { font-size: 1.1rem; }
.detail-head code { background: var(--bg); padding: .15rem .45rem; border-radius: 5px; }
.detail-chat { margin-top: 1.25rem; }
.detail-chat .chat-header { font-weight: 600; margin-bottom: .5rem; }
.detail-chat .messages { max-height: 280px; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
.detail-chat .empty { color: var(--muted); text-align: center; padding: 1rem; }

/* ============ RESPONSIVE (BR-008) ============ */
@media (max-width: 800px) {
  .room-main { grid-template-columns: 1fr; grid-template-rows: 1fr 260px; }
  .video-wrap.local { width: 38%; }
  .ctrl span { display: none; }
}
