/* 云舍 YS-SKIN v1 · 仅样式改造，选择器与原版保持一致 */

/* ========== 设计令牌（YS-SKIN §1） ========== */
:root {
  --ys-blue: #2B5CFF;
  --ys-blue-hover: #1B48E0;
  --ys-purple: #7C5CFF;
  --ys-cyan: #22C8F5;
  --ys-ink: #0B1220;
  --ys-ink-2: #3D4657;
  --ys-muted: #5B6472;
  --ys-faint: #8A94A6; /* 扩展令牌：时间、弱提示 */
  --ys-bg: #FFFFFF;
  --ys-bg-soft: #F6F8FC;
  --ys-wash: #EEF3FF;
  --ys-line: #E6E9F0;
  --ys-danger: #E5484D;
  --ys-success: #12B76A;
  --ys-warning: #F79009;
  --ys-gradient: linear-gradient(135deg, #2B5CFF 0%, #7C5CFF 100%);
  --ys-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --ys-shadow-md: 0 8px 24px rgba(43, 92, 255, 0.10);
  --ys-shadow-lg: 0 24px 60px rgba(11, 18, 32, 0.14);
  --ys-ease: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  color: var(--ys-ink);
  background:
    radial-gradient(ellipse at top left, rgba(43, 92, 255, 0.08), transparent 45%),
    linear-gradient(180deg, #FFFFFF 0%, #F6F8FC 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ========== 登录页：浅蓝极光 + 白卡 ========== */
.login-view {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 62% 52% at 16% 12%, rgba(43, 92, 255, 0.18), transparent 62%),
    radial-gradient(ellipse 56% 48% at 86% 18%, rgba(124, 92, 255, 0.15), transparent 62%),
    radial-gradient(ellipse 72% 56% at 50% 102%, rgba(34, 200, 245, 0.10), transparent 66%),
    #EDF2FB;
}
.login-card {
  width: min(420px, 100%);
  background: var(--ys-bg);
  border: 1px solid var(--ys-line);
  border-radius: 16px;
  box-shadow: var(--ys-shadow-lg);
  padding: 32px 30px 24px;
}
.brand { text-align: center; margin-bottom: 18px; }
.brand h1 {
  margin: 10px 0 4px;
  font-size: 28px;
  letter-spacing: 0.02em;
  color: var(--ys-ink);
}
.brand p { margin: 0; color: var(--ys-muted); font-size: 13px; }
.login-card label {
  display: block;
  font-size: 13px;
  color: var(--ys-muted);
  margin-bottom: 12px;
}
.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1px solid var(--ys-line);
  border-radius: 10px;
  outline: none;
  background: #fff;
  color: var(--ys-ink);
}
.login-card input:focus { border-color: var(--ys-blue); box-shadow: 0 0 0 3px rgba(43, 92, 255, 0.14); }
#login-btn {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--ys-gradient);
  color: #fff;
  font-weight: 600;
  transition: transform 240ms var(--ys-ease), opacity 240ms var(--ys-ease);
}
#login-btn:hover { transform: translateY(-1px); box-shadow: var(--ys-shadow-md); }
.error { color: var(--ys-danger); font-size: 13px; margin-top: 10px; }
.cred-tip {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--ys-bg-soft);
  border: 1px solid var(--ys-line);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ys-ink-2);
}
.cred-title { font-weight: 700; margin-bottom: 2px; color: var(--ys-ink); }
.cred-sub { margin-top: 4px; color: var(--ys-muted); font-size: 12px; }

/* ========== 主框架 ========== */
.main-view {
  height: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 64px 300px minmax(0, 1fr);
  gap: 0;
  background: #fff;
}

