body {
  font-family: sans-serif;
  background: #fff;
  margin: 20px;
}

/* Центровка блока логина */
.login-box {
  max-width: 300px;
  margin: 100px auto;
  padding: 30px;
  border: 1px solid #ccc;
  text-align: center;
  background: #f9f9f9;
  border-radius: 8px;
}
.login-box h2 {
  margin-bottom: 20px;
}
.login-box input[type="password"] {
  padding: 8px;
  width: 100%;
  margin: 8px 0 15px;
  font-size: 16px;
}
.login-box button {
  padding: 8px 16px;
  font-size: 16px;
  cursor: pointer;
}
.error {
  color: red;
  margin-top: 10px;
}

/* ===== ЧАТ ===== */

.chat-header {
  display: flex;
   justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
}
.chat-header h1 {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
}
.chat-username {
  font-style: italic;
  color: #777;
  font-weight: normal;
  font-family: monospace;
}

/* Выбор */
.select-btn,
.tab-btn {
  background: #f0f0f0;
  border: 1px solid #ccc;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  margin-right: 8px;
  transition: background 0.3s;
  font-family: monospace;
}
.select-btn:hover,
.tab-btn:hover {
  background: #e0e0e0;
}
.select-btn.active,
.tab-btn.active {
  background: lime;
  border-color: #999;
  font-family: monospace;
}

/* Чатбокс */
.chat-box {
  max-height: 80vh;
  overflow-y: auto;
  padding: 10px;
  margin: 10px 0;
  background: #f9f9f9;
  border: 1px dashed #ededed;
  transition: max-height 0.3s ease;
}

/* Ввод */
.input-area {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-right: 10px;
}
.input-area input,
.input-area textarea {
  flex: 1;
  padding: 10px;
  font-size: 16px;
  border: 1px solid #ccc;
  width: 100%;
}
.input-area textarea {
  resize: none;
  overflow-y: auto;
  max-height: 150px;
  line-height: 1.4;
}
.input-area .send-btn {
  width: 50px;
  font-size: 22px;
  background: darkgray;
  color: white;
  border: none;
  cursor: pointer;
}
.record-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  margin-left: 5px;
}
.recording {
  color: red;
  font-weight: bold;
}

/* Сообщения */



/* Загрузка */
.upload-label {
  display: inline-block;
  cursor: pointer;
  font-size: 24px;
  padding: 0 8px;
  color: #555;
}
.upload-label:hover {
  color: #000;
}

/* Trash & Edit */
.trash-btn,
.edit-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #888;
}
.trash-btn:hover,
.edit-btn:hover {
  color: red;
}

/* Копия */
#copy_message {
  position: fixed;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  padding: 11px 18px;
  background: #727272;
  border-radius: 4px;
  color: white;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
  z-index: 999;
  pointer-events: none;
}

/* Медиа */
.chat-img {
  max-width: 300px;
  max-height: 200px;
  width: 100%;
  height: auto;
  display: block;
  margin-top: 5px;
  border-radius: 4px;
}
.chat-video {
  max-width: 300px;
  max-height: 240px;
  display: block;
  margin-top: 5px;
  border-radius: 4px;
  box-shadow: 0 0 6px rgba(0,0,0,0.2);
}

/* Drag'n'Drop */
body.drag-over {
  outline: 3px dashed #007bff;
  outline-offset: -10px;
  background-color: #f0f8ff;
}
.drag-hint {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 24px;
  background: rgba(0, 123, 255, 0.9);
  color: white;
  padding: 12px 24px;
  border-radius: 6px;
  z-index: 999;
  display: none;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background-color: rgba(0,0,0,0.6);
  justify-content: center;
  align-items: center;
  z-index: 9999;
}
.modal.show {
  display: flex;
}
.modal-content {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
}
.modal-content h3 {
  margin-top: 0;
}
.modal-content textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px;
  margin-bottom: 10px;
  resize: vertical;
  font-family: monospace;
  font-size: x-large;
}
.modal-buttons {
  margin-top: 15px;
  text-align: right;
}
.modal-content button,
.modal-buttons button {
  margin-right: 10px;
  padding: 6px 12px;
  cursor: pointer;
}
.modal-buttons button {
  background: #4CAF50;
  color: white;
  transition: background 0.3s ease;
  border: none;
  border-radius: 4px;
  font-size: 14px;
}
.modal-buttons button:hover {
  background: #45a049;
}
.modal-buttons button:last-child {
  background: #888;
}
.modal-buttons button:last-child:hover {
  background: #666;
}

