/* Переписка фотографа с родителем (public/chat.js) */

.chat-badge{
  display:inline-flex; align-items:center; justify-content:center; min-width:19px; height:19px;
  padding:0 6px; margin-left:6px; border-radius:10px; background:var(--danger); color:#fff;
  font-size:11.5px; font-weight:700; line-height:1; vertical-align:middle;
}
.chat-badge[hidden]{ display:none; }

/* ---- лента и поле ввода ---- */
.chat-box{ display:flex; flex-direction:column; min-height:0; border:1px solid var(--line); border-radius:12px; background:#fbf9f5; position:relative; }
.chat-box.drag{ outline:2px dashed var(--accent); outline-offset:-4px; }
.chat-msgs{ flex:1; min-height:120px; max-height:460px; overflow-y:auto; padding:12px 12px 6px; display:flex; flex-direction:column; gap:4px; }
.chat-empty{ color:var(--ink-soft); font-size:14px; text-align:center; padding:28px 16px; margin:auto 0; }
.chat-day{ align-self:center; font-size:12px; color:var(--ink-soft); background:#efe9df; padding:2px 10px; border-radius:10px; margin:8px 0 4px; }
.chat-msg{ display:flex; }
.chat-msg.mine{ justify-content:flex-end; }
.chat-bubble{ max-width:78%; padding:7px 11px 5px; border-radius:14px; background:#fff; border:1px solid var(--line); box-shadow:0 1px 1px rgba(0,0,0,.03); }
.chat-msg.mine .chat-bubble{ background:var(--accent-soft); border-color:#e8cdb4; border-bottom-right-radius:4px; }
.chat-msg.theirs .chat-bubble{ border-bottom-left-radius:4px; }
.chat-msg.imported .chat-bubble{ border-style:dashed; }
.chat-src{ font-size:11.5px; color:var(--accent-ink); margin-bottom:3px; }
.chat-text{ white-space:pre-wrap; word-wrap:break-word; overflow-wrap:anywhere; font-size:14.5px; line-height:1.4; }
.chat-text a{ color:var(--accent-ink); }
.chat-imgs{ display:grid; gap:4px; margin:2px 0 4px; }
.chat-imgs.n1{ grid-template-columns:1fr; }
.chat-imgs.n2{ grid-template-columns:1fr 1fr; }
.chat-imgs.n3{ grid-template-columns:1fr 1fr 1fr; }
.chat-imgs a{ display:block; }
.chat-imgs img{ display:block; width:100%; max-height:260px; object-fit:cover; border-radius:9px; background:#eee; }
.chat-imgs.n1 img{ width:auto; max-width:100%; }
.chat-imgs.n2 img, .chat-imgs.n3 img{ aspect-ratio:1; height:auto; }
.chat-meta{ font-size:11px; color:var(--ink-soft); text-align:right; margin-top:2px; }
.chat-read.yes{ color:var(--ok); }
.chat-del{ border:none; background:none; color:var(--ink-soft); font-size:11px; cursor:pointer; padding:0 0 0 6px; text-decoration:underline; opacity:0; }
.chat-msg:hover .chat-del, .chat-del:focus{ opacity:1; }
@media (hover:none){ .chat-del{ opacity:.55; } }
.chat-seen{ align-self:flex-end; font-size:11px; color:var(--ok); margin:0 4px 2px; }

.chat-compose{ border-top:1px solid var(--line); padding:8px 10px 8px; background:var(--card); border-radius:0 0 12px 12px; }
.chat-row{ display:flex; align-items:flex-end; gap:6px; }
.chat-row textarea{
  flex:1; resize:none; min-height:40px; max-height:160px; padding:9px 12px; border:1px solid var(--line);
  border-radius:20px; font:inherit; font-size:15px; line-height:1.35; background:#fff; margin:0;
}
.chat-row textarea:focus{ outline:none; border-color:var(--accent); }
.chat-clip, .chat-send{
  flex-shrink:0; width:40px; height:40px; border-radius:50%; border:none; cursor:pointer; font-size:18px;
  display:flex; align-items:center; justify-content:center; padding:0;
}
.chat-clip{ background:#f1ece3; }
.chat-send{ background:var(--accent); color:#fff; }
.chat-send:disabled{ opacity:.6; cursor:default; }
.chat-under{ display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; margin-top:4px; }
.chat-tip{ margin:0; font-size:11.5px; }
.chat-err{ color:var(--danger); font-size:13px; }
.chat-err:empty{ display:none; }
.chat-files{ display:flex; gap:6px; flex-wrap:wrap; }
.chat-files:not(:empty){ margin-bottom:6px; }
.chat-file{ position:relative; }
.chat-file img{ width:62px; height:62px; object-fit:cover; border-radius:8px; display:block; border:1px solid var(--line); }
.chat-file button{ position:absolute; top:-6px; right:-6px; width:20px; height:20px; border-radius:50%; border:none; background:var(--ink); color:#fff; font-size:11px; cursor:pointer; padding:0; }
.chat-import{ background:var(--warn-bg); border-radius:10px; padding:8px 10px; margin-bottom:8px; }
.chat-import-h{ display:flex; justify-content:space-between; font-weight:600; font-size:14px; }
.chat-import .small-note{ margin:4px 0 6px; }
.chat-import-row{ display:flex; flex-wrap:wrap; gap:8px; }
.chat-import-row label{ display:flex; flex-direction:column; font-size:12px; color:var(--ink-soft); gap:2px; margin:0; }
.chat-import-row select, .chat-import-row input{ margin:0; padding:5px 8px; font-size:14px; width:auto; }

/* ---- страница ученика ---- */
.chat-card .chat-msgs{ max-height:420px; }

/* ---- «Сообщения» у фотографа ---- */
.chat-inbox{
  display:grid; grid-template-columns:300px 1fr; gap:0; background:var(--card); border:1px solid var(--line); border-radius:14px;
  height:calc(100vh - var(--hdr-h, 73px) - 60px); min-height:420px; overflow:hidden;
}
.chat-inbox-list{ border-right:1px solid var(--line); overflow-y:auto; }
.chat-conv{
  display:block; width:100%; text-align:left; border:none; border-bottom:1px solid var(--line); background:none;
  padding:10px 14px; cursor:pointer; font:inherit;
}
.chat-conv:hover{ background:#f8f4ee; }
.chat-conv.active{ background:var(--accent-soft); }
.chat-conv-top{ display:flex; justify-content:space-between; gap:8px; }
.chat-conv-top b{ font-size:14.5px; }
.chat-conv-when{ font-size:12px; color:var(--ink-soft); white-space:nowrap; }
.chat-conv-where{ display:block; font-size:12px; color:var(--ink-soft); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chat-conv-last{ display:flex; justify-content:space-between; align-items:center; gap:6px; font-size:13px; color:var(--ink-soft); margin-top:2px; }
.chat-conv.unread .chat-conv-last{ color:var(--ink); font-weight:600; }
.chat-inbox-thread{ display:flex; flex-direction:column; min-height:0; min-width:0; }
.chat-inbox-thread > .chat-empty{ margin:auto; }
.chat-thread-head{ display:flex; align-items:center; gap:12px; padding:10px 14px; border-bottom:1px solid var(--line); }
.chat-thread-head > div{ flex:1; min-width:0; }
.chat-thread-head small{ display:block; color:var(--ink-soft); font-size:12px; }
.chat-thread-head .chat-back{ display:none; }
.chat-inbox .chat-box{ flex:1; border:none; border-radius:0; }
.chat-inbox .chat-msgs{ max-height:none; }
.chat-inbox .chat-compose{ border-radius:0; }

/* ---- родитель: кнопка, карточка, окно ---- */
.chat-top-btn{
  margin-left:auto; display:inline-flex; align-items:center; border:1px solid var(--line); background:var(--card);
  border-radius:18px; padding:5px 11px; font-size:14px; cursor:pointer; color:var(--ink); white-space:nowrap;
}
.chat-top-btn .chat-badge{ margin-left:5px; }
.chat-hub-card{
  display:flex; align-items:center; gap:14px; width:100%; text-align:left; cursor:pointer; font:inherit; color:inherit;
  background:var(--card); border:1px solid var(--line); border-radius:14px; padding:14px 16px; margin-bottom:18px;
}
.chat-hub-card:hover{ border-color:var(--accent); }
.chat-hub-ico{ font-size:26px; }
.chat-hub-text{ flex:1; display:flex; flex-direction:column; }
.chat-hub-text span{ font-size:13px; color:var(--ink-soft); }
.chat-hub-card .chat-badge{ font-size:13px; min-width:24px; height:24px; border-radius:12px; }

body.chat-overlay-open{ overflow:hidden; }
.chat-overlay{
  position:fixed; inset:0; z-index:1000; background:rgba(30,24,18,.45);
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.chat-panel{
  width:100%; max-width:560px; height:min(760px, 100%); background:var(--card); border-radius:16px;
  display:flex; flex-direction:column; overflow:hidden; box-shadow:0 12px 40px rgba(0,0,0,.25);
}
.chat-panel-head{ display:flex; align-items:center; gap:10px; padding:12px 14px; border-bottom:1px solid var(--line); }
.chat-panel-head > div{ flex:1; }
.chat-panel-head small{ display:block; color:var(--ink-soft); font-size:12.5px; }
.chat-close{ width:36px; height:36px; border-radius:50%; border:none; background:#f1ece3; font-size:16px; cursor:pointer; }
.chat-panel .chat-box{ flex:1; border:none; border-radius:0; }
.chat-panel .chat-msgs{ max-height:none; }
.chat-panel .chat-compose{ border-radius:0; padding-bottom:max(8px, env(safe-area-inset-bottom)); }

@media (max-width:760px){
  .chat-inbox{ grid-template-columns:1fr; height:auto; min-height:0; }
  .chat-inbox .chat-msgs{ max-height:calc(100vh - 330px); max-height:calc(100dvh - 330px); min-height:220px; }
  .chat-inbox.has-sel .chat-inbox-list{ display:none; }
  .chat-inbox:not(.has-sel) .chat-inbox-thread{ display:none; }
  .chat-inbox-list{ border-right:none; }
  .chat-thread-head .chat-back{ display:inline; }
  .chat-thread-head{ flex-wrap:wrap; gap:4px 10px; }
  .sidebar .chat-badge{ margin-left:4px; }
}
@media (max-width:600px){
  .chat-overlay{ padding:0; }
  .chat-panel{ max-width:none; height:100%; border-radius:0; }
  .chat-bubble{ max-width:86%; }
  .chat-row textarea{ font-size:16px; } /* иначе iOS зумит */
  .chat-card .chat-msgs{ max-height:60vh; }
  .chat-tip{ display:none; }
}
