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

:root {
    --primary-color: #007AFF;
    --success-color: #34C759;
    --danger-color: #FF3B30;
    --bg-color: #F2F2F7;
    --card-bg: #FFFFFF;
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --border-color: #E5E5EA;
    --message-bg: #E9E9EB;
    --message-own-bg: #007AFF;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 100% !important;
    width: 100% !important;
    flex: 1;
    margin: 0 auto !important;
    position: relative;
}

.page {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
}

.page.active {
    display: flex;
}

/* 登录页面 */
#loginPage {
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: calc(100vh - 50px);
}

.card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.card h1 {
    font-size: 28px;
    margin-bottom: 30px;
    color: var(--text-primary);
}

.login-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px 20px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn svg {
    width: 20px;
    height: 20px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #0051D5;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--primary-color);
}

.btn-secondary:hover {
    background: #E5E5EA;
}

.btn-scan {
    background: var(--success-color);
    color: white;
}

.btn-scan:hover {
    background: #2DB84D;
}

.divider {
    color: var(--text-secondary);
    font-size: 14px;
}

.join-group {
    display: flex;
    gap: 10px;
}

.join-group .btn {
    width: auto;
    flex-shrink: 0;
}

.join-group input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.join-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 群组页面 */
#groupPage {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
}

#groupPage.active {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: var(--card-bg);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.group-info h2 {
    font-size: 18px;
    font-weight: 600;
}

#groupIdDisplay {
    font-family: monospace;
    letter-spacing: 2px;
}

.member-count {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: block;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-color);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.icon-btn:hover {
    background: #E5E5EA;
}

.btn-danger:hover {
    background: #FFE5E5;
    color: var(--danger-color);
}

/* 消息区域 */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.welcome-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
}

.welcome-message svg {
    width: 60px;
    height: 60px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.message {
    display: flex;
    flex-direction: row;
    gap: 8px;
    max-width: 80%;
    animation: slideIn 0.3s ease;
    align-items: flex-start;
}

.message.other {
    flex-direction: row;
}

.message.own {
    flex-direction: row-reverse;
}

.message-avatar {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid;
    background-color: var(--bg-color);
}

.avatar-emoji {
    font-size: 18px;
    line-height: 1;
}

.message-sender {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    max-width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.message.own .message-wrapper {
    align-items: flex-end;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.own {
    align-self: flex-end;
    align-items: flex-end;
}

.message.other {
    align-self: flex-start;
    align-items: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    white-space: pre-wrap;
    word-break: break-word;
    position: relative;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.message-content:hover {
    filter: brightness(0.95);
}

.message-content::after {
    content: '点击复制';
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    white-space: nowrap;
}

.message-content:hover::after {
    opacity: 1;
}

.message.own .message-content {
    background: var(--message-own-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.other .message-content {
    background: var(--message-bg);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    margin-left: 12px;
}

.message.own .message-time {
    margin-left: 0;
    margin-right: 12px;
}

/* 文件消息 */
.file-message {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-icon svg {
    width: 24px;
    height: 24px;
}

.file-info {
    display: flex;
    flex-direction: column;
}

.file-name {
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 12px;
    opacity: 0.7;
}

.file-download {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
}

/* 图片消息 */
.image-message img {
    max-width: 250px;
    max-height: 250px;
    border-radius: 12px;
    cursor: pointer;
}

.image-message img:hover {
    opacity: 0.9;
}

/* 输入区域 */
.input-area {
    background: var(--card-bg);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.input-actions {
    display: flex;
    gap: 5px;
}

#messageInput {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    font-size: 16px;
    font-family: inherit;
    background: var(--bg-color);
    min-height: 44px;
    max-height: 120px;
    resize: none;
    overflow-y: auto;
    line-height: 1.4;
}

#messageInput:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
}

#messageInput::placeholder {
    color: var(--text-secondary);
}

.btn-send {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
    border: none;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-send:hover {
    background: #0051D5;
    transform: scale(1.05);
}

.btn-send svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 100%;
    position: relative;
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content h3 {
    text-align: center;
    margin-bottom: 20px;
}

.close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close:hover {
    background: var(--bg-color);
}

#qrCodeContainer {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

#qrCodeContainer canvas,
#qrCodeContainer img {
    border-radius: 12px;
    border: 10px solid white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.group-id-display {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    font-family: monospace;
    letter-spacing: 2px;
    margin-bottom: 15px;
}

.url-display {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.url-display input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 12px;
    background: var(--bg-color);
}

.btn-small {
    padding: 10px 15px;
    border: none;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.btn-small:hover {
    background: #0051D5;
}

/* 扫码弹窗 */
.scan-video {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
}

.scan-overlay {
    position: relative;
    margin-top: 15px;
}

.scan-box {
    width: 250px;
    height: 250px;
    margin: 0 auto;
    border: 3px solid var(--primary-color);
    border-radius: 20px;
    position: relative;
}

.scan-box::before,
.scan-box::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border-color: var(--primary-color);
    border-style: solid;
}

.scan-box::before {
    top: -3px;
    left: -3px;
    border-width: 4px 0 0 4px;
    border-top-left-radius: 20px;
}

.scan-box::after {
    bottom: -3px;
    right: -3px;
    border-width: 0 4px 4px 0;
    border-bottom-right-radius: 20px;
}

.scan-hint {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 15px;
    font-size: 14px;
}

#switchCameraBtn {
    width: 100%;
    margin-top: 15px;
}

/* 版权备案信息 */
.footer {
    text-align: center;
    padding: 15px;
    font-size: 12px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.footer span {
    color: var(--text-secondary);
}

.footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer a:hover {
    color: var(--primary-color);
}

/* 响应式 */
@media (max-width: 480px) {
    /* 暂时注释掉以测试PC端样式 */
    /*
    #groupPage {
        max-width: 100% !important;
        margin: 0 !important;
        border-left: none !important;
        border-right: none !important;
        box-shadow: none !important;
    }
    */

    .card {
        padding: 30px 20px;
    }

    .card h1 {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .btn {
        padding: 12px 16px;
        font-size: 15px;
    }

    .btn svg {
        width: 18px;
        height: 18px;
    }

    .join-group {
        flex-direction: column;
        gap: 8px;
    }

    .join-group input {
        width: 100%;
        padding: 12px;
        font-size: 18px;
        letter-spacing: 3px;
    }

    .join-group .btn {
        width: 100%;
    }

    .header {
        padding: 12px 15px;
    }

    .group-info h2 {
        font-size: 16px;
    }

    .messages-container {
        padding: 15px;
    }

    .message {
        max-width: 90%;
        gap: 6px;
    }

    .avatar {
        width: 32px;
        height: 32px;
    }

    .avatar-emoji {
        font-size: 16px;
    }

    .input-area {
        padding: 10px 12px;
        gap: 8px;
    }

    .input-actions {
        gap: 4px;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
    }

    .btn-send {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    .btn-send svg {
        width: 18px;
        height: 18px;
    }

    #messageInput {
        font-size: 16px;
    }

    .modal-content {
        padding: 20px;
    }
}

/* 系统消息 */
.system-message {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    align-self: center;
    max-width: 90%;
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 9999;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 历史消息加载按钮 */
.history-button {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 15px auto;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--primary-color), #0051D5);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 122, 255, 0.3);
}

.history-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.4);
}

.history-button:active {
    transform: translateY(0);
}
