/* Профсоюз шиномонтажников — стили только для chat.html */
/* Используем CSS-переменные темы из app.css / black.css / white.css */

.chat-box{
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--panel);
  height: 720px;
  overflow: hidden;
}

/* ===== DM tabs (IRC /query style) ===== */
.chat-tabs{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  margin-bottom:10px;
}

.chat-tab{
  height:28px;
  padding:0 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background: var(--tile);
  color: var(--ink);
  cursor:pointer;
  font-size:13px;
  user-select:none;
  display:inline-flex;
  align-items:center;
  gap:8px;
}

.chat-tab.unread{
  border-color: var(--accent);
}

.chat-tab:hover{
  background: var(--panel);
}

.chat-tab.active{
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(100,150,255,.18);
}

.chat-tab-badge{
  min-width:18px;
  height:18px;
  padding:0 6px;
  border-radius:999px;
  border:1px solid var(--line);
  background: var(--panel);
  font-size:12px;
  line-height:18px;
  opacity:.9;
}

.chat-tab-close{
  display:inline-flex;
  width:18px;
  height:18px;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  border:1px solid transparent;
  opacity:.65;
  font-size:16px;
  line-height:16px;
}

.chat-tab:hover .chat-tab-close{
  opacity:.9;
}

.chat-tab-close:hover{
  border-color: var(--line);
  background: var(--panel);
}

/* окно сообщений */
.chat-log{
  height: auto;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 10px;
  background: var(--tile);
  color: var(--ink);
}

/* сообщение */
.chat-msg{
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.35;
  /* защита от «простыней» без пробелов */
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}

/* строка ввода */
.chat-input{
  display:flex;
  gap:8px;
  align-items: center;
}

/* поле ввода */
.chat-text{
  flex:1;
  height:34px;
  padding:0 10px;

  color: var(--ink);
  background: var(--tile);

  border: 1px solid var(--line);
  border-radius: 6px;

  outline:none;
}

.chat-text::placeholder{
  opacity:.55;
}

.chat-text:focus{
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(100,150,255,.25);
}

/* кнопка отправки */
.chat-send{
  height:34px;
  padding:0 14px;

  border-radius:6px;
  border:1px solid var(--line);

  background: var(--tile);
  color: var(--ink);

  cursor:pointer;
  user-select:none;
}

.chat-send:disabled{
  opacity:.45;
  cursor:default;
}

.chat-send:hover{
  background: var(--panel);
}

.chat-send:active{
  transform: translateY(1px);
}

/* recipients chips inside input area */
.chat-inputwrap{
  display:flex;
  align-items:center;
  gap:6px;
  padding:4px 6px;
  border:1px solid var(--line);
  border-radius:6px;
  background:var(--tile);
}

.chat-chips{
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
}

.chat-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:2px 8px;
  border:1px solid var(--line);
  border-radius:999px;
  background:var(--panel);
  color:var(--ink);
  font-size:12px;
  line-height:18px;
  white-space:nowrap;
}

.chat-chip-x{
  height:18px;
  min-width:18px;
  padding:0 4px;
  border:1px solid var(--line);
  border-radius:999px;
  background:transparent;
  color:var(--ink);
  cursor:pointer;
}

.chat-chip-x:hover{
  filter:brightness(1.1);
}

.chat-input-inner{
  flex:1 1 auto;
  min-width:160px;
  border:0 !important;
  outline:none;
  background:transparent !important;
  color:var(--ink) !important;
}



/* local alias (visible only on this PC) */
.chat-alias{
  color: var(--ink);
  font-weight:400;
  opacity:0.75;
  margin-left:6px;
  font-size:12px;
}

/* ===== Онлайн (выдвижная панель) ===== */
.has-online-drawer{
  position: relative;
}



.my-account{
  display:flex;
  align-items:center;
  gap:10px;
}

.my-account-info{
  display:flex;
  flex-direction:column;
  line-height:1.25;
  text-align:right;
}

.my-avatar{
  width:34px;
  height:34px;
  border-radius:50%;
  overflow:hidden;
  padding:0;
  border:none;
  background:transparent;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 34px;
}

.my-avatar img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

