/* ============================================================
   ZAP — оформление страницы (внешний вид)
   Цвета: приятные синие и белые тона.
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #2f6bed;          /* основной синий */
  --blue-light: #5b8df5;    /* светло-синий */
  --blue-soft: #eaf1ff;     /* очень светлый синий (фон выделения) */
  --blue-dark: #1f4fc4;
  --bg-top: #eaf2ff;        /* фон страницы, верх */
  --bg-bottom: #f7fafe;     /* фон страницы, низ */
  --panel: #ffffff;
  --line: #e2e9f5;
  --text: #1b2431;
  --muted: #7c8aa0;
}

body {
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-top) 0%, var(--bg-bottom) 55%);
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  font-size: 15px;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  background: linear-gradient(180deg, var(--blue-light), var(--blue));
  color: #fff;
  cursor: pointer;
  transition: filter 0.15s, box-shadow 0.15s, background 0.15s;
  box-shadow: 0 4px 12px rgba(47, 107, 237, 0.28);
}

button:hover { filter: brightness(1.07); }
button:active { filter: brightness(0.95); }

/* ---------- ЭКРАН ВХОДА ---------- */
.screen { height: 100vh; }

#screen-login {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--panel);
  padding: 44px 40px 34px;
  border-radius: 22px;
  width: 360px;
  box-shadow: 0 22px 60px rgba(31, 79, 196, 0.16);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.9);
}

.logo {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--blue-light), var(--blue-dark));
  color: #fff;
  font-size: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 26px rgba(47, 107, 237, 0.38);
}

.login-box h1 {
  font-size: 30px;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--blue-dark), var(--blue-light));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 10px;
}

.hint { color: var(--muted); margin-bottom: 24px; font-size: 14px; line-height: 1.45; }

.login-box input {
  width: 100%;
  padding: 13px 15px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  margin-bottom: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fbfdff;
}

.login-box input:focus {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 4px var(--blue-soft);
}

.login-box button { width: 100%; }

.error { color: #d3455b; font-size: 13px; margin-top: 10px; min-height: 16px; }

/* ---------- ОСНОВНОЙ ЭКРАН ---------- */
#screen-chat { display: flex; gap: 0; }

.sidebar {
  width: 300px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  background: linear-gradient(160deg, var(--blue-dark), var(--blue));
  color: #fff;
}

.sidebar-top .caption { color: rgba(255, 255, 255, 0.75); }

.caption { font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); }
.caption-list { padding: 16px 18px 8px; }

.my-name { font-weight: 600; font-size: 16px; color: #fff; }

.link-button {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 10px;
  box-shadow: none;
}

.people-list { list-style: none; overflow-y: auto; flex: 1; padding: 4px 10px 12px; }

.people-list li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  transition: background 0.15s;
}

.people-list li:hover { background: var(--blue-soft); }
.people-list li.active { background: var(--blue-soft); color: var(--blue-dark); font-weight: 600; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--blue-light), var(--blue));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.empty-hint { padding: 18px; color: var(--muted); font-size: 14px; line-height: 1.45; }

/* ---------- ОБЛАСТЬ ПЕРЕПИСКИ ---------- */
.dialog { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 15px;
}

.dialog-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-weight: 600;
  font-size: 16px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- СООБЩЕНИЯ ---------- */
.bubble {
  position: relative;
  max-width: 62%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.bubble .time {
  display: block;
  font-size: 11px;
  margin-top: 6px;
  opacity: 0.7;
}

.bubble.own {
  align-self: flex-end;
  background: linear-gradient(180deg, var(--blue-light), var(--blue));
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 12px rgba(47, 107, 237, 0.22);
}

.bubble.other {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 8px rgba(27, 36, 49, 0.05);
}

/* Кнопки «изменить» и «удалить» — появляются при наведении на своё сообщение */
.bubble-actions {
  position: absolute;
  top: -10px;
  right: 6px;
  display: none;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  box-shadow: 0 4px 12px rgba(27, 36, 49, 0.14);
}

.bubble.own:hover .bubble-actions { display: flex; }

.bubble-actions button {
  background: none;
  box-shadow: none;
  padding: 3px 6px;
  font-size: 13px;
  border-radius: 7px;
  line-height: 1;
}

.bubble-actions button:hover { background: var(--blue-soft); filter: none; }

/* Режим изменения сообщения */
.bubble.editing { background: var(--panel); border: 1.5px solid var(--blue-light); color: var(--text); }

.edit-text {
  width: 100%;
  min-width: 220px;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
  outline: none;
}

.edit-actions { display: flex; gap: 8px; margin-top: 8px; }
.edit-actions button { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.edit-actions .cancel { background: #eef1f7; color: var(--muted); box-shadow: none; }

/* ---------- ВЛОЖЕНИЯ (фото и файлы) ---------- */
.attachment-image {
  display: block;
  max-width: 100%;
  max-height: 260px;
  border-radius: 10px;
  margin-bottom: 6px;
  cursor: zoom-in;
}

.attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.22);
  color: inherit;
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 4px;
  word-break: break-all;
}

.bubble.other .attachment-file { background: var(--blue-soft); color: var(--blue-dark); }
.attachment-file:hover { filter: brightness(0.97); }

/* ---------- ПОЛЕ ОТПРАВКИ ---------- */
.send-area {
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.attach-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 24px 0;
  padding: 9px 14px;
  background: var(--blue-soft);
  border-radius: 12px;
  font-size: 14px;
  color: var(--blue-dark);
}

.attach-preview img { max-height: 46px; border-radius: 8px; vertical-align: middle; margin-right: 8px; }

#attach-remove {
  background: none;
  box-shadow: none;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 14px;
  border-radius: 8px;
}

.send-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
}

.attach-button {
  background: var(--blue-soft);
  color: var(--blue-dark);
  box-shadow: none;
  padding: 12px 14px;
  font-size: 17px;
  line-height: 1;
  flex-shrink: 0;
}

.attach-button:hover { background: #dbe7ff; filter: none; }

.send-form input[type="text"] {
  flex: 1;
  padding: 12px 15px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fbfdff;
}

.send-form input[type="text"]:focus {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 4px var(--blue-soft);
}

/* ---------- ПРОКРУТКА ---------- */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-thumb { background: #cfdcf2; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #b6c9e8; }
