/* ==========================================================================
   FITFAK E2EE — SADE, HAFİF VE GPU DOSTU TASARIM (SIFIR KASMALI PERFORMANS)
   ========================================================================== */

:root {
  --bg-main: #0b0e14;
  --bg-panel: #121721;
  --bg-input: #181f2c;
  --border: #232c3d;
  --text: #eef2f6;
  --text-dim: #8b98ad;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --emerald: #10b981;
  --danger: #e11d48;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-main);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.icon-xs { width: 14px; height: 14px; flex-shrink: 0; }
.icon-sm { width: 18px; height: 18px; flex-shrink: 0; }
.icon-md { width: 22px; height: 22px; flex-shrink: 0; }

/* GİRİŞ MODALI */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(8, 11, 16, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.16);
  color: #60a5fa;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-dim);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.text-input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.text-input:focus {
  border-color: var(--accent);
}

.btn-primary {
  margin-top: 4px;
  padding: 11px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

/* ANA DÜZEN */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  max-width: 960px;
  margin: 0 auto;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--bg-main);
}

.topbar {
  height: 54px;
  padding: 0 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
}

.channel-name {
  font-weight: 700;
  font-size: 15px;
}

.member-pill {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-input);
  padding: 3px 9px;
  border-radius: 999px;
}

.btn-call {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--emerald);
  color: #042f1e;
  font-weight: 700;
  font-size: 13px;
}

/* TAM EKRAN GÖRÜNTÜLÜ GÖRÜŞME SAHNESİ */
.video-stage {
  position: fixed;
  inset: 0;
  width: 100dvw;
  height: 100dvh;
  z-index: 600;
  background: #05070a;
  overflow: hidden;
  user-select: none;
}

.video-top-bar {
  position: absolute;
  top: max(14px, env(safe-area-inset-top, 14px));
  left: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.call-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 20, 28, 0.88);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: var(--emerald);
  font-size: 12px;
  font-weight: 600;
}

.call-timer {
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(15, 20, 28, 0.88);
  border: 1px solid var(--border);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.remote-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  background: #06090e;
}

.remote-tile {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.remote-name-tag {
  position: absolute;
  left: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  padding: 5px 11px;
  border-radius: 8px;
  background: rgba(10, 14, 20, 0.85);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
}

.waiting-box {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
}

/* SAĞ ALT KÜÇÜK PENCERE: KENDİ GÖRÜNTÜN (PiP — GPU HIZLANDIRMALI) */
.self-pip {
  position: absolute;
  right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  width: 124px;
  height: 176px;
  border-radius: 12px;
  overflow: hidden;
  background: #10151f;
  border: 2px solid rgba(255, 255, 255, 0.25);
  z-index: 30;
  touch-action: none;
  will-change: transform;
  cursor: grab;
}

.self-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.self-video.mirrored {
  transform: scaleX(-1);
}

/* ALT KONTROL BARI */
.call-dock {
  position: absolute;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 20px;
  background: #111621;
  border: 1px solid var(--border);
}

.dock-btn {
  min-width: 64px;
  height: 52px;
  padding: 0 12px;
  border-radius: 14px;
  background: #1a2232;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.dock-btn.active {
  background: rgba(37, 99, 235, 0.24);
  color: #93c5fd;
}

.dock-btn.muted-off {
  background: rgba(225, 29, 72, 0.22);
  color: #fda4af;
}

.dock-btn-hangup {
  background: var(--danger);
  color: #fff;
}

.dock-icon {
  width: 20px;
  height: 20px;
}

.dock-label {
  font-size: 10.5px;
  font-weight: 600;
}

/* SOHBET ALANI */
.chat-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-item {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}

.msg-item.self {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-item.peer {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.msg-author {
  font-weight: 600;
  color: #cbd5e1;
}

.msg-bubble {
  padding: 9px 13px;
  border-radius: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.msg-item.self .msg-bubble {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chat-bar {
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-input {
  flex: 1;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.chat-input:focus {
  border-color: var(--accent);
}

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .app-container {
    border: none;
  }
  .self-pip {
    width: 108px;
    height: 154px;
    right: 12px;
  }
  .call-dock {
    width: calc(100vw - 24px);
    max-width: 390px;
    justify-content: space-around;
  }
  .msg-item {
    max-width: 88%;
  }
}