/* Tabs & Chat list */
.chat-tabs {
  margin-bottom: 10px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.chat-list {
  border: 1px solid #ccc;
  padding: 10px;
  margin-bottom: 10px;
  max-height: 200px;
  overflow-y: auto;
  background: #fafafa;
}
.chat-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid #ddd;
  align-items: center;
  font-family: monospace;
}
.chat-item button {
  margin-left: 10px;
  padding: 1px 8px;
  cursor: pointer;
  width: 120px;
}
.chat-actions {
  margin-bottom: 10px;
}

.chat-management {
  margin-bottom: 10px;
  border: 1px solid #ccc;
  padding: 10px;
  background: #fdfdfd;
  border-radius: 10px;
}

.chat-tabs,
.chat-actions,
.chat-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.chat-list {
  border: 1px solid #ddd;
  padding: 8px;
  max-height: 200px;
  overflow-y: auto;
  background: #fafafa;
  width: fit-content;
}

.chat-item {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 1px 0;
    border-bottom: 1px solid #eee;
}
span.chat-tema {
    min-width: 300px;
}
input.chat-checkbox {
    margin-right: 15px;
}
.chat-tools {
    display: flex;
    justify-content: flex-end;
    margin-right: 10px;
}

.edit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
 
.delete-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
 
  
 
 .img-modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0,0,0,0.85);
  justify-content: center;
  align-items: center;
  z-index: 9999;
  cursor: zoom-out;
}

.img-modal.show {
  display: flex;
}

#activeChatLabel {
  display: none;
}

#activeChatLabel.show {
  display: flex;
}

.img-modal-content {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 95%;
  max-height: 95%;
}

.img-modal-content img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 6px;
  box-shadow: 0 0 15px rgba(255,255,255,0.6);
}

.img-nav {
  background: rgba(0,0,0,0.5);
  border: none;
  color: white;
  font-size: 32px;
  padding: 10px 15px;
  cursor: pointer;
  z-index: 1;
  transition: background 0.3s;
}

.img-nav:hover {
  background: rgba(0,0,0,0.7);
}

.img-nav.left  {
  margin-right: 10px;
}

.img-nav.right {
  margin-left: 10px;
}

div#chatPanel {
    border: 1px #8b6c6c;
    /* background-color: #f5f5f5; */
    border: 1px solid #ccc;
    padding-bottom: 15px;
    padding-top: 10px;
    border-radius: 10px;
}

.msg-media {
    display: flex;
    align-items: center;
}

.msize {
    font-size: small;
    margin-left: 5px;
}

audio {
    margin-right: 10px;
}

video {
    margin-right: 10px;
}

.msg-file {
    display: flex
;
    max-height: 20px;
}

.msg-image {
  max-width: 200px;
  height: auto;
  cursor: pointer;
  border-radius: 4px;
  transition: transform 0.2s;
}

.msg-image:hover {
  transform: scale(1.03);
}

#imgModal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  justify-content: center;
  align-items: center;
}

#imgModal.show {
  display: flex;
}

#modalImage {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
}

.modal-nav {
  position: absolute;
  top: 50%;
  width: 100%;
  display: flex;
  justify-content: space-between;
  color: white;
  font-size: 3rem;
  cursor: pointer;
  user-select: none;
}

.msg-media img,
.msg-media video {
  max-width: 200px;
  height: auto;
  cursor: pointer;
  border-radius: 4px;
  transition: transform 0.2s;
  display: block;
  margin-bottom: 5px;
}