/* 深色侧栏：冷调蓝黑（行业惯例深色形态保留） */
.rail {
  background: linear-gradient(180deg, #0E1422, #16233F);
  color: #9FB0D0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
}
.rail-brand {
  margin-bottom: 6px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.10);
  display: grid;
  place-items: center;
}
.rail-brand img { width: 28px; height: 28px; }
.rail-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #9FB0D0;
  font-weight: 700;
  font-size: 14px;
  transition: transform 220ms var(--ys-ease), opacity 220ms var(--ys-ease);
}
.rail-btn.active, .rail-btn:hover { background: rgba(43, 92, 255, 0.25); color: #fff; }
.rail-spacer { flex: 1; }

/* 会话 / 通讯录列 */
.sidebar {
  background: var(--ys-bg-soft);
  border-right: 1px solid var(--ys-line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.side-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--ys-line); background: #fff; }
.side-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.side-title { font-size: 17px; font-weight: 700; color: var(--ys-ink); }
.side-sub { color: var(--ys-muted); font-size: 12px; margin-top: 2px; }
.side-action, .head-btn, .link-btn, .primary-btn {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}
.side-action, .head-btn {
  height: 30px;
  padding: 0 10px;
  background: #fff;
  border: 1px solid rgba(43, 92, 255, 0.35);
  color: var(--ys-blue);
  font-size: 13px;
  flex-shrink: 0;
}
.link-btn { background: transparent; color: var(--ys-blue); font-size: 12px; padding: 0; }
.primary-btn {
  height: 36px;
  padding: 0 16px;
  background: var(--ys-gradient);
  color: #fff;
  font-weight: 600;
  transition: transform 240ms var(--ys-ease), opacity 240ms var(--ys-ease);
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: var(--ys-shadow-md); }
.side-search {
  width: 100%;
  margin-top: 10px;
  padding: 8px 11px;
  border: 1px solid var(--ys-line);
  border-radius: 10px;
  background: var(--ys-bg-soft);
  outline: none;
  color: var(--ys-ink);
}
.side-search:focus { border-color: var(--ys-blue); background: #fff; box-shadow: 0 0 0 3px rgba(43, 92, 255, 0.14); }
.side-list { overflow: auto; flex: 1; padding: 6px; }
.item {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.item:hover { background: var(--ys-wash); }
.item.active { background: var(--ys-wash); color: var(--ys-blue-hover); }
.avatar-wrap { position: relative; width: 40px; height: 40px; }
.unread-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--ys-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  background: var(--ys-gradient);
}
.avatar.sm { width: 32px; height: 32px; border-radius: 8px; font-size: 12px; flex-shrink: 0; }
.avatar.group { background: linear-gradient(135deg, #7C5CFF 0%, #22C8F5 100%); }
.item-body { min-width: 0; }
.item-top { display: flex; align-items: baseline; gap: 8px; }
.item-name { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-time { color: var(--ys-faint); font-size: 11px; flex-shrink: 0; }
.item-meta {
  color: var(--ys-muted);
  font-size: 12px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dept-label {
  margin: 10px 8px 6px;
  font-size: 12px;
  color: var(--ys-muted);
  font-weight: 600;
}
.online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9AA5B5;
  margin-right: 4px;
}
.online-dot.on { background: var(--ys-success); }

/* 聊天区 */
.chat {
  background:
    radial-gradient(ellipse at top, rgba(43, 92, 255, 0.05), transparent 55%),
    var(--ys-bg-soft);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.chat-empty {
  margin: auto;
  color: var(--ys-muted);
  font-size: 14px;
  padding: 24px;
  text-align: center;
}
.chat-room,
#chat-room {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chat-head {
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--ys-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chat-title { font-size: 15px; font-weight: 700; color: var(--ys-ink); }
.chat-sub { color: var(--ys-muted); font-size: 12px; margin-top: 2px; max-width: 72ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-list {
  flex: 1;
  overflow: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.msg-list::before {
  content: "";
  flex: 1 0 auto;
}
.time-sep {
  display: flex;
  justify-content: center;
  margin: 6px 0 2px;
}
.time-sep span {
  background: rgba(11, 18, 32, 0.06);
  color: var(--ys-muted);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
}
.sys-tip {
  text-align: center;
  color: var(--ys-faint);
  font-size: 12px;
  padding: 4px 0;
}
.bubble-row { display: flex; gap: 8px; max-width: 72%; align-items: flex-start; }
.bubble-row.me { margin-left: auto; flex-direction: row-reverse; }
.bubble-wrap { min-width: 0; }
.bubble {
  background: #fff;
  border: 1px solid var(--ys-line);
  border-radius: 12px 12px 12px 4px;
  padding: 8px 11px;
  position: relative;
  cursor: context-menu;
  box-shadow: var(--ys-shadow-sm);
}
.bubble.media { padding: 4px; background: transparent; border: 0; box-shadow: none; }
.bubble-row.me .bubble {
  background: #DDF5E3;
  border-color: #B7E8C4;
  border-radius: 12px 12px 4px 12px;
}
.bubble-row.me .bubble.media { background: transparent; border: 0; box-shadow: none; }
.bubble-name { font-size: 12px; color: var(--ys-muted); margin-bottom: 3px; }
.bubble-time {
  font-size: 11px;
  color: var(--ys-faint);
  margin-top: 3px;
  text-align: right;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}
.bubble-row:not(.me) .bubble-time { justify-content: flex-start; text-align: left; }
.read-state { font-size: 11px; }
.read-state.is-read { color: var(--ys-blue); }
.read-state.is-unread { color: var(--ys-faint); }
.bubble-text { white-space: pre-wrap; word-break: break-word; line-height: 1.45; font-size: 14px; }
.item-time { font-size: 10px !important; max-width: 118px; text-align: right; line-height: 1.2; white-space: normal; }
.media-image img {
  display: block;
  max-width: min(280px, 56vw);
  max-height: 220px;
  border-radius: 8px;
  cursor: zoom-in;
  background: var(--ys-line);
}
.media-video video {
  display: block;
  max-width: min(280px, 56vw);
  max-height: 220px;
  border-radius: 8px;
  background: var(--ys-ink);
}
.media-file {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 180px;
  max-width: 260px;
  text-decoration: none;
  color: inherit;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--ys-line);
  border-radius: 10px;
  box-shadow: var(--ys-shadow-sm);
}
.bubble-row.me .media-file { background: #EAF8EE; border-color: #B7E8C4; }
.file-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--ys-gradient);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.file-name { font-size: 13px; font-weight: 600; word-break: break-all; }
.file-size { font-size: 11px; color: var(--ys-muted); margin-top: 2px; }

/* 输入区 */
.composer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 14px 10px;
  background: #fff;
  border-top: 1px solid var(--ys-line);
  flex-shrink: 0;
}
.composer-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 4px 4px 4px 12px;
  border: 1px solid var(--ys-line);
  border-radius: 10px;
  background: var(--ys-bg-soft);
}
.composer-box:focus-within {
  border-color: var(--ys-blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(43, 92, 255, 0.14);
}
.composer textarea {
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  padding: 6px 0;
  margin: 0;
  line-height: 20px;
  height: 32px;
  min-height: 32px;
  max-height: 96px;
  overflow-y: auto;
  font-size: 14px;
  color: var(--ys-ink);
}
.composer-hint {
  font-size: 11px;
  color: var(--ys-faint);
  padding-left: 2px;
  line-height: 1;
}
#btn-send {
  border: 0;
  border-radius: 10px;
  height: 32px;
  padding: 0 14px;
  background: var(--ys-gradient);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 240ms var(--ys-ease), opacity 240ms var(--ys-ease);
}
#btn-send:hover { transform: translateY(-1px); box-shadow: var(--ys-shadow-md); }

.toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 0 2px 2px;
}
.tool-btn {
  border: 0;
  background: var(--ys-bg-soft);
  color: var(--ys-ink-2);
  border-radius: 10px;
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
}
.tool-btn:hover { background: var(--ys-wash); color: var(--ys-blue); }
.emoji-panel {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  max-height: 140px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--ys-line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--ys-shadow-lg);
}
.emoji-item {
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1.2;
  padding: 4px;
  border-radius: 8px;
}
.emoji-item:hover { background: var(--ys-wash); }

/* 消息右键菜单 */
.msg-menu {
  position: fixed;
  z-index: 50;
  min-width: 120px;
  background: #fff;
  border: 1px solid var(--ys-line);
  border-radius: 10px;
  box-shadow: var(--ys-shadow-lg);
  padding: 4px;
}
.msg-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ys-ink-2);
}
.msg-menu button:hover:not(:disabled) { background: var(--ys-wash); }
.msg-menu button:disabled { color: var(--ys-faint); cursor: not-allowed; }

/* 图片灯箱 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(11, 18, 32, 0.72);
  display: grid;
  place-items: center;
  padding: 24px;
}
.lightbox img {
  max-width: min(920px, 92vw);
  max-height: 88vh;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

/* 群信息抽屉 / 遮罩 */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.35);
  z-index: 40;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(360px, 92vw);
  height: 100%;
  background: #fff;
  z-index: 41;
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 48px rgba(11, 18, 32, 0.14);
}
.drawer-head, .picker .drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ys-line);
}
.drawer-title { font-size: 16px; font-weight: 700; color: var(--ys-ink); }
.drawer-sub { font-size: 12px; color: var(--ys-muted); margin-top: 2px; }
.drawer-body { overflow: auto; padding: 12px 16px 24px; flex: 1; }
.drawer-section { margin-bottom: 18px; }
.drawer-label { font-size: 12px; color: var(--ys-muted); font-weight: 600; margin-bottom: 8px; }
.drawer-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drawer-roles, .drawer-members { display: flex; flex-direction: column; gap: 8px; }
.member-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  background: var(--ys-bg-soft);
}
.member-row .meta { font-size: 12px; color: var(--ys-muted); }
.role-tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--ys-wash);
  color: var(--ys-blue);
}
.role-tag.owner { background: rgba(247, 144, 9, 0.12); color: #B45309; }
.role-tag.admin { background: rgba(124, 92, 255, 0.12); color: var(--ys-purple); }
.member-actions { display: flex; gap: 4px; }
.member-actions button {
  border: 0;
  background: #fff;
  border: 1px solid var(--ys-line);
  border-radius: 8px;
  font-size: 11px;
  padding: 3px 6px;
  cursor: pointer;
  color: var(--ys-ink-2);
}

/* 成员选择器 */
.picker {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 94vw);
  max-height: min(80vh, 720px);
  background: #fff;
  z-index: 42;
  border-radius: 16px;
  box-shadow: var(--ys-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.picker-hint { padding: 8px 16px; font-size: 12px; color: var(--ys-muted); background: var(--ys-bg-soft); border-bottom: 1px solid var(--ys-line); }
.picker-depts { overflow: auto; padding: 10px 16px; flex: 1; }
.picker-dept { margin-bottom: 12px; }
.picker-dept-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ys-ink);
}
.picker-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 13px;
}
.picker-foot {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--ys-line);
  background: #fff;
}
.picker-name {
  flex: 1;
  border: 1px solid var(--ys-line);
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
  color: var(--ys-ink);
}

/* ========== 响应式：断点与原版一致，仅适配新令牌 ========== */
@media (max-width: 720px) {
  .main-view { grid-template-columns: 64px 1fr; }
  .sidebar { display: none; }
  .main-view.show-side .sidebar { display: flex; position: absolute; left: 64px; top: 0; bottom: 0; width: min(300px, calc(100vw - 64px)); z-index: 5; box-shadow: var(--ys-shadow-lg); }
  .main-view.show-side .chat { display: none; }
}
