/* ===== 沉浸式聊天模式 ===== */
/* 当 data-chat-style="immersive" 时激活 */

html[data-chat-style="immersive"] {
  --im-glass: rgba(255, 255, 255, 0.10);
  --im-glass-border: rgba(190, 215, 255, 0.38);
  --im-blue: #2f7cf6;
  --im-gray: rgba(62, 72, 92, 0.86);
}

/* 沉浸式背景 */
html[data-chat-style="immersive"] body[data-page="chat"] .bg-layer {
  background: linear-gradient(180deg, 
    #2d4a73 0%,
    #3d5a8a 15%,
    #4d6fa0 30%,
    #2d5080 50%,
    #1e3a65 70%,
    #0f2550 100%
  );
}

/* 隐藏普通的顶部导航 */
html[data-chat-style="immersive"] body[data-page="chat"] .floating-header {
  display: none !important;
}

/* 沉浸式状态栏 */
html[data-chat-style="immersive"] body[data-page="chat"]::before {
  content: "";
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  height: 54px;
  pointer-events: none;
}

html[data-chat-style="immersive"] body[data-page="chat"]::after {
  content: "00:00";
  position: fixed;
  z-index: 31;
  top: 6px;
  left: 34px;
  font-weight: 600;
  font-size: 17px;
  color: #fff;
  pointer-events: none;
}

/* 灵动岛 */
html[data-chat-style="immersive"] body[data-page="chat"] .chat::before {
  content: "";
  position: fixed;
  z-index: 30;
  left: 50%;
  top: 11px;
  width: 126px;
  height: 37px;
  transform: translateX(-50%);
  background: #000;
  border-radius: 20px;
  pointer-events: none;
}

/* 信号图标区域 */
html[data-chat-style="immersive"] body[data-page="chat"] .chat::after {
  content: "📶 5G 🔋";
  position: fixed;
  z-index: 31;
  top: 6px;
  right: 30px;
  font-size: 15px;
  color: #fff;
  pointer-events: none;
}

/* 顶部玻璃导航栏 */
.immersive-nav {
  position: fixed;
  z-index: 20;
  top: 62px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0 16px;
  pointer-events: none;
}

.immersive-back {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 52px;
  padding: 0 8px 0 12px;
  border-radius: 26px;
  background: var(--im-glass);
  backdrop-filter: blur(16px) saturate(170%);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  border: 1px solid var(--im-glass-border);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.35),
              inset 0 -1px 1px rgba(255, 255, 255, 0.08),
              0 6px 20px rgba(0, 10, 30, 0.25);
  color: #fff;
  pointer-events: auto;
}

.immersive-badge {
  padding: 3px 11px;
  border-radius: 999px;
  background: #dbe9ff;
  color: #1d3557;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
}

.immersive-video {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--im-glass);
  backdrop-filter: blur(16px) saturate(170%);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  border: 1px solid var(--im-glass-border);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.35),
              inset 0 -1px 1px rgba(255, 255, 255, 0.08),
              0 6px 20px rgba(0, 10, 30, 0.25);
  display: grid;
  place-items: center;
  color: #fff;
  pointer-events: auto;
}