.msg-media img:hover,
.msg-media video:hover {
  transform: scale(1.03);
}


.msg-preview {
  max-width: 200px;
  height: auto;
  cursor: pointer;
  border-radius: 4px;
  transition: transform 0.2s;
  display: block;
  margin-bottom: 5px;
}

.msg-preview:hover {
  transform: scale(1.03);
}

.msg-preview {
  max-width: 200px;
  height: auto;
  cursor: pointer;
  border-radius: 4px;
  transition: transform 0.2s;
  display: block;
  margin-bottom: 5px;
}

.msg-preview:hover {
  transform: scale(1.03);
}



/*================== МОДАЛКА ==================*/
/* ------------------------------
   Общая оболочка модалки
--------------------------------- */
.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0,0,0,0.6);
  justify-content: center;
  align-items: center;
}

.modal.show {
  display: flex;
}

/* ------------------------------
   Содержимое модалки
--------------------------------- */
.modal-content {
  background: #fff;
  border-radius: 10px;
  padding: 25px 30px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  text-align: center;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

/* ------------------------------
   Заголовок
--------------------------------- */
.modal-title {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 1.5em;
  font-weight: bold;
  text-align: center;
  color: #333;
}

/* ------------------------------
   Тело формы
--------------------------------- */
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 20px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.modal-field label {
  margin-bottom: 6px;
  font-weight: 600;
  color: #444;
}

.modal-field input,
.modal-field select {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.95em;
  transition: border-color 0.2s;
}

.modal-field input:focus,
.modal-field select:focus {
  outline: none;
  border-color: #4CAF50;
}

/* ------------------------------
   Кнопки
--------------------------------- */
.modal-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
}

.modal-buttons button {
  padding: 8px 16px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.95em;
  transition: background-color 0.2s;
}

.btn-save {
  background-color: #4CAF50;
  color: white;
}

.btn-save:hover {
  background-color: #45a049;
}

.btn-cancel {
  background-color: #ccc;
  color: #333;
}

.btn-cancel:hover {
  background-color: #bbb;
}

/* ------------------------------
   Список пользователей
--------------------------------- */
#userSearch {
  width: 100%;
  padding: 7px 10px;
  margin-bottom: 10px;
  border-radius: 5px;
  border: 1px solid #ccc;
  font-size: 0.95em;
}

.user-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #ddd;
  padding: 10px;
  border-radius: 5px;
  background: #fafafa;
}

.user-item {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
}

.user-item label {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95em;
  color: #333;
}

img.img_avatar {
    width: 60px;             /* фиксируем размер */
    height: 60px;            /* делаем равной ширине */
    object-fit: cover;       /* обрезает лишнее, сохраняя центр */
    border-radius: 50%;      /* превращает в круг */
    /*margin-right: 10px;*/
    border: 2px solid #ccc;  /* (опционально) рамка */
}

.chatprop {
    margin-right: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-wrap: wrap;
    align-content: center;
    align-items: center;
    padding: 5px;
    border: 1px solid grey;
    border-top: 0px;
    border-bottom: 0px;
}

div#user {
    border-bottom: 1px dashed gray;
    padding-bottom: 5px;
}

div#typechat {
    padding-top: 5px;
}

header.main-headers {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 10px;
    margin-bottom: 10px;
}

.header-left {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.header-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 15px;
}

.header-search {
    display: flex;
    align-items: center;
    border: 1px solid #ccc;
    padding: 2px 5px;
    border-radius: 4px;
    background: #fff;
}

.header-search input {
    border: none;
    outline: none;
    font-size: 14px;
    padding: 4px;
}

.img_search {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin-left: 5px;
}

img.img_exitr {
    cursor: pointer;
    max-width: 30px;
}

.header-search input {
    border: none;
    outline: none;
    font-size: 14px;
    padding: 4px;
    width: 150px;                  /* исходная ширина */
    transition: width 0.3s ease;   /* плавная анимация */
}

