/* CASA 工作群 - 移动端优先的浅色主题样式 */
:root {
  --orange: #f18805;
  --orange-dark: #d86e00;
  --bg: #ededed;
  --bg-light: #ffffff;
  --text: #1a1a1a;
  --text-muted: #888888;
  --border: #e5e5e5;
  --danger: #fa5151;
  --warn-bg: #fef0f0;
  --warn-text: #d32f2f;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

.hidden { display: none !important; }

.screen { min-height: 100dvh; }

/* ---- 登录页 ---- */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #f7f7f7;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 16px;
  padding: 36px 28px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.06);
}
.logo-img {
  width: 96px; height: 96px; margin: 0 auto 16px;
  border-radius: 18px;
  object-fit: contain;
}
.auth-card h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
#login-form input {
  width: 100%; padding: 13px 14px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 10px; font-size: 16px;
}
#login-form input:focus { outline: none; border-color: var(--orange); }
.btn-primary {
  width: 100%; padding: 13px; border: none; border-radius: 10px;
  background: var(--orange); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-primary:active { background: var(--green-dark); }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }
.hint { color: #bbb; font-size: 12px; margin-top: 16px; }

/* ---- 主界面 ---- */
#app-screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + var(--safe-top)) 8px 8px;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 17px; font-weight: 600; flex: 1; text-align: center; }
.topbar-spacer { width: 40px; height: 40px; flex-shrink: 0; }
.icon-btn {
  width: 40px; height: 40px; border: none; background: transparent;
  font-size: 22px; cursor: pointer; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
}

.group-tabs {
  display: flex; background: var(--bg-light);
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1; padding: 10px 0; border: none; background: transparent;
  font-size: 15px; color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--orange); border-bottom-color: var(--orange); font-weight: 600; }

.message-list {
  flex: 1; overflow-y: auto; padding: 16px 12px;
  -webkit-overflow-scrolling: touch;
}
.day-divider { text-align: center; margin: 8px 0 16px; font-size: 12px; color: #999; }

.msg { display: flex; margin-bottom: 16px; }
.msg.mine { flex-direction: row-reverse; }
.avatar {
  width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; font-weight: 600;
}
.msg-body { max-width: 72%; margin: 0 10px; display: flex; flex-direction: column; }
.msg.mine .msg-body { align-items: flex-end; }
.sender { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.msg.mine .sender { text-align: right; }
.bubble {
  padding: 9px 12px; border-radius: 8px; background: #fff;
  font-size: 16px; line-height: 1.45; word-break: break-word; white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.msg.mine .bubble { background: #ffd8a6; }
.bubble img { display: block; max-width: 200px; border-radius: 6px; cursor: zoom-in; }
.msg-time { font-size: 11px; color: #bbb; margin-top: 4px; }

/* 机器人消息（WARNING 高亮） */
.msg.bot .bubble {
  background: var(--warn-bg); color: var(--warn-text); font-weight: 600;
  border: 1px solid #f3b4b4;
}

/* 图片加载态 */
.img-loading { width: 200px; height: 140px; background: #f0f0f0; border-radius: 6px; display:flex; align-items:center; justify-content:center; color:#aaa; font-size:13px; }

/* ---- 输入栏 ---- */
.composer {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 8px calc(8px + var(--safe-bottom));
  background: var(--bg-light); border-top: 1px solid var(--border);
}
.composer input[type="text"] {
  flex: 1; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 20px; font-size: 16px;
}
.composer input[type="text"]:focus { outline: none; border-color: var(--orange); }
.send-btn {
  padding: 10px 16px; border: none; border-radius: 20px;
  background: var(--orange); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.send-btn:active { background: var(--green-dark); }

/* ---- 抽屉 & 弹窗 ---- */
.mask { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 82%;
  background: var(--bg-light); z-index: 101;
  display: flex; flex-direction: column;
  transform: translateX(0); transition: transform .2s ease;
}
.drawer-header {
  display: flex; align-items: center; gap: 12px; padding: 24px 16px 16px;
  background: #f7f7f7; border-bottom: 1px solid var(--border);
}
.drawer-header .avatar { background: var(--orange); }
.drawer-name { font-size: 16px; font-weight: 600; }
.drawer-role { font-size: 12px; color: var(--text-muted); }
.drawer-body { flex: 1; overflow-y: auto; padding: 12px; }
.section-title { font-size: 13px; color: var(--text-muted); margin: 16px 4px 8px; }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 12px 8px; border: none; background: transparent;
  font-size: 15px; color: var(--text); cursor: pointer; text-align: left;
  border-radius: 8px;
}
.menu-item:active { background: #f0f0f0; }
.menu-item.danger { color: var(--danger); }
.my-group { display: flex; justify-content: space-between; padding: 10px 8px; font-size: 15px; border-bottom: 1px solid #f5f5f5; }
.badge { font-size: 12px; color: var(--orange); }

.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 92%; max-width: 480px; max-height: 84vh;
  background: var(--bg-light); border-radius: 16px; z-index: 101;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 17px; font-weight: 600; }
.modal-body { flex: 1; overflow-y: auto; padding: 16px; }
.create-user { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.create-user input {
  padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px;
}
.create-user input:focus { outline: none; border-color: var(--orange); }
.member-tabs { display: flex; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.mtab { flex: 1; padding: 8px 0; border: none; background: transparent; font-size: 14px; color: var(--text-muted); cursor: pointer; }
.mtab.active { color: var(--orange); font-weight: 600; border-bottom: 2px solid var(--orange); }
.user-list { list-style: none; }
.user-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 4px; border-bottom: 1px solid #f5f5f5;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 15px; font-weight: 500; }
.user-role { font-size: 12px; color: var(--text-muted); }
.user-actions { display: flex; gap: 6px; flex-shrink: 0; }
.mini-btn {
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; font-size: 13px; cursor: pointer; color: var(--text);
}
.mini-btn.in { background: var(--orange); border-color: var(--orange); color: #fff; }
.mini-btn.del { color: var(--danger); border-color: #f3c1c1; }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75); color: #fff; padding: 12px 18px;
  border-radius: 10px; font-size: 14px; z-index: 200; max-width: 80%; text-align: center;
}

/* 桌面端稍宽 */
@media (min-width: 640px) {
  #app-screen { max-width: 560px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
