@font-face{
  font-family:'IRANSansX';
  src:url('../fonts/IRANSansX.woff2') format('woff2'),
      url('../fonts/IRANSansX.woff') format('woff');
  font-weight:400;
  font-style:normal;
  font-display:swap;
}

*{box-sizing:border-box;font-family:IRANSansX,Tahoma,Arial}

body,html{margin:0;height:100%;background:#0f0f10;color:#111}
.page{height:100%}
.hidden{display:none!important}

.card{max-width:360px;margin:6vh auto;background:#fff;border-radius:14px;padding:18px 16px;box-shadow:0 10px 25px rgba(0,0,0,.2)}
.card h2{margin:0 0 12px}
.card input{width:100%;padding:12px;border:1px solid #ddd;border-radius:10px;margin:7px 0;outline:none}
.card button{width:100%;padding:12px;border:0;border-radius:10px;background:#2b5278;color:#fff;cursor:pointer}
.small{font-size:12px;color:#444;margin-top:8px;white-space:pre-wrap}

.layout{display:flex;height:100vh}
.sidebar{width:360px;background:#fff;border-left:1px solid #e6e6e6;display:flex;flex-direction:column}
.topbar{padding:12px 12px;background:#2b5278;color:#fff;display:flex;align-items:center;justify-content:space-between}
.title{font-weight:700}
.subtitle{font-size:12px;opacity:.85;margin-top:2px}
.actions{display:flex;gap:8px}
.iconbtn{border:0;background:rgba(255,255,255,.2);color:#fff;border-radius:10px;padding:8px 10px;cursor:pointer}
.iconbtn:hover{filter:brightness(1.05)}
.search{padding:10px}
.search input{width:100%;padding:10px;border:1px solid #ddd;border-radius:12px}

.chatlist{flex:1;overflow:auto;padding:6px}
.chatitem{padding:10px;border-radius:12px;cursor:pointer;display:flex;justify-content:space-between;align-items:center}
.chatitem:hover{background:#f3f5f7}
.chatitem.active{background:#e9f0f8}
.chatmeta{display:flex;flex-direction:column}
.chatname{font-weight:700}
.chatsub{font-size:12px;color:#666;margin-top:2px}

.chatpanel{flex:1;display:flex;flex-direction:column;background:#101113}
.chathead{height:58px;background:#fff;border-bottom:1px solid #e6e6e6;display:flex;align-items:center;padding:0 10px;gap:10px}
.chathead .iconbtn{background:#f0f2f4;color:#222}
.chatheadinfo{display:flex;flex-direction:column}
.chattitle{font-weight:700}
.chatstatus{font-size:12px;color:#666;margin-top:2px}

.messages{
  flex:1; overflow:auto; padding:14px;
  display:flex; flex-direction:column; gap:10px;
  background:#e6ebee;
  background-image: url('../img/pattern2.svg');
  background-repeat: repeat;
  background-size: 420px;
}

.bubble{max-width:76%;padding:10px 12px;border-radius:14px;position:relative;line-height:1.6}
.me{align-self:flex-start;background:#efffde;color:#111;border-bottom-right-radius:6px}
.you{align-self:flex-end;background:#fff;color:#111;border-bottom-left-radius:6px}
.meta{font-size:10px;opacity:.65;margin-top:6px;text-align:left}

/* Reply / Forward blocks */
.replyBox{border-right:3px solid rgba(0,0,0,.18);padding:6px 8px;margin-bottom:8px;background:rgba(0,0,0,.04);border-radius:10px}
.replyWho{font-size:12px;opacity:.8;margin-bottom:2px}
.replyPrev{font-size:12px;opacity:.9;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.fwdBox{font-size:12px;opacity:.75;margin-bottom:6px}

.composer{height:62px;background:#fff;border-top:1px solid #e6e6e6;display:flex;align-items:center;gap:8px;padding:8px 10px;position:relative}
.composebar{position:absolute;left:0;right:0;top:-44px;height:40px;background:#f7f7f7;border-top:1px solid #eee;border-bottom:1px solid #eee;display:flex;align-items:center;justify-content:space-between;padding:0 10px;gap:10px}
.composebar.hidden{display:none}
.composemeta{font-size:12px;color:#555;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:calc(100% - 40px)}
.composer .iconbtn{background:#f0f2f4;color:#222}
.composer input{flex:1;padding:12px;border:1px solid #ddd;border-radius:999px;outline:none}
.sendbtn{border:0;background:#2b5278;color:#fff;border-radius:999px;padding:12px 16px;cursor:pointer}

.modal{position:fixed;inset:0;background:rgba(0,0,0,.6);display:flex;align-items:center;justify-content:center}
.modalcard{width:min(520px,92vw);background:#fff;border-radius:14px;padding:12px}
.modalhead{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px}
.modalcard input{width:100%;padding:12px;border:1px solid #ddd;border-radius:12px;outline:none}
.results{max-height:50vh;overflow:auto;margin-top:10px}
.userrow{padding:10px;border-radius:12px;cursor:pointer}
.userrow:hover{background:#f3f5f7}

@media (max-width: 900px){
  .sidebar{width:100%}
  .chatpanel{display:none}
  .chatpanel.show{display:flex;position:fixed;inset:0;z-index:5}
}
.hint{
  font-size:12px;
  color:#666;
  margin-top:6px;
  line-height:1.7;
}

.modalcard{
  box-shadow:0 18px 60px rgba(0,0,0,.35);
  transform: translateY(6px);
  opacity: .98;
  animation: pop .12s ease-out forwards;
}
@keyframes pop{
  to{ transform: translateY(0); opacity:1; }
}

.modalhead{
  position: sticky;
  top: 0;
  background: #fff;
  padding-bottom: 8px;
  z-index: 2;
}

.modalcard input{
  background:#f4f5f7;
  border:1px solid #e7e7e7;
}

.userrow{
  display:flex;
  align-items:center;
  gap:10px;
}

.userrow::before{
  content:"";
  width:34px;height:34px;
  border-radius:50%;
  background:#dfe7f3;
  display:inline-block;
}

.context-menu{
  position: fixed;
  z-index: 9999;
  min-width: 190px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 14px;
  box-shadow: 0 18px 55px rgba(0,0,0,.18);
  padding: 6px;
}

.context-menu button{
  width: 100%;
  text-align: right;
  background: transparent;
  border: 0;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.context-menu button:hover{
  background: rgba(0,0,0,.05);
}
.context-menu .danger{ color: #d11; }

.deleted{
  opacity: .82;
  font-style: italic;
}

.deletedText{
  color: rgba(0,0,0,.55);
}

.toast{
  position: fixed;
  left: 50%;
  top: 22px;
  transform: translateX(-50%) translateY(-10px);
  opacity: 0;
  z-index: 99999;
  background: rgba(0,0,0,.75);
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  transition: opacity .15s ease, transform .15s ease;
  pointer-events: none;
}
.toast.show{
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* unread badge */
.badge{
  display:inline-block;
  min-width:18px;
  padding:0 6px;
  border-radius:999px;
  font-size:12px;
  line-height:18px;
  text-align:center;
  background:#ff3b30;
  color:#fff;
  vertical-align:middle;
}

.field{display:flex;flex-direction:column;gap:6px;margin:8px 0}
.field label{font-size:12px;color:#555}
.field input{height:38px;border:1px solid #e6e6e6;border-radius:10px;padding:0 10px;outline:none}
.btn{height:38px;border:0;border-radius:12px;padding:0 14px;background:#1f6feb;color:#fff;cursor:pointer}
.btn:disabled{opacity:.6;cursor:not-allowed}
.muted{color:#777;font-size:12px}
.userrow{padding:10px 12px;border:1px solid #eee;border-radius:12px;margin:6px 0;cursor:pointer}
.userrow:hover{background:#fafafa}
/* ===== ModalBox (Contacts/Profile) ===== */
.modalbox{
  width:min(520px,92vw);
  max-height:84vh;
  background:#fff;
  border-radius:16px;
  overflow:hidden;
  box-shadow:0 18px 60px rgba(0,0,0,.35);
  display:flex;
  flex-direction:column;
}

.modaltop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 12px;
  border-bottom:1px solid #eee;
  background:#fff;
  position:sticky;
  top:0;
  z-index:2;
}

.modalbody{
  padding:12px;
  overflow:auto;
}
.pinnedbar{
  padding:10px 12px;
  background:#fff7cc;
  border-bottom:1px solid rgba(0,0,0,.08);
  font-family:tahoma;
}
.pinnedbar.hidden{ display:none; }