/* 联系人头像 */
.immersive-contact {
  position: fixed;
  z-index: 20;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.immersive-avatar {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: linear-gradient(140deg, #f6d5c4, #c98d7b);
  display: grid;
  place-items: center;
  font: 600 28px Georgia, serif;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.immersive-name {
  margin-top: -10px;
  padding: 5px 12px 5px 16px;
  border-radius: 999px;
  background: var(--im-glass);
  backdrop-filter: blur(16px) saturate(170%);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  border: 1px solid var(--im-glass-border);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.35),
              inset 0 -1px 1px rgba(255, 255, 255, 0.08),
              0 6px 20px rgba(0, 10, 30, 0.25);
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 2px;
}

.immersive-name small {
  opacity: 0.55;
  font-size: 15px;
}

/* 顶部模糊遮罩 */
html[data-chat-style="immersive"] body[data-page="chat"] .chat {
  top: 0;
  padding-top: 150px;
}

.immersive-blur {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  height: 240px;
  pointer-events: none;
  background: linear-gradient(rgba(30, 55, 95, 0.35), transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  -webkit-mask-image: linear-gradient(#000 50%, transparent);
  mask-image: linear-gradient(#000 50%, transparent);
}

/* 消息气泡 */
html[data-chat-style="immersive"] body[data-page="chat"] .messages {
  gap: 8px;
}

html[data-chat-style="immersive"] body[data-page="chat"] .message {
  max-width: 72%;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  width: fit-content;
}

html[data-chat-style="immersive"] body[data-page="chat"] .message::before {
  display: none !important;
}

html[data-chat-style="immersive"] body[data-page="chat"] .bubble:not(.voice-bubble):not(.photo-bubble) {
  position: relative;
  max-width: 100%;
  padding: 8px 14px;
  border: 0;
  border-radius: 19px;
  font-size: 17px;
  line-height: 1.3;
  word-break: break-word;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-chat-style="immersive"] body[data-page="chat"] .message.ai .bubble:not(.voice-bubble):not(.photo-bubble) {
  background: var(--im-gray);
  color: #fff;
  align-self: flex-start;
}

html[data-chat-style="immersive"] body[data-page="chat"] .message.human .bubble:not(.voice-bubble):not(.photo-bubble) {
  background: var(--im-blue);
  color: #fff;
  align-self: flex-end;
}

/* 气泡尾巴 */
html[data-chat-style="immersive"] body[data-page="chat"] .bubble:not(.voice-bubble):not(.photo-bubble)::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 16px;
  height: 20px;
  background: inherit;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 20'%3E%3Cpath d='M0 0H6C6 10 9 17 16 20C10 21 4 20 0 18Z'/%3E%3C/svg%3E") no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 20'%3E%3Cpath d='M0 0H6C6 10 9 17 16 20C10 21 4 20 0 18Z'/%3E%3C/svg%3E") no-repeat;
}

html[data-chat-style="immersive"] body[data-page="chat"] .message.human .bubble::after {
  right: -6px;
}

html[data-chat-style="immersive"] body[data-page="chat"] .message.ai .bubble::after {
  left: -6px;
  transform: scaleX(-1);
}

/* 连续消息去掉尾巴 */
html[data-chat-style="immersive"] body[data-page="chat"] .message.ai + .message.ai:not(.message-group-start) .bubble::after,
html[data-chat-style="immersive"] body[data-page="chat"] .message.human + .message.human .bubble::after {
  display: none;
}

/* 时间戳 */
html[data-chat-style="immersive"] body[data-page="chat"] .chat-date-separator {
  align-self: center;
  margin: 16px 0 8px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
}

html[data-chat-style="immersive"] body[data-page="chat"] .meta {
  grid-column: 1;
  text-align: right;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  padding-top: 3px;
}

html[data-chat-style="immersive"] body[data-page="chat"] .message.ai .meta {
  text-align: left;
}

/* 输入栏保持原样，只调整位置 */
html[data-chat-style="immersive"] body[data-page="chat"] .composer-zone {
  bottom: calc(12px + env(safe-area-inset-bottom));
}

html[data-chat-style="immersive"] body[data-page="chat"] .composer {
  background: var(--im-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

html[data-chat-style="immersive"] body[data-page="chat"] .composer textarea {
  color: #fff;
}

html[data-chat-style="immersive"] body[data-page="chat"] .composer textarea::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

html[data-chat-style="immersive"] body[data-page="chat"] .tool-button,
html[data-chat-style="immersive"] body[data-page="chat"] .send-button {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
}

html[data-chat-style="immersive"] body[data-page="chat"] .model-chip {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* 隐藏底部 Tab Bar */
html[data-chat-style="immersive"] body[data-page="chat"] #tabBar {
  display: none !important;
}

/* 响应式 */
@media (max-width: 560px) {
  html[data-chat-style="immersive"] body[data-page="chat"] .message {
    max-width: 86%;
  }
  
  .immersive-avatar {
    width: 60px;
    height: 60px;
    font-size: 26px;
  }
  
  .immersive-name {
    font-size: 16px;
  }
}
