/* MesajPlus - WhatsApp-benzeri dizayn */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --green-dark: #075E54;
  --green: #128C7E;
  --green-light: #25D366;
  --bubble-me: #DCF8C6;
  --bubble-other: #FFFFFF;
  --bg: #ECE5DD;
  --text: #111;
  --muted: #667781;
}
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}

/* ---------- Giris ---------- */
#loginScreen { align-items: center; justify-content: center; background: var(--green-dark); }
.login-box {
  background: #fff; border-radius: 16px; padding: 32px 24px;
  width: min(360px, 92vw); text-align: center;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.3);
}
.login-logo { font-size: 56px; }
.login-box h1 { color: var(--green-dark); font-size: 26px; }
.login-box input {
  padding: 12px; border: 1px solid #ccc; border-radius: 8px; font-size: 16px; width: 100%;
}
.btn-primary {
  background: var(--green-light); color: #fff; border: none;
  padding: 12px; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-primary:active { opacity: .8; }
.btn-secondary {
  background: #eee; border: 1px solid #ccc; padding: 8px; border-radius: 8px; cursor: pointer; width: 100%;
}
.login-box > div > input { margin-bottom: 8px; }
.login-box > div > p { margin-bottom: 8px; }
.error-text { color: #d32f2f; font-weight: 600; }
#otpCode { text-align: center; letter-spacing: 8px; font-size: 22px; font-weight: 700; }

/* Icaze xeberdarligi */
.perm-banner {
  background: #fff3cd; border-bottom: 1px solid #ffe08a;
  padding: 8px 12px; font-size: 13px; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
}
.perm-banner button {
  background: var(--green); color: #fff; border: none;
  padding: 6px 12px; border-radius: 6px; font-size: 12px;
  cursor: pointer; white-space: nowrap; margin-left: auto;
}

/* Devet linki paneli */
.header-btn {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  font-size: 18px; width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
}
.header-btn:active { opacity: .7; }
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-box {
  background: #fff; border-radius: 14px; padding: 22px;
  width: min(400px, 92vw); display: flex; flex-direction: column; gap: 10px;
}
.modal-box h3 { color: var(--green-dark); }
.invite-link {
  background: #f2f2f2; border-radius: 8px; padding: 10px;
  font-size: 13px; word-break: break-all; color: var(--green-dark); font-weight: 600;
}

.server-settings { text-align: left; margin-top: 8px; }
.server-settings summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.server-settings input { margin: 8px 0; }

/* ---------- Basliq ---------- */
.app-header {
  background: var(--green-dark); color: #fff;
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
  min-height: 56px; flex-shrink: 0;
  padding-top: max(10px, env(safe-area-inset-top));
}
.app-title { font-size: 20px; font-weight: 700; flex: 1; }
.header-right { display: flex; align-items: center; gap: 8px; }
.my-name { font-size: 14px; opacity: .9; }
.conn-dot {
  width: 12px; height: 12px; border-radius: 50%; display: inline-block;
  background: #f44; transition: background .3s;
}
.conn-dot.on { background: #4dff88; box-shadow: 0 0 6px #4dff88; }
.conn-dot.searching { background: #ffb300; }

/* ---------- Tablar ---------- */
.tab-page { flex: 1; overflow-y: auto; padding-bottom: 8px; }
.tabbar {
  display: flex; background: #fff; border-top: 1px solid #ddd; flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1; background: none; border: none; padding: 8px 0 6px;
  font-size: 22px; cursor: pointer; color: var(--muted); position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab-btn span { font-size: 11px; }
.tab-btn.active { color: var(--green); font-weight: 700; }
.badge {
  position: absolute; top: 4px; right: 24%;
  background: var(--green-light); color: #fff; border-radius: 10px;
  font-size: 11px; padding: 1px 6px; min-width: 18px;
}

/* ---------- Sohbet siyahisi ---------- */
.list-caption { padding: 12px 16px 4px; color: var(--green-dark); font-size: 14px; }
.chat-list { background: #fff; }
.chat-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid #f0f0f0; cursor: pointer;
}
.chat-item:active { background: #f5f5f5; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  background: var(--green); color: #fff; font-size: 20px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.avatar.online::after {
  content: ''; position: absolute; bottom: 0; right: 0;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--green-light); border: 2px solid #fff;
}
.chat-item-main { flex: 1; min-width: 0; }
.chat-item-name { font-weight: 600; }
.chat-item-last {
  font-size: 13px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 60vw;
}
.chat-item-meta { text-align: right; font-size: 11px; color: var(--muted); }
.chat-item-meta .badge { position: static; display: inline-block; margin-top: 4px; }
.empty-hint { text-align: center; padding: 40px 20px; color: var(--muted); }
.call-actions { display: flex; gap: 6px; }
.call-actions button {
  border: none; background: #e8f5e9; border-radius: 50%;
  width: 40px; height: 40px; font-size: 18px; cursor: pointer;
}

/* ---------- Sohbet penceresi ---------- */
#chatScreen { background: var(--bg); }
.chat-header { gap: 6px; }
.chat-peer { flex: 1; min-width: 0; }
.peer-name { font-weight: 700; font-size: 17px; }
.chat-header .small { color: #cfe9e5; }
.icon-btn {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: inherit; padding: 6px; border-radius: 50%; line-height: 1;
}
.icon-btn:active { background: rgba(255,255,255,.15); }

.messages {
  flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 6px;
  background-image: linear-gradient(rgba(229,221,213,.9), rgba(229,221,213,.9));
}
.msg {
  max-width: 78%; padding: 8px 10px; border-radius: 10px; font-size: 15px;
  box-shadow: 0 1px 1px rgba(0,0,0,.1); word-wrap: break-word; position: relative;
}
.msg.me { align-self: flex-end; background: var(--bubble-me); border-bottom-right-radius: 2px; }
.msg.other { align-self: flex-start; background: var(--bubble-other); border-bottom-left-radius: 2px; }
.msg .meta {
  font-size: 10px; color: var(--muted); text-align: right; margin-top: 2px;
  display: flex; gap: 4px; justify-content: flex-end; align-items: center;
}
.msg .ticks { color: #53bdeb; }
.msg .ticks.gray { color: #999; }
.msg img, .msg video { max-width: 100%; border-radius: 8px; display: block; }
.msg audio { max-width: 220px; width: 220px; }
.file-link {
  display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text);
  background: rgba(0,0,0,.05); padding: 8px; border-radius: 8px;
}
.file-link .fsize { font-size: 11px; color: var(--muted); }
.day-sep {
  align-self: center; background: #d5eaf7; color: #555; font-size: 12px;
  padding: 4px 10px; border-radius: 8px; margin: 6px 0;
}

.input-bar {
  display: flex; align-items: flex-end; gap: 4px; padding: 8px;
  background: #f0f0f0; flex-shrink: 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  position: relative;          /* ses yazma paneli bunun ustunde acilir */
}
.input-bar .icon-btn { color: var(--muted); }
.input-bar .send { color: var(--green); font-size: 24px; }
#msgInput {
  flex: 1; border: none; border-radius: 20px; padding: 10px 14px;
  font-size: 15px; resize: none; max-height: 110px; font-family: inherit;
}
#msgInput:focus { outline: none; }
.rec-bar, .upload-bar {
  background: #fff3e0; padding: 8px 14px; font-size: 14px; flex-shrink: 0;
}
.upload-track { height: 6px; background: #ddd; border-radius: 3px; margin-top: 4px; overflow: hidden; }
.upload-fill { height: 100%; width: 0; background: var(--green-light); transition: width .2s; }
/* ---------- SES YAZMA PANELI ----------
   Mikrofon duymesinin SOLUNDA, yazi sahesinin ustunde acilir.
   Sagdan sola suruserek gelir - barmaq mikrofondadir, animasiya onun
   yaninda baslayir. */
.rec-bar {
  position: absolute; left: 8px; right: 96px; bottom: 8px; z-index: 30;
  height: 46px; padding: 0 14px; border-radius: 23px;
  background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.18);
  color: #c62828; display: flex; align-items: center; gap: 10px;
  transform-origin: right center;
  animation: recIn .18s cubic-bezier(.2,.9,.3,1.2);
  transition: background .15s, color .15s;
}
@keyframes recIn {
  from { opacity: 0; transform: scaleX(.35); }
  to   { opacity: 1; transform: scaleX(1); }
}

.rec-bar .rec-dot {
  width: 11px; height: 11px; border-radius: 50%; background: #e53935;
  flex-shrink: 0; animation: recPulse 1s infinite;
}
@keyframes recPulse {
  0%, 100% { opacity: 1;  transform: scale(1); }
  50%      { opacity: .3; transform: scale(.8); }
}
#recTime {
  font-variant-numeric: tabular-nums; font-weight: 600;
  min-width: 40px; flex-shrink: 0;
}

/* --- Canli dalga: hunduruluk real mikrofon seviyyesinden gelir --- */
.rec-wave {
  flex: 1 1 auto; min-width: 70px; height: 26px;
  display: flex; align-items: center; justify-content: center; gap: 3px;
  overflow: hidden;
}
.rec-wave i {
  display: block; width: 3px; border-radius: 2px;
  background: linear-gradient(180deg, #ef5350, #c62828);
  height: 4px;
  transition: height .09s ease-out;
}

.rec-hint {
  margin-left: auto; opacity: .8; font-size: 13px; white-space: nowrap;
  flex-shrink: 0;
}
.rec-arrow { display: inline-block; animation: recArrow 1.1s infinite; }
@keyframes recArrow {
  0%, 100% { transform: translateX(0);    opacity: .4; }
  50%      { transform: translateX(-5px); opacity: 1; }
}

/* Barmaq sola surusdurulende - legv zonasi */
.rec-bar.will-cancel { background: #c62828; color: #fff; }
.rec-bar.will-cancel .rec-dot { background: #fff; animation: none; }
.rec-bar.will-cancel .rec-wave i { background: rgba(255,255,255,.65); }
.rec-bar.will-cancel .rec-hint { opacity: 1; font-weight: 700; }
.rec-bar.will-cancel .rec-arrow { animation: none; }

/* Yazi gedende mikrofon duymesi boyuyub qirmizilasir */
#recBtn.recording {
  transform: scale(1.35); color: #fff; background: #e53935;
  border-radius: 50%; box-shadow: 0 0 0 8px rgba(229,57,53,.18);
}
#recBtn { transition: transform .15s, background .15s, color .15s, box-shadow .15s; }

/* ---------- Qisa melumat yazisi ---------- */
.toast-box {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px);
  background: rgba(30, 30, 30, .92); color: #fff; padding: 10px 18px;
  border-radius: 20px; font-size: 14px; max-width: 86vw; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 9999;
}
.toast-box.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Proqrami qurasdirma teklifi (giris/devet ekrani) ---------- */
.install-box {
  margin-top: 18px; padding: 14px; border-radius: 12px;
  background: #f1f8f6; border: 1px solid #cfe6de; text-align: left;
}
.install-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.install-icon { font-size: 26px; line-height: 1; }
.install-title { font-weight: 700; font-size: 15px; color: var(--green-dark, #075E54); }
.install-sub { font-size: 12px; color: #6b7c76; margin-top: 2px; }
.install-btn {
  display: block; width: 100%; text-align: center; text-decoration: none;
  margin-top: 8px; box-sizing: border-box;
}
.install-note { margin-top: 8px; line-height: 1.45; }
.install-steps { margin: 4px 0 0; padding-left: 20px; font-size: 14px; line-height: 1.7; }
.install-steps li { margin-bottom: 2px; }
.ios-share {
  display: inline-block; padding: 0 5px; border: 1px solid #b9c9c3;
  border-radius: 5px; font-size: 12px;
}
.nowrap { white-space: nowrap; }

/* ---------- Status / sosial ---------- */
.status-composer {
  background: #fff; margin: 10px; border-radius: 12px; padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.status-composer textarea {
  width: 100%; border: none; resize: none; font-size: 15px; font-family: inherit;
}
.status-composer textarea:focus { outline: none; }
.composer-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.composer-row .small-btn { margin-left: auto; padding: 8px 20px; font-size: 14px; }
.status-feed { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 10px; }
.status-card {
  background: #fff; border-radius: 12px; padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.status-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.status-head .avatar { width: 38px; height: 38px; font-size: 16px; }
.status-user { font-weight: 700; }
.status-time { font-size: 11px; color: var(--muted); }
.status-text { font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.status-card img, .status-card video { max-width: 100%; border-radius: 8px; margin-top: 8px; }
.status-actions { display: flex; gap: 14px; margin-top: 10px; border-top: 1px solid #f0f0f0; padding-top: 8px; }
.status-actions button {
  background: none; border: none; cursor: pointer; font-size: 14px; color: var(--muted);
}
.status-actions button.liked { color: #e53935; font-weight: 700; }
.status-comments { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.status-comment { font-size: 13px; background: #f5f5f5; border-radius: 8px; padding: 6px 10px; }
.status-comment b { color: var(--green-dark); }
.comment-input-row { display: flex; gap: 6px; margin-top: 8px; }
.comment-input-row input {
  flex: 1; border: 1px solid #ddd; border-radius: 16px; padding: 6px 12px; font-size: 13px;
}
.comment-input-row button {
  background: var(--green); color: #fff; border: none; border-radius: 16px; padding: 6px 14px; cursor: pointer;
}

/* ---------- Zeng ekrani ----------
   VACIB: idare duymeleri videodan SONRA yox, USTUNDE (overlay) durur.
   Evvel altda idiler ve mobil brauzerin ünvan/alt paneli onlari orturdu -
   istifadeci "Zengi bitir" duymesini gore bilmirdi. */
.call-screen { background: #1a1a2e; color: #fff; position: fixed; inset: 0; }
.call-videos { position: absolute; inset: 0; background: #000; }
#remoteVideo { width: 100%; height: 100%; object-fit: cover; }

/* Oz kameramiz - suruskeli/olcusu deyisen pencere */
.local-box {
  position: absolute; bottom: 120px; right: 16px;
  width: 110px; height: 150px;
  border-radius: 10px; border: 2px solid rgba(255,255,255,.5);
  background: #222; overflow: hidden; touch-action: none; cursor: grab;
  z-index: 3;
}
.local-box.dragging { cursor: grabbing; border-color: var(--green-light); }
.local-box.full { inset: 0; width: auto; height: auto; border-radius: 0; border: none; }
#localVideo { width: 100%; height: 100%; object-fit: cover; display: block; }
/* On kamera guzgu kimi gorunmelidir; arxa kameraya kecende guzgu goturulur */
#localVideo.mirror { transform: scaleX(-1); }
.local-actions {
  position: absolute; top: 3px; left: 3px; display: flex; gap: 3px;
  opacity: 0; transition: opacity .15s;
}
.local-box:hover .local-actions, .local-box.touched .local-actions { opacity: 1; }
.mini-btn {
  background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 5px;
  width: 24px; height: 24px; font-size: 13px; cursor: pointer; line-height: 1;
}
.local-resize {
  position: absolute; right: 0; bottom: 0; width: 22px; height: 22px;
  cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,.7) 50%);
}
.local-box.full .local-resize { display: none; }

.call-info-overlay {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  text-align: center; padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  background: linear-gradient(rgba(0,0,0,.55), transparent);
  pointer-events: none;
}
.call-peer-name { font-size: 22px; font-weight: 700; }
.call-state { font-size: 13px; opacity: .85; }

.call-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  display: flex; justify-content: center; gap: 12px;
  padding: 16px 10px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,.65));
  flex-wrap: wrap;
}
.call-btn {
  width: 54px; height: 54px; border-radius: 50%; border: none;
  font-size: 22px; cursor: pointer; background: rgba(255,255,255,.18); color: #fff;
  position: relative; flex-shrink: 0;
}
.call-btn.active { background: var(--green-light); }
.chat-badge {
  position: absolute; top: -2px; right: -2px; background: #e53935;
  border-radius: 10px; min-width: 18px; height: 18px; font-size: 11px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
/* Dar telefonlarda 6 duyme bir setire sigsin - iki setir ekranin dordde
   birini yeyirdi */
@media (max-width: 430px) {
  .call-controls { gap: 7px; padding: 12px 6px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .call-btn { width: 46px; height: 46px; font-size: 19px; }
}

/* Zeng zamani yazisma */
.call-chat {
  position: absolute; z-index: 5; right: 0; bottom: 0; left: 0;
  max-height: 55%; background: rgba(20,20,35,.96);
  display: flex; flex-direction: column;
  border-top-left-radius: 14px; border-top-right-radius: 14px;
}
.call-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,.15); font-weight: 600;
}
.call-chat-body { flex: 1; overflow-y: auto; padding: 10px 14px; font-size: 14px; }
.call-chat-msg { margin-bottom: 8px; }
.call-chat-msg .who { font-size: 11px; opacity: .7; }
.call-chat-msg.me { text-align: right; }
.call-chat-input {
  display: flex; gap: 8px; padding: 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.call-chat-input input {
  flex: 1; min-width: 0; padding: 10px; border-radius: 20px; border: none; font-size: 15px;
}
.call-chat-input button { border-radius: 50%; width: 42px; height: 42px; padding: 0; }

/* ---------- Yazisma ACIQ olanda zeng ekraninin duzulusu ----------
   Adi ekran:  iki video YUXARIDA beraber olcude, altda yazisma.
   Kicik ekran (ve ya klaviatura acilanda): oz kameram gizlenir,
   yazisma sol terefi tutur, qarsi terefin goruntusu SAG terefde qalir. */
.call-screen.chat-open { display: flex; flex-direction: column; }

.call-screen.chat-open .call-videos {
  position: relative; inset: auto; flex: 0 0 36%;
  display: flex; gap: 2px; min-height: 0;
}
/* min-width:0 VACIBDIR: flex elementinin defolt "min-width:auto" qiymeti
   videonun oz tebii enini minimum sayir - ona gore biri o birini sixisdirib
   beraber olcunu pozurdu. */
.call-screen.chat-open #remoteVideo {
  flex: 1; width: auto; height: 100%; min-width: 0; object-fit: cover;
}
.call-screen.chat-open .local-box {
  /* suruskelemeni legv edirik - bu rejimde iki video beraber sutundur */
  position: relative; inset: auto; flex: 1; width: auto; height: 100%;
  min-width: 0; border-radius: 0; border: none; cursor: default;
}
.call-screen.chat-open .local-resize { display: none; }
.call-screen.chat-open .call-info-overlay { padding: 8px; }
.call-screen.chat-open .call-peer-name { font-size: 16px; }
.call-screen.chat-open .call-controls {
  position: relative; inset: auto; flex-shrink: 0;
  background: rgba(0,0,0,.55); padding: 10px 6px;
}
.call-screen.chat-open .call-btn { width: 44px; height: 44px; font-size: 18px; }
.call-screen.chat-open .call-chat {
  position: relative; inset: auto; flex: 1; min-height: 0;
  max-height: none; border-radius: 0;
}

/* --- Kicik ekran / klaviatura aciq --- */
.call-screen.chat-open.compact {
  display: grid;
  grid-template-columns: 1fr 100px;
  grid-template-rows: 1fr auto;
  grid-template-areas: "chat video" "controls controls";
}
/* min-width:0 olmasa grid sutunu yazisma panelinin ic olcusune gore genislenir
   ve butun ekrandan daşır - duymeler kenarda qalirdi */
.call-screen.chat-open.compact .call-chat { grid-area: chat; min-width: 0; }
.call-screen.chat-open.compact .call-videos {
  grid-area: video; flex: none; height: 100%; display: block;
}
.call-screen.chat-open.compact .local-box { display: none; }  /* oz kameram gizlenir */
.call-screen.chat-open.compact #remoteVideo { width: 100%; height: 100%; }
.call-screen.chat-open.compact .call-controls {
  grid-area: controls; background: rgba(0,0,0,.7); padding: 7px 4px;
  padding-bottom: max(7px, env(safe-area-inset-bottom));
}
.call-screen.chat-open.compact .call-btn { width: 40px; height: 40px; font-size: 17px; }
.call-screen.chat-open.compact .call-info-overlay { display: none; }
.call-screen.chat-open.compact .call-chat-head { padding: 7px 10px; font-size: 13px; }
.call-btn.off { background: #555; opacity: .6; }
.call-btn.hangup { background: #e53935; }
.call-btn.accept { background: var(--green-light); width: auto; padding: 0 20px; border-radius: 30px; font-size: 16px; }
.incoming {
  position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.incoming-box {
  background: #fff; border-radius: 16px; padding: 28px; text-align: center;
  width: min(320px, 90vw); display: flex; flex-direction: column; gap: 10px;
}
.incoming-btns { display: flex; gap: 12px; justify-content: center; margin-top: 10px; }
.incoming-btns .call-btn { width: auto; padding: 12px 18px; border-radius: 30px; font-size: 15px; }
