/* ================================
   One2One Admin Chat - chat.css
   Mobile-safe height (dvh) + visible composer
   ================================ */

.o2o-wrap{
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 14px;
  font-family: inherit;
  color: #0f172a;
}

/* ===== Desktop / Tablet shell ===== */
.o2o-chat-shell{
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;

  height: 72vh;
  max-height: 760px;
  min-height: 520px;
}

/* IMPORTANT for internal scroll */
.o2o-sidebar,
.o2o-main{
  min-height: 0;
}

.o2o-user-mode .o2o-search{ display:none; }

/* ===== Panels ===== */
.o2o-sidebar,
.o2o-main{
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(15,23,42,0.10);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.08);
  overflow: hidden;
}

.o2o-sidebar{
  display:flex;
  flex-direction:column;
}

.o2o-sidebar-head{
  padding: 14px;
  border-bottom: 1px solid rgba(15,23,42,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0.80));
}

.o2o-title{
  font-weight:800;
  font-size:14px;
  margin-bottom:10px;
}

.o2o-search{
  width: 100%;
  border: 1px solid rgba(15,23,42,0.12);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  font: inherit;
  background: rgba(255,255,255,0.85);
}

/* ===== Users ===== */
.o2o-userlist{
  flex: 1 1 auto;
  padding: 10px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.o2o-user{
  width: 100%;
  text-align: right;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.90);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  margin-bottom: 8px;
  transition: transform .08s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;

  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.o2o-user .o2o-user-name{
  flex: 1 1 auto;
  min-width: 0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.o2o-user:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
}

.o2o-user.active{
  border-color: rgba(59,130,246,0.45);
  box-shadow: 0 12px 30px rgba(59,130,246,0.18);
  background: rgba(59,130,246,0.06);
}

/* unread badge */
.o2o-badge{
  display:none;
  align-items:center;
  justify-content:center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  background: rgba(220,38,38,0.92);
  color: #fff;
  line-height: 1;
  flex: 0 0 auto;
}

/* ===== Main ===== */
.o2o-main{
  display:flex;
  flex-direction:column;
  min-height: 0;
}

.o2o-topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:12px 14px;
  border-bottom:1px solid rgba(15,23,42,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0.82));
}

.o2o-peer{
  display:flex;
  align-items:baseline;
  gap:8px;
}

.o2o-peer-label{
  opacity:.7;
  font-size:13px;
}

.o2o-peer-name{
  font-weight:900;
  font-size:14px;
}

.o2o-actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap: wrap;
  justify-content:flex-end;
}

.o2o-status{
  font-size:12px;
  opacity:.75;
  white-space:nowrap;
}

/* buttons */
.o2o-btn{
  border: 1px solid rgba(15,23,42,0.12);
  background: rgba(255,255,255,0.88);
  border-radius: 12px;
  padding: 8px 10px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}

.o2o-btn:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0,0,0,0.08);
}

.o2o-btn-danger{
  border-color: rgba(220,38,38,0.28);
  background: rgba(220,38,38,0.06);
  color: rgba(185,28,28,1);
}

.o2o-btn-danger:hover{
  background: rgba(220,38,38,0.10);
  box-shadow: 0 10px 22px rgba(220,38,38,0.12);
}

/* ===== Messages (scroll area) ===== */
.o2o-messages{
  padding: 14px 18px;
  overflow-y:auto;
  overflow-x:hidden;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(700px 260px at 90% 0%, rgba(59,130,246,0.08), transparent 55%),
    radial-gradient(700px 260px at 10% 100%, rgba(168,85,247,0.08), transparent 55%),
    rgba(255,255,255,0.90);
}

.o2o-msg{
  display:flex;
  width:100%;
  margin-bottom:10px;
}

.o2o-msg.mine{ justify-content:flex-end; }
.o2o-msg.theirs{ justify-content:flex-start; }

.o2o-bubble{
  border:1px solid rgba(15,23,42,0.12);
  border-radius:16px;
  padding:10px 12px;
  background: rgba(255,255,255,0.96);
  box-shadow:0 10px 25px rgba(0,0,0,0.06);
  max-width:78%;
}

.o2o-msg.mine .o2o-bubble{
  border-color: rgba(59,130,246,0.22);
  background: rgba(59,130,246,0.10);
}

.o2o-textline{
  font-size:14px;
  line-height:1.7;
  word-break:break-word;
}

.o2o-img{
  display:block;
  width:100%;
  height:auto;
  border-radius:12px;
  margin-top:8px;
  border:1px solid rgba(15,23,42,0.08);
  max-width: 280px;
}

.o2o-filelink{
  display:inline-block;
  margin-top:8px;
  font-size:13px;
  text-decoration:none;
  border-bottom: 1px dashed rgba(15,23,42,0.35);
  padding-bottom:2px;
}

/* ===== Upload progress ===== */
.o2o-upload{
  display:none;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-top:1px solid rgba(15,23,42,0.08);
  background: rgba(255,255,255,0.95);
}