.header-search input:focus {
    width: 225px; /* увеличиваем на 50% */
}

.delete-chat-btn {
    margin-left: 5px;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 18px;
    padding: 2px 5px;
}

.delete-chat-btn:hover {
    color: red;
}

.chat-item {
    font-family: sans-serif;
    font-size: smaller;
}

button.delete-chat-btn {
    width: 40px;
}

    /* Новый стиль для имени под аватаром */
    .avatar-name {
        position: absolute;
        bottom: -10px;
        left: 50%;
        transform: translateX(-50%);
        background: #fff;
        border-radius: 6px;
        padding: 2px 8px;
        font-size: 14px;
        font-weight: bold;
        white-space: nowrap;
        box-shadow: 0 0 4px rgba(0,0,0,0.2);
    }
    .avatar-wrapper {
        position: relative;
        display: inline-block;
        margin-right: 10px;
    }
    /* Кнопки Монолог/Мультилог */
    .chat-type-buttons {
    display: flex;
    /* gap: 8px; */
    /* margin-top: 8px; */
    flex-direction: column;
    align-content: flex-start;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
    margin-right: 10px;
    }
    button.chatlist-btn {
    padding: 5px 10px;
    }
    .chat-type-buttons button {
        /* padding: 6px 12px; */
        border: none;
        border-radius: 4px;
        cursor: pointer;
        font-size: 14px;
        font-weight: bold;
        margin-top: 0px;
    }
    .chat-type-buttons #monologTab { background: #4caf50; color: #fff; }
    .chat-type-buttons #multilogTab { background: #ccc; color: #000; }
    /* Кнопка раскрытия списка */
    .toggle-chatlist-btn {
        margin-top: 8px;
        padding: 5px 10px;
        font-size: 14px;
        border: 1px solid #ddd;
        border-radius: 4px;
        background: #f7f7f7;
        cursor: pointer;
    }
    
.chat-date {
    margin-right: 10px;
    color: lightgray;
}    

.chat-header-text {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: center;
    align-items: center;
}

div#activeSection {
    padding-right: 5px;
    padding-left: 5px;
    font-size: x-large;
    border-right: 2px solid grey;
    border-left: 2px solid grey;
    border-radius: 5px;
    margin-right: 7px;
}

chat-header h1 {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 0;
    padding-left: 5px;
}

/* ===== МЕДИАЗАПРОС ДЛЯ МОБИЛОК ===== */
@media screen and (max-width: 600px) {
  .chat-box {
    max-height: 65vh;
    padding: 5px;
  }
  .input-area {
    flex-direction: column;
  }
  .input-area input,
  .input-area textarea {
    width: 100%;
    font-size: 14px;
  }
  .input-area .send-btn {
    width: 100%;
    font-size: 18px;
    padding: 10px 0;
  }
  .chat-img {
    max-width: 100%;
    max-height: 200px;
  }
  .msg-text {
    font-size: 15px;
  }
  .upload-label {
    font-size: 20px;
  }
  .msg-block {
    padding: 8px;
  }
}


/*Новое оформление сообщений */
.msg-block {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  margin: 3px 0;
  padding: 7px;
  gap: 10px;
}

/* Колонка с чекбоксом */
.msg-checkbox-col {
  width: 40px;
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.msg-checkbox-wrap {
  border: 1px dashed lightgray;
  border-radius: 6px;
  padding: 2px;
}

/* Колонка с автором, датой и временем */
.msg-info-col {
  width: 120px;
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: #555;
}

.msg-author {
  font-weight: bold;
  margin-bottom: 2px;
}

.msg-datetime {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #888;
  font-family: system-ui;
}

/* Колонка с сообщением — занимает всё оставшееся место */
.msg-content-col {
  flex: 1;  /* <== магия */
  border: 1px dashed #ddd;
  border-radius: 6px;
  background: white;
  padding: 6px;
}

.msg-text {
  font-size: 15px;
  white-space: pre-wrap;
  color: #000;
  padding: 5px;
}

