/* チャット画面専用スタイル */

/* ヘッダーの高さ確保 */
.header {
    min-height: 56px;
}

/* ヘッダーのタイトル */
.page-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
}

/* ヘッダーの検索ボタン */
.chat-search-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    color: white;
    border-radius: 4px;
    transition: all 0.3s ease;
    position: absolute;
    right: 16px;
}

.chat-search-btn:hover {
    background-color: rgba(255,255,255,0.1);
}

/* チャットタブ切り替え */
.chat-tabs {
    display: flex;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    padding: 0;
}

.chat-tab {
    flex: 1;
    background-color: transparent;
    border: none;
    padding: 16px 12px;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.chat-tab.active {
    color: #2196F3;
    font-weight: 600;
}

.chat-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: #2196F3;
}

.chat-tab:hover:not(.active) {
    background-color: rgba(33, 150, 243, 0.05);
    color: #2196F3;
}

/* チャットリスト */
.chat-list {
    padding: 0;
}

.chat-room {
    display: flex;
    align-items: center;
    padding: 16px;
    background-color: white;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-room:hover {
    background-color: #f8f9fa;
}

.chat-room:active {
    background-color: #e9ecef;
}

.room-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-right: 12px;
    flex-shrink: 0;
}

.room-info {
    flex: 1;
    min-width: 0;
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.room-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.last-time {
    font-size: 12px;
    color: #999;
    flex-shrink: 0;
    margin-left: 8px;
}

.room-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.last-message {
    font-size: 14px;
    color: #666;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    line-height: 1.3;
}

.unread-badge {
    background-color: #ff4444;
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    flex-shrink: 0;
}

/* ヘッダーレイアウト調整 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 戻るボタン */
.back-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
}

.back-btn:hover {
    background-color: rgba(255,255,255,0.1);
}

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

/* アプリタイトル調整 */
.app-title {
    margin: 0;
}

/* ヘッダーの検索ボタン */
.chat-search-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    color: white;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.chat-search-btn:hover {
    background-color: rgba(255,255,255,0.1);
}

/* 特別なチャットルームスタイル */
.chat-room:first-child {
    border-top: none;
}

.chat-room:last-child {
    border-bottom: none;
}

/* 全世界チャットのアバター背景色 */
.chat-global .chat-room:nth-child(1) .room-avatar {
    background-color: #2196F3;
    color: white;
}

.chat-global .chat-room:nth-child(2) .room-avatar {
    background-color: #4CAF50;
    color: white;
}

.chat-global .chat-room:nth-child(3) .room-avatar {
    background-color: #FF9800;
    color: white;
}

.chat-global .chat-room:nth-child(4) .room-avatar {
    background-color: #9C27B0;
    color: white;
}

.chat-global .chat-room:nth-child(5) .room-avatar {
    background-color: #00BCD4;
    color: white;
}

.chat-global .chat-room:nth-child(6) .room-avatar {
    background-color: #795548;
    color: white;
}

.chat-global .chat-room:nth-child(7) .room-avatar {
    background-color: #607D8B;
    color: white;
}

.chat-global .chat-room:nth-child(8) .room-avatar {
    background-color: #E91E63;
    color: white;
}

/* チーム内チャットのアバター背景色 */
.chat-team .chat-room:nth-child(1) .room-avatar {
    background-color: #2196F3;
    color: white;
}

.chat-team .chat-room:nth-child(2) .room-avatar {
    background-color: #4CAF50;
    color: white;
}

.chat-team .chat-room:nth-child(3) .room-avatar {
    background-color: #FF9800;
    color: white;
}

.chat-team .chat-room:nth-child(4) .room-avatar {
    background-color: #9C27B0;
    color: white;
}

.chat-team .chat-room:nth-child(5) .room-avatar {
    background-color: #00BCD4;
    color: white;
}

.chat-team .chat-room:nth-child(6) .room-avatar {
    background-color: #FFC107;
    color: white;
}

.chat-team .chat-room:nth-child(7) .room-avatar {
    background-color: #795548;
    color: white;
}

.chat-team .chat-room:nth-child(8) .room-avatar {
    background-color: #E91E63;
    color: white;
}

/* 個人チャットのアバター */
.chat-personal .room-avatar {
    background-color: #e0e0e0;
}

/* チーム内チャットメッセージ */
.chat-messages {
    padding: 16px;
    padding-bottom: 80px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.message-item {
    display: flex;
    margin-bottom: 16px;
    align-items: flex-start;
}

/* システムメッセージ（参加・退出通知） */
.system-message {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 4px 0;
    padding: 2px 0;
    width: 100%;
    text-align: center;
    font-size: 11px;
}

.system-message.join {
    color: #4CAF50;
}

.system-message.leave {
    color: #FF9800;
}

.system-icon {
    font-size: 10px;
    margin-right: 4px;
    opacity: 0.7;
}

.system-text {
    font-size: 11px;
    color: inherit;
    font-weight: 400;
    opacity: 0.8;
}

.system-time {
    font-size: 10px;
    color: inherit;
    font-weight: 400;
    opacity: 0.6;
    margin-left: 4px;
}

.message-item.other {
    justify-content: flex-start;
}

.message-item.own {
    justify-content: flex-end;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #ddd;
    margin-right: 8px;
    flex-shrink: 0;
}

.message-item.own .message-avatar {
    display: none;
}

.message-content {
    max-width: 70%;
    background-color: #f8f9fa;
    border-radius: 12px;
    padding: 8px 12px;
    position: relative;
}

.message-item.own .message-content {
    background-color: #2196F3;
    color: white;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.message-user {
    font-size: 12px;
    font-weight: 600;
    color: #666;
}

.message-item.own .message-user {
    color: rgba(255,255,255,0.8);
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-left: 8px;
}

.message-item.own .message-time {
    color: rgba(255,255,255,0.7);
}

.message-text {
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    white-space: pre-line;
}

.message-item.own .message-text {
    color: white;
}

/* メッセージ入力欄 */
.message-input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 430px;
    margin: 0 auto;
    background-color: white;
    border-top: 1px solid #e0e0e0;
    padding: 12px 16px;
    z-index: 100;
}

.message-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.message-input:focus {
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.send-button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background-color: #2196F3;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.send-button:hover {
    background-color: #1976D2;
    transform: scale(1.05);
}

.send-button:active {
    transform: scale(0.95);
}

.send-icon {
    font-size: 16px;
}

/* メインコンテンツの下部パディング調整（ナビゲーション非表示のため） */
.main-content {
    padding-bottom: 20px;
}

/* チーム内チャット用の調整 */
.chat-team {
    padding: 0;
    position: relative;
    height: calc(100vh - 120px);
}

/* 全世界チャット用の調整 */
.chat-global {
    padding: 0;
    position: relative;
    height: calc(100vh - 120px);
}

/* レスポンシブ対応 */
@media (max-width: 430px) {
    .chat-room {
        padding: 12px 16px;
    }
    
    .room-avatar {
        width: 45px;
        height: 45px;
        font-size: 20px;
        margin-right: 10px;
    }
    
    .room-name {
        font-size: 15px;
    }
    
    .last-message {
        font-size: 13px;
    }
    
    .last-time {
        font-size: 11px;
    }
    
    .unread-badge {
        font-size: 11px;
        min-width: 16px;
        height: 16px;
        padding: 2px 5px;
    }
    
    .system-message {
        margin: 4px 0;
        padding: 2px 0;
        font-size: 10px;
    }
    
    .system-text {
        font-size: 10px;
    }
    
    .system-time {
        font-size: 9px;
    }
}