/* ==========================================
   聊天室样式
   ========================================== */

.chatroom-page {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 60px;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
    overflow: hidden;
}

.chatroom-guest__card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    max-width: 400px;
}

.chatroom-guest__icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.chatroom-guest__title {
    font-size: 24px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 10px;
}

.chatroom-guest__subtitle {
    color: #718096;
    margin-bottom: 30px;
}

.chatroom-button {
    display: inline-block;
    padding: 12px 32px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.chatroom-button--primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.chatroom-button--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* 聊天容器 */
.chatroom-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f9f9f9;
    -webkit-overflow-scrolling: touch;
}

/* 固定顶部标题栏 */
.chatroom-header-fixed {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.chatroom-header__content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    color: white;
}

.chatroom-header__title h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 2px 0;
}

.chatroom-header__subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
}

.chatroom-header__stats {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatroom-online {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
}

.chatroom-online__dot {
    width: 8px;
    height: 8px;
    background: #48bb78;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* 连接状态 */
.chatroom-status {
    background: #fed7d7;
    color: #c53030;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    flex-shrink: 0;
}

.chatroom-status__icon {
    font-size: 18px;
}

/* 封禁提示 */
.chatroom-banned {
    background: #fed7d7;
    border-left: 4px solid #c53030;
    padding: 16px 24px;
    margin: 16px 24px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatroom-banned__icon {
    font-size: 32px;
}

.chatroom-banned__content h3 {
    font-size: 16px;
    font-weight: 600;
    color: #c53030;
    margin: 0 0 4px 0;
}

.chatroom-banned__content p {
    color: #742a2a;
    margin: 0;
    font-size: 14px;
}

/* 消息区域包装器（可滚动） */
.chatroom-messages-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f9f9f9;
    -webkit-overflow-scrolling: touch;
}

/* 消息列表 */
.chatroom-messages {
    padding: 1rem;
    min-height: 100%;
}

.chatroom-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #718096;
}

.chatroom-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.chatroom-messages__list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chatroom-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #a0aec0;
    text-align: center;
}

.chatroom-empty__icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.chatroom-error {
    background: #fed7d7;
    color: #c53030;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}

/* 消息气泡 */
.chatroom-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

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

/* 自己的消息靠右 */
.chatroom-message--own {
    align-items: flex-end;
}

.chatroom-message__content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

.chatroom-message__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    padding: 0 4px;
}

.chatroom-message__user-id {
    font-weight: 500;
    font-size: 12px;
    color: #718096;
}

.chatroom-message--own .chatroom-message__user-id {
    color: #667eea;
}

.chatroom-message__time {
    font-size: 11px;
    color: #a0aec0;
}

.chatroom-message__text {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: 15px;
    line-height: 1.5;
    color: #2d3748;
}

.chatroom-message--own .chatroom-message__text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

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

/* 图片消息样式 */
.chatroom-message__image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    cursor: pointer;
    display: block;
    object-fit: contain;
    transition: transform 0.2s;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    background: white;
}

.chatroom-message__image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* 系统消息 */
.chatroom-system-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    margin: 0.5rem 0;
    animation: fadeIn 0.3s ease;
}

.chatroom-system-message__icon {
    font-size: 1.2rem;
}

.chatroom-system-message__text {
    color: #667eea;
    font-size: 14px;
    font-weight: 500;
}

/* 固定底部输入栏 */
.chatroom-input-fixed {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: white;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    padding: 0.5rem 0.75rem 0.75rem;
}

/* 工具栏 */
.chatroom-input-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.chatroom-toolbar-btn {
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    padding: 0;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chatroom-toolbar-btn:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

.chatroom-toolbar-btn:active {
    transform: scale(0.95);
}

.chatroom-input-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.chatroom-input {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 15px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.chatroom-input:focus {
    outline: none;
    border-color: #667eea;
}

.chatroom-input::placeholder {
    color: #a0aec0;
}

.chatroom-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
    padding: 0;
}

.chatroom-send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chatroom-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chatroom-send-icon {
    font-size: 18px;
}

.chatroom-input-hint {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
    font-size: 12px;
    color: #a0aec0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chatroom-page {
        padding: 0;
    }

    .chatroom-container {
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
    }

    .chatroom-header__content {
        padding: 0.5rem 0.75rem;
    }

    .chatroom-header__title h1 {
        font-size: 16px;
    }
    
    .chatroom-header__subtitle {
        font-size: 11px;
    }

    .chatroom-messages {
        padding: 16px;
    }

    .chatroom-message__content {
        max-width: 80%;
    }

    .chatroom-input-fixed {
        padding: 0.5rem;
    }

    .chatroom-send-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .chatroom-toolbar-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}

/* 滚动条样式 */
.chatroom-messages::-webkit-scrollbar {
    width: 6px;
}

.chatroom-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chatroom-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.chatroom-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}