.o2o-upload.is-on{ display:flex; }

.o2o-upload-track{
  flex:1 1 auto;
  height:8px;
  border-radius:999px;
  background: rgba(15,23,42,0.10);
  overflow:hidden;
  position: relative;
}

.o2o-upload-bar{
  height:100%;
  width:0%;
  border-radius:999px;
  background: linear-gradient(90deg, rgba(59,130,246,0.95), rgba(37,99,235,0.95));
  transition: width .12s linear;
}

.o2o-upload.is-indet .o2o-upload-bar{
  width: 40% !important;
  animation: o2o-indet 1.05s ease-in-out infinite;
}

@keyframes o2o-indet{
  0%   { transform: translateX(-120%); }
  50%  { transform: translateX(80%); }
  100% { transform: translateX(240%); }
}

.o2o-upload-pct{
  font-size:12px;
  font-weight:900;
  min-width:70px;
  text-align:left;
  opacity:.85;
}

/* ===== Composer ===== */
.o2o-compose{
  display:grid;
  grid-template-columns: auto 1fr 120px;
  gap:10px;
  padding:12px;
  border-top:1px solid rgba(15,23,42,0.08);
  background: rgba(255,255,255,0.92);
  align-items:end;
}

.o2o-attach{
  display:flex;
  align-items:center;
  gap:8px;
  min-width: 0;
}

.o2o-file{ display:none; }

.o2o-attach-btn{
  width:44px;
  height:44px;
  display:grid;
  place-items:center;
  border-radius:14px;
  border:1px solid rgba(15,23,42,0.12);
  background: rgba(255,255,255,0.90);
  cursor:pointer;
  user-select:none;
  flex: 0 0 auto;
}

.o2o-filehint{
  display:none;
  font-size:12px;
  opacity:.85;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  line-height:1.4;
  max-width: 160px;
}

.o2o-filehint.is-on{ display:block; }

.o2o-text{
  width:100%;
  resize:none;
  border:1px solid rgba(15,23,42,0.12);
  border-radius:14px;
  padding:10px 12px;
  font:inherit;
  outline:none;
  background: rgba(255,255,255,0.90);
}

.o2o-send{
  border:0;
  border-radius:14px;
  cursor:pointer;
  font:inherit;
  font-weight:900;
  padding:10px 12px;
  background: rgba(59,130,246,0.92);
  color:#fff;
  transition: transform .08s ease, opacity .12s ease;
}

.o2o-send:hover{ transform: translateY(-1px); }
.o2o-send:disabled{ opacity:.55; cursor:not-allowed; transform:none; }

/* ===== Responsive ===== */
@media (max-width: 980px){
  .o2o-chat-shell{
    grid-template-columns:1fr;
    height: 74vh;
    min-height: 560px;
  }
  .o2o-img{ max-width:100%; }
  .o2o-filehint{ max-width: 95px; font-size:11.5px; }
}

/* ===== Mobile FIX: use dvh, keep composer visible, better bubbles ===== */
@media (max-width: 768px){
  .o2o-wrap{
    margin: 0 auto;
    padding: 0;
  }

  /* full-height chat on mobile (dvh fixes address-bar issue) */
  .o2o-chat-shell{
    grid-template-columns:1fr;
    gap: 10px;
    height: 100dvh;
    max-height: none;
    min-height: 100dvh;
  }

  /* make panels full height without rounding issues */
  .o2o-sidebar,
  .o2o-main{
    border-radius: 0;
  }

  /* sidebar list smaller; chat is primary */
  .o2o-userlist{
    max-height: 220px;
  }

  .o2o-topbar{
    padding: 10px 12px;
  }

  .o2o-status{
    max-width: 44vw;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }

  /* messages take the remaining space and scroll */
  .o2o-messages{
    padding: 12px 12px;
  }

  .o2o-bubble{
    max-width: 88%;
    padding: 10px 12px;
  }

  .o2o-textline{
    font-size: 14px;
  }

  /* mobile composer layout: row1 attach+filename, row2 text+send */
  .o2o-compose{
    display:flex !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    align-items: flex-end !important;

    padding: 10px 12px;
  }

  .o2o-attach{
    flex: 1 1 100% !important;
    order: 1 !important;
    min-width: 0;
  }

  .o2o-filehint{
    max-width: calc(100% - 52px) !important;
  }

  /* force text input to not collapse */
  .o2o-text{
    flex: 1 1 auto !important;
    min-width: 0 !important;
    order: 2 !important;

    height: 44px;
    max-height: 110px;
  }

  /* make sure send button is always visible */
  .o2o-send{
    flex: 0 0 92px !important;
    order: 3 !important;

    height: 44px;
    display: inline-flex;
    align-items:center;
    justify-content:center;
  }

  /* safe area for phones with notch */
  .o2o-compose{
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
}

/* fallback if browser doesn't support dvh */
@supports not (height: 100dvh){
  @media (max-width: 768px){
    .o2o-chat-shell{
      height: 100vh;
      min-height: 100vh;
    }
  }
}
