/* ============================================================
 * 《白石岭没有下线》 — css/qq.css
 * QQ 2006 风格（PHASE 03）
 * 主窗口：蓝色渐变标题栏 / 好友列表（在线绿点·离线灰点）/
 * 聊天区（消息气泡左右排列）/ 输入框 + 发送按钮
 * 参考 IMG_017 设计
 * ============================================================ */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: "SimSun", "宋体", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    -webkit-user-select: none;
    user-select: none;
}

/* ============================================================
 * QQ 主窗口（pages/qq/index.html）
 * ============================================================ */
.qq-desktop {
    position: fixed;
    inset: 0;
    background: #3a6ea5;
    background-image:
        radial-gradient(circle at 50% 60%, #5a9bd8 0%, transparent 55%),
        linear-gradient(180deg, #1e5f9e 0%, #3a8ec4 45%, #2c6aa8 100%);
}

/* ---------- 主窗口 ---------- */
.qq-window {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 620px;
    height: 460px;
    transform: translate(-50%, -50%);
    background: #ece9d8;
    border: 1px solid #0a246a;
    box-shadow: 3px 3px 12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* 最小化状态（缩小淡出到任务栏） */
.qq-window.minimized {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 0;
    pointer-events: none;
}

/* ---------- 标题栏：蓝色渐变 ---------- */
.qq-titlebar {
    height: 30px;
    display: flex;
    align-items: center;
    padding: 0 4px 0 10px;
    background: linear-gradient(180deg, #6aa8f0 0%, #3d7fe0 12%, #2a63c8 60%, #1c4a9e 100%);
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
    text-shadow: 1px 1px 1px rgba(0, 30, 80, 0.8);
}

.qq-title {
    flex: 1;
}

.win-btn {
    width: 20px;
    height: 20px;
    margin-left: 3px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: linear-gradient(180deg, #f0f4fa, #c8d4e4);
    color: #333;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    border-radius: 2px;
}
.win-btn:hover {
    background: linear-gradient(180deg, #fff, #e0e8f4);
}
.win-btn.close {
    background: linear-gradient(180deg, #f8b0a8, #d04840);
    color: #fff;
}
.win-btn.close:hover {
    background: linear-gradient(180deg, #ffc8c0, #e06058);
}

/* ---------- 主体：左好友列表 + 右聊天区 ---------- */
.qq-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* 好友列表 */
.qq-friends {
    width: 170px;
    background: linear-gradient(180deg, #ffffff, #f0f2f6);
    border-right: 1px solid #b8c2d0;
    overflow-y: auto;
}

.qq-friends-title {
    padding: 8px 10px 4px;
    font-size: 12px;
    color: #4a6a9a;
    font-weight: bold;
}

.friend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    cursor: pointer;
    border-left: 2px solid transparent;
}

.friend-item:hover {
    background: #e8f0fa;
}

.friend-item.active {
    background: #d8e8f8;
    border-left: 2px solid #2a63c8;
}

/* 头像 */
.friend-avatar {
    position: relative;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
}

.friend-avatar img {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border: 1px solid #8899aa;
    display: block;
}

/* 离线头像变灰 */
.friend-item.offline .friend-avatar img {
    filter: grayscale(100%);
    opacity: 0.75;
}

/* 状态点：在线绿 / 离线灰 */
.status-dot {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #fff;
    background: #55b02a; /* 在线绿 */
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.4);
}
.friend-item.offline .status-dot {
    background: #9aa4ac; /* 离线灰 */
}

.friend-name {
    font-size: 13px;
    color: #222;
}

/* 离线联系人文字灰色 */
.friend-item.offline .friend-name {
    color: #8a929a;
}

.friend-sign {
    font-size: 11px;
    color: #9aa0a8;
    max-width: 95px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* 聊天区（iframe 容器） */
.qq-chat-frame {
    flex: 1;
    border: none;
    background: #f5f7fa;
}

/* ---------- 底部模拟任务栏（最小化/恢复） ---------- */
.qq-taskbar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 30px;
    display: flex;
    align-items: center;
    background: linear-gradient(180deg, #316ac5 0%, #245edb 8%, #1f4fc4 40%, #19409c 88%, #123277 100%);
    border-top: 1px solid #0a2f55;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
    z-index: 50;
}

.qq-taskbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    margin-left: 6px;
    padding: 0 10px;
    background: linear-gradient(180deg, #5a9adf, #2a63a8);
    border: 1px solid #1c4a7a;
    border-radius: 3px;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: none;
}
.qq-taskbar-btn.visible {
    display: flex;
}
.qq-taskbar-btn:hover {
    filter: brightness(1.15);
}
.qq-taskbar-btn .tb-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #55b02a;
    border: 1px solid #fff;
}

/* 回到桌面按钮 */
.qq-back {
    margin-left: auto;
    margin-right: 6px;
    color: #cfe0ff;
    font-size: 12px;
    text-decoration: none;
    padding: 3px 8px;
}
.qq-back:hover {
    text-decoration: underline;
    color: #fff;
}

/* ============================================================
 * 聊天窗口（pages/qq/chat.html，iframe 内）
 * ============================================================ */
.chat-page {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #f5f7fa;
}

/* 聊天对象头部 */
.chat-header {
    height: 34px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    background: linear-gradient(180deg, #e8eef6, #d4deea);
    border-bottom: 1px solid #b8c2d0;
}

.chat-header .friend-avatar {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
}
.chat-header .friend-avatar img {
    width: 26px;
    height: 26px;
}

.chat-header .status-dot {
    width: 9px;
    height: 9px;
}

.chat-header .chat-with {
    font-size: 13px;
    font-weight: bold;
    color: #222;
}

.chat-header .chat-status {
    font-size: 11px;
    color: #889;
}

/* 消息区 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f8fafc;
}

/* 消息行 */
.msg {
    display: flex;
    margin-bottom: 12px;
    align-items: flex-start;
    gap: 8px;
}

.msg .msg-avatar {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    object-fit: cover;
    border: 1px solid #b0bcc8;
}

.msg .bubble-wrap {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

.msg .msg-name {
    font-size: 11px;
    color: #667;
    margin-bottom: 2px;
}

.msg .bubble {
    padding: 7px 11px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.6;
    position: relative;
    word-break: break-word;
}

.msg .msg-time {
    font-size: 10px;
    color: #aab;
    margin-top: 2px;
}

/* 对方消息：左侧 */
.msg.in {
    flex-direction: row;
}
.msg.in .bubble {
    background: #ffffff;
    border: 1px solid #d0d8e2;
    border-top-left-radius: 2px;
}

/* 玩家消息：右侧，浅绿色背景 */
.msg.out {
    flex-direction: row-reverse;
}
.msg.out .bubble-wrap {
    align-items: flex-end;
}
.msg.out .bubble {
    background: #c9e7c0;
    border: 1px solid #a8d49a;
    border-top-right-radius: 2px;
}

/* 消息滑入动画：对方从左侧、自己从右侧（0.3秒） */
.msg.enter-in {
    animation: slideInLeft 0.3s ease-out;
}
.msg.enter-out {
    animation: slideInRight 0.3s ease-out;
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-24px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* 系统提示（离线等） */
.msg-sys {
    text-align: center;
    color: #8a929a;
    font-size: 11px;
    margin: 8px 0;
}

/* "对方正在输入……" 闪烁 */
.typing {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: #778;
    font-size: 12px;
}
.typing .dots {
    display: inline-block;
    animation: blink 1s steps(1) infinite;
}
.typing .typing-text {
    animation: blinkText 1s ease-in-out infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
@keyframes blinkText {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 离线提示条 */
.offline-hint {
    padding: 4px 12px;
    background: #eee;
    color: #8a929a;
    font-size: 11px;
    text-align: center;
    border-top: 1px solid #d8dde2;
}

/* 输入区 */
.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #eceef2;
    border-top: 1px solid #c8d0da;
}

.chat-input-bar textarea {
    flex: 1;
    height: 40px;
    resize: none;
    border: 1px solid #a0aab8;
    padding: 6px 8px;
    font-family: inherit;
    font-size: 13px;
    background: #fff;
    line-height: 1.5;
}

/* 发送按钮（黄色信封感） */
.send-btn {
    width: 64px;
    height: 40px;
    border: 1px solid #b8901a;
    background: linear-gradient(180deg, #ffe27a 0%, #f0c838 55%, #d8a818 100%);
    color: #5a3a00;
    font-family: inherit;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 3px;
}
.send-btn:hover {
    filter: brightness(1.08);
}
.send-btn:active {
    transform: translateY(1px);
}
.send-btn:disabled {
    filter: grayscale(60%);
    opacity: 0.6;
    cursor: default;
}

/* 降级友好 */
@media (prefers-reduced-motion: reduce) {
    .msg.enter-in, .msg.enter-out {
        animation: none;
    }
    .qq-window {
        transition: none;
    }
    .typing .dots, .typing .typing-text {
        animation: none;
    }
}