.my-avatar-fallback{
  width:100%;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:50%;
  border:1px solid var(--line);
  background:var(--tile);
  color:var(--ink);
  font-size:16px;
  line-height:1;
}

.online-toggle{
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--tile);
  color: var(--ink);
  padding: 0 10px;
  cursor: pointer;
  font-size: 13px;
}

.online-toggle.active{
  box-shadow: inset 0 0 0 1px var(--line);
}

.online-panel{
  position: absolute;
  top: 8px;
  right: 8px;
  bottom: 8px;
  width: 240px;
  max-width: 70%;
  background: var(--tile);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 10px 24px rgba(0,0,0,.12);
  overflow: hidden;
  transform: translateX(110%);
  transition: transform .18s ease;
  pointer-events: none;
}

.has-online-drawer.online-open .online-panel{
  transform: translateX(0);
  pointer-events: auto;
}

.has-online-drawer.online-open .chat-log{
  /* чтобы чат не прятался под панель */
  margin-right: 250px;
}

.online-head{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.online-title{
  font-weight: 700;
}

.online-count{
  margin-left: auto;
  opacity: .8;
  font-size: 12px;
}

.online-close{
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  line-height: 1;
  font-size: 18px;
}

.online-list{
  height: calc(100% - 36px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.online-row{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
}

.online-row:hover{
  border-color: var(--line);
  background: var(--panel);
}

.online-dot{
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 10px;
}

.online-label{
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.online-alias{
  font-weight: 600;
  margin-right: 6px;
}

.online-id{
  opacity: .75;
  font-size: 12px;
}

.online-marks{
  display: inline-flex;
  gap: 6px;
  opacity: .9;
  font-size: 12px;
}




/* --- Patch 19: Autoscroll toggle --- */
.chat-tools{
  display:flex;
  align-items:center;
  gap:12px;
  margin: 6px 0 8px 0;
}
.chat-autoscroll{
  display:flex;
  align-items:center;
  gap:8px;
  font-size: 12px;
  opacity: .9;
  user-select:none;
}
.chat-autoscroll input{
  width: 16px;
  height: 16px;
}

/* --- Patch 21: online panel filters + city grouping --- */
.online-filters{
  display:flex;
  gap:10px;
  padding: 10px 12px 0;
  align-items:center;
}
.online-filter-sel{
  flex: 1;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
}
.online-group-city{
  display:flex;
  gap:6px;
  align-items:center;
  font-size: 12px;
  opacity: 0.9;
  user-select:none;
}
.online-group-city input{
  width: 14px;
  height: 14px;
}
.online-group{
  margin-top: 10px;
  padding: 6px 10px;
  font-size: 12px;
  opacity: 0.8;
  border-top: 1px solid var(--line);
}
.online-city{
  opacity: 0.75;
  font-size: 12px;
}

/* Patch 22 already applied */


/* ===== Grid layout for chat + compose + online sidebar ===== */
.chat-box{
  min-height: 0;
}

.chat-main.chat-grid{
  display:grid;
  grid-template-columns:minmax(0,1fr) 44px;
  grid-template-rows:auto minmax(0,1fr) auto;
  gap:12px;
  align-items:stretch;
  overflow:hidden;
  height:100%;
  min-height:0;
}

.chat-box.online-open .chat-main.chat-grid{
  grid-template-columns:minmax(0,1fr) 258px;
}

.chat-top{
  grid-column:1 / span 2;
  grid-row:1;
  min-width:0;
  display:flex;
  flex-direction:column;
}

.chat-compose{
  grid-column:1;
  grid-row:3;
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:6px;
}

.chat-compose-row{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
}

.chat-compose .chat-inputwrap{
  flex:1 1 auto;
  min-width:0;
}

.chat-compose .chat-send{
  flex:0 0 auto;
}

.chat-toolbar{
  position:relative;
  display:flex;
  align-items:flex-start;
  gap:10px;
  margin-bottom:0;
  min-height:52px;
}

.chat-top .chat-tabs{
  margin-bottom:10px;
}

.chat-toolbar-right{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:12px;
  padding-right:2px;
}

.chat-toolbar-status{
  display:flex;
  flex-direction:column;
  align-items:flex-end;
}

.online-toggle{
  display:none !important;
}

.online-shell{
  grid-column:2;
  grid-row:2 / span 2;
  min-width:0;
  position:relative;
  display:flex;
  align-items:stretch;
}

.online-rail{
  width:44px;
  border:1px solid var(--line);
  border-radius:14px;
  background:var(--tile);
  display:flex;
  flex-direction:column;
  align-items:center;
  padding:10px 6px;
  gap:14px;
  user-select:none;
}

.online-rail-top{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:4px;
}

.online-rail-count{
  font-size:12px;
  opacity:.9;
  min-width:10px;
  text-align:center;
}

.online-rail-toggle{
  width:22px;
  height:22px;
  border-radius:8px;
  border:1px solid var(--line);
  background:var(--panel);
  color:var(--ink);
  cursor:pointer;
  line-height:1;
  font-size:16px;
  padding:0;
}

.online-rail-sep{
  width:100%;
  height:1px;
  background:var(--line);
  opacity:.7;
}

.online-rail-dots{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:18px;
  padding-top:2px;
}

.online-rail-userdot{
  width:11px;
  height:11px;
  border-radius:50%;
  background:var(--accent);
  box-shadow:0 0 0 1px rgba(0,0,0,.08);
}

.chat-box.online-open .chat-main.chat-grid .online-rail{
  display:none;
}

.online-panel{
  position:static;
  inset:auto;
  width:100%;
  max-width:none;
  height:100%;
  background:var(--tile);
  border:1px solid var(--line);
  border-radius:14px;
  padding:10px;
  box-shadow:none;
  overflow:hidden;
  transform:none;
  transition:none;
  pointer-events:auto;
  display:none;
}

.chat-box.online-open .chat-main.chat-grid .online-panel{
  display:block;
}

.has-online-drawer.online-open .chat-log{
  margin-right:0;
}

.chat-main.chat-grid > .chat-log{
  grid-column:1;
  grid-row:2;
  min-width:0;
  min-height:0;
  margin-bottom:0;
}

.chat-main.chat-grid .chat-top .chat-tabs{
  margin-bottom:10px;
}

.chat-main.chat-grid .chat-top .online-head{
  margin-bottom:10px;
}

.chat-main.chat-grid .online-list{
  height:calc(100% - 84px);
}

@media (max-width: 1080px){
  .chat-box.online-open .chat-main.chat-grid{
    grid-template-columns:minmax(0,1fr) 232px;
  }
}


/* Patch 13: stretch chat internals to block edges (Telegram-like) */
.chat-box{
  display:flex;
  align-items:stretch;
}

.chat-box > .chat-main{
  flex:1 1 auto;
  min-width:0;
}

.chat-main.chat-grid{
  flex:1 1 auto;
  min-height:0;
  height:100%;
}

.chat-main.chat-grid > .chat-log,
.chat-log{
  height:auto;
}

.chat-main.chat-grid > .chat-log{
  min-height:0;
}

.chat-compose{
  align-self:end;
}

/* Patch 23: restore and scope user info modal */
.chat-id-modal{
  width:min(420px, calc(100vw - 24px));
  max-width:92vw;
  border:1px solid var(--line);
  border-radius:18px;
  background:var(--panel);
  color:var(--ink);
  box-shadow:0 10px 30px rgba(0,0,0,.35);
  padding:16px;
}
.chat-id-modal-head{
  display:grid;
  grid-template-columns:minmax(0,1fr) 64px 40px;
  gap:10px;
  align-items:center;
  margin-bottom:14px;
}
.chat-id-modal-head-text{min-width:0;}
.chat-id-modal-company{
  font-size:18px;
  font-weight:800;
  line-height:1.15;
  margin-bottom:4px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.chat-id-modal-title{
  font-size:13px;
  color:var(--muted);
}
.chat-id-modal-avatar,
.chat-id-modal-close,
.chat-id-modal-reset,
.chat-id-modal-action{
  border:1px solid var(--line);
  background:var(--tile);
  color:var(--ink);
}
.chat-id-modal-avatar{
  width:64px;
  height:64px;
  border-radius:50%;
  overflow:hidden;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0;
}
.chat-id-modal-avatar-img{width:100%;height:100%;object-fit:cover;display:block;}
.chat-id-modal-avatar-fallback{font-size:24px;line-height:1;opacity:.7;}
.chat-id-modal-close{
  width:40px;
  height:40px;
  border-radius:14px;
  cursor:pointer;
  font-size:22px;
  line-height:1;
}
.chat-id-modal-label{
  font-size:12px;
  color:var(--muted);
  margin-bottom:6px;
}
.chat-id-modal-alias-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:10px;
  align-items:center;
  margin-bottom:14px;
}
.chat-id-modal-input{
  min-width:0;
  height:38px;
  border-radius:10px;
  border:1px solid var(--line);
  background:var(--tile);
  color:var(--ink);
  padding:0 12px;
}
.chat-id-modal-reset{
  height:38px;
  border-radius:10px;
  padding:0 14px;
  cursor:pointer;
}
.chat-id-modal-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}
.chat-id-modal-action{
  min-height:46px;
  border-radius:13px;
  padding:0 14px;
  display:flex;
  align-items:center;
  gap:10px;
  cursor:pointer;
  font-weight:600;
  justify-content:flex-start;
}
.chat-id-modal-action.is-full{grid-column:1 / -1;}
.chat-id-modal-action:disabled{opacity:.5;cursor:default;}
.chat-id-modal-action-icon{
  width:18px;
  height:18px;
  flex:0 0 18px;
  display:block;
}

/* Patch 24: profile modal polish, scoped so user info modal stays intact */
#profileModalBack .profile-modal{
  width:min(420px, calc(100vw - 24px));
  max-width:420px;
  padding:18px 18px 16px;
  border-radius:22px  !important;
  overflow:hidden;
  background:var(--panel);
  color:var(--ink);
  border:1px solid var(--line);
  box-shadow:0 14px 36px rgba(0,0,0,.38);
}



#profileModalBack .profile-modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:14px;
}
#profileModalBack .profile-modal-title{
  margin:0;
  font-size:18px;
  font-weight:800;
  color:var(--ink);
}
#profileModalBack .profile-close-btn{
  width:40px;
  height:40px;
  padding:0;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:14px;
  border:1px solid var(--line);
  background:var(--tile);
  color:var(--ink);
  font-size:22px;
  line-height:1;
}
#profileModalBack .profile-form{
  display:flex;
  flex-direction:column;
  gap:14px;
}
#profileModalBack .profile-field{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin:0;
}
#profileModalBack .profile-label,
#profileModalBack .profile-logo-head{
  font-size:13px;
  font-weight:600;
  color:var(--muted);
}
#profileModalBack .profile-logo-head span{
  opacity:.9;
}
#profileModalBack .profile-logo-card{
  display:grid;
  grid-template-columns:118px minmax(0,1fr);
  gap:36px;
  align-items:center;
}
#profileModalBack .profile-logo-stage{
  position:relative;
  width:118px;
  min-width:118px;
  height:118px;
}
#profileModalBack .profile-logo-preview{
  width:118px;
  height:118px;
  border-radius:50%;
  border:1px solid var(--line);
  background:var(--tile);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}
#profileModalBack .profile-logo-preview img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}
#profileModalBack .profile-logo-actions{
  position:absolute;
  left:58px;
  bottom:8px;
  display:flex;
  flex-direction:row;
  gap:8px;
}
#profileModalBack .icon-btn{
  width:38px;
  height:38px;
  padding:0;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  border:1px solid var(--line);
  background:var(--tile);
}
#profileModalBack .icon-btn img{
  width:17px;
  height:17px;
  display:block;
}
#profileModalBack .profile-logo-note{
  font-size:12px;
  line-height:1.45;
  color:var(--muted);
}
#profileModalBack .profile-input{
  width:100%;
  height:40px;
  border-radius:12px;
  border:1px solid var(--line);
  background:var(--tile);
  color:var(--ink);
  padding:0 12px;
}
#profileModalBack .profile-actions{
  display:flex;
  justify-content:flex-end;
  margin-top:14px;
}
#profileModalBack #profileSave{
  min-width:100px;
}

